-- v3: vkd3d: Print the thread id in trace messages.
From: Conor McCarthy cmccarthy@codeweavers.com
--- libs/vkd3d-common/debug.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/libs/vkd3d-common/debug.c b/libs/vkd3d-common/debug.c index b363efbd..fde89f52 100644 --- a/libs/vkd3d-common/debug.c +++ b/libs/vkd3d-common/debug.c @@ -31,6 +31,7 @@ #include <stdlib.h> #include <stdbool.h> #include <string.h> +#include <unistd.h> #ifdef HAVE_PTHREAD_H #include <pthread.h> #endif @@ -105,7 +106,11 @@ void vkd3d_dbg_printf(enum vkd3d_dbg_level level, const char *function, const ch
assert(level < ARRAY_SIZE(debug_level_names));
- vkd3d_dbg_output("vkd3d:%s:%s ", debug_level_names[level], function); +#ifdef _WIN32 + vkd3d_dbg_output("vkd3d:%04lx:%s:%s ", GetCurrentThreadId(), debug_level_names[level], function); +#else + vkd3d_dbg_output("vkd3d:%04lx:%s:%s ", gettid(), debug_level_names[level], function); +#endif va_start(args, fmt); vkd3d_dbg_voutput(fmt, args); va_end(args);
Giovanni Mascellani (@giomasce) commented about libs/vkd3d-common/debug.c:
assert(level < ARRAY_SIZE(debug_level_names));
- vkd3d_dbg_output("vkd3d:%s:%s ", debug_level_names[level], function);
+#ifdef _WIN32
- vkd3d_dbg_output("vkd3d:%04lx:%s:%s ", GetCurrentThreadId(), debug_level_names[level], function);
+#else
- vkd3d_dbg_output("vkd3d:%04lx:%s:%s ", gettid(), debug_level_names[level], function);
The thread id is usually displayed as a decimal number in Unix environments, so I would do the same here. And I would not pad with zeros, because nowadays it can be 32 bit on Linux.
gettid() is not portable. That doesn't necessarily prevent us from using it, but it does mean we need to test whether it's available first.