[Mesa-dev] [PATCH 3/8] ddebug: set thread name

Nicolai Hähnle nhaehnle at gmail.com
Wed Apr 24 13:14:31 UTC 2019


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

For better debuggability.
---
 src/gallium/auxiliary/driver_ddebug/dd_draw.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/gallium/auxiliary/driver_ddebug/dd_draw.c b/src/gallium/auxiliary/driver_ddebug/dd_draw.c
index f5b94356119..4eb0dd096f4 100644
--- a/src/gallium/auxiliary/driver_ddebug/dd_draw.c
+++ b/src/gallium/auxiliary/driver_ddebug/dd_draw.c
@@ -26,20 +26,21 @@
  **************************************************************************/
 
 #include "dd_pipe.h"
 
 #include "util/u_dump.h"
 #include "util/u_format.h"
 #include "util/u_framebuffer.h"
 #include "util/u_helpers.h"
 #include "util/u_inlines.h"
 #include "util/u_memory.h"
+#include "util/u_process.h"
 #include "tgsi/tgsi_parse.h"
 #include "tgsi/tgsi_scan.h"
 #include "util/os_time.h"
 #include <inttypes.h>
 #include "pipe/p_config.h"
 
 
 static void
 dd_write_header(FILE *f, struct pipe_screen *screen, unsigned apitrace_call_number)
 {
@@ -995,20 +996,29 @@ dd_report_hang(struct dd_context *dctx)
    dd_kill_process();
 }
 
 int
 dd_thread_main(void *input)
 {
    struct dd_context *dctx = (struct dd_context *)input;
    struct dd_screen *dscreen = dd_screen(dctx->base.screen);
    struct pipe_screen *screen = dscreen->screen;
 
+   const char *process_name = util_get_process_name();
+   if (process_name) {
+      char threadname[16];
+      util_snprintf(threadname, sizeof(threadname), "%.*s:ddbg",
+                    (int)MIN2(strlen(process_name), sizeof(threadname) - 6),
+                    process_name);
+      u_thread_setname(threadname);
+   }
+
    mtx_lock(&dctx->mutex);
 
    for (;;) {
       struct list_head records;
       list_replace(&dctx->records, &records);
       list_inithead(&dctx->records);
       dctx->num_records = 0;
 
       if (dctx->api_stalled)
          cnd_signal(&dctx->cond);
-- 
2.20.1



More information about the mesa-dev mailing list