ddebug: set thread name
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Tue, 26 Feb 2019 12:07:30 +0000 (13:07 +0100)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Thu, 25 Apr 2019 10:35:16 +0000 (12:35 +0200)
For better debuggability.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/auxiliary/driver_ddebug/dd_draw.c

index f5b9435611999281099e0800a174a42d223795d9..4eb0dd096f4e710b2db32edb72e545f8b4041f4a 100644 (file)
@@ -33,6 +33,7 @@
 #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"
@@ -1002,6 +1003,15 @@ dd_thread_main(void *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 (;;) {