diff options
author | Karol Herbst <kherbst@redhat.com> | 2021-05-05 14:01:57 +0200 |
---|---|---|
committer | Karol Herbst <kherbst@redhat.com> | 2021-05-06 19:41:12 +0200 |
commit | 17a51b0b31c6e7f0d862fe30d3a3222d152c2966 (patch) | |
tree | 5711978200bb8228fc7790e37ef5fd52c01b3bf6 /nouveau | |
parent | c0ae9cfa001788bc33d69bd3e65a2d4c417e2a5f (diff) | |
download | libdrm-17a51b0b31c6e7f0d862fe30d3a3222d152c2966.tar.gz libdrm-17a51b0b31c6e7f0d862fe30d3a3222d152c2966.tar.bz2 libdrm-17a51b0b31c6e7f0d862fe30d3a3222d152c2966.zip |
nouveau: rework debugging so we can also dump into a file
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Diffstat (limited to 'nouveau')
-rw-r--r-- | nouveau/nouveau.c | 26 | ||||
-rw-r--r-- | nouveau/private.h | 7 |
2 files changed, 27 insertions, 6 deletions
diff --git a/nouveau/nouveau.c b/nouveau/nouveau.c index 80c62c58..9fa940a9 100644 --- a/nouveau/nouveau.c +++ b/nouveau/nouveau.c @@ -46,15 +46,33 @@ #include "nvif/ioctl.h" #include "nvif/unpack.h" +drm_private FILE *nouveau_out = NULL; drm_private uint32_t nouveau_debug = 0; static void -debug_init(char *args) +debug_init(void) { - if (args) { - int n = strtol(args, NULL, 0); + static bool once = false; + char *debug, *out; + + if (once) + return; + once = true; + + debug = getenv("NOUVEAU_LIBDRM_DEBUG"); + if (debug) { + int n = strtol(debug, NULL, 0); if (n >= 0) nouveau_debug = n; + + } + + nouveau_out = stderr; + out = getenv("NOUVEAU_LIBDRM_OUT"); + if (out) { + FILE *fout = fopen(out, "w"); + if (fout) + nouveau_out = fout; } } @@ -325,7 +343,7 @@ nouveau_drm_new(int fd, struct nouveau_drm **pdrm) struct nouveau_drm *drm; drmVersionPtr ver; - debug_init(getenv("NOUVEAU_LIBDRM_DEBUG")); + debug_init(); if (!(drm = calloc(1, sizeof(*drm)))) return -ENOMEM; diff --git a/nouveau/private.h b/nouveau/private.h index 13cec3cd..55fe57d8 100644 --- a/nouveau/private.h +++ b/nouveau/private.h @@ -1,6 +1,8 @@ #ifndef __NOUVEAU_LIBDRM_PRIVATE_H__ #define __NOUVEAU_LIBDRM_PRIVATE_H__ +#include <stdio.h> + #include <libdrm_macros.h> #include <xf86drm.h> #include <xf86atomic.h> @@ -10,12 +12,13 @@ #include "nouveau.h" drm_private extern uint32_t nouveau_debug; +drm_private extern FILE *nouveau_out; #define dbg_on(lvl) (nouveau_debug & (1 << lvl)) #define dbg(lvl, fmt, args...) do { \ if (dbg_on((lvl))) \ - fprintf(stderr, "nouveau: "fmt, ##args); \ + fprintf(nouveau_out, "nouveau: "fmt, ##args); \ } while(0) -#define err(fmt, args...) fprintf(stderr, "nouveau: "fmt, ##args) +#define err(fmt, args...) fprintf(nouveau_out, "nouveau: "fmt, ##args) struct nouveau_client_kref { struct drm_nouveau_gem_pushbuf_bo *kref; |