From 74fc8fcd1841069b351f5943d85ab81fffde32bd Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Tue, 10 May 2016 16:51:25 +0200 Subject: [PATCH] Display thread id in _dbus_verbose to be able to see thread issues. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=95191 --- dbus/dbus-internals.c | 4 ++-- dbus/dbus-sysdeps-unix.c | 5 +++++ dbus/dbus-sysdeps-win.c | 5 +++++ dbus/dbus-sysdeps.h | 2 ++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/dbus/dbus-internals.c b/dbus/dbus-internals.c index f49f8fa..134aee2 100644 --- a/dbus/dbus-internals.c +++ b/dbus/dbus-internals.c @@ -407,9 +407,9 @@ _dbus_verbose_real ( if (need_pid) { #if PTHREAD_IN_VERBOSE - fprintf (stderr, "%lu: 0x%lx: ", _dbus_pid_for_log (), pthread_self ()); + fprintf (stderr, "%lu: 0x%lx: ", _dbus_pid_for_log (), _dbus_current_thread_id ()); #else - fprintf (stderr, "%lu: ", _dbus_pid_for_log ()); + fprintf (stderr, "%lu:0x%04lx: ", _dbus_pid_for_log (), _dbus_current_thread_id ()); #endif } #endif diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index ce8cbf7..1b6eef2 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -4431,4 +4431,9 @@ _dbus_restore_socket_errno (int saved_errno) errno = saved_errno; } +unsigned long _dbus_current_thread_id () +{ + return pthread_self(); +} + /* tests in dbus-sysdeps-util.c */ diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 1a35a89..1b139f0 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -3634,6 +3634,11 @@ _dbus_restore_socket_errno (int saved_errno) _dbus_win_set_errno (saved_errno); } +unsigned long _dbus_current_thread_id() +{ + return GetCurrentThreadId(); +} + /** @} end of sysdeps-win */ /* tests in dbus-sysdeps-util.c */ diff --git a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h index c832b3f..29356e1 100644 --- a/dbus/dbus-sysdeps.h +++ b/dbus/dbus-sysdeps.h @@ -492,6 +492,8 @@ DBUS_PRIVATE_EXPORT int _dbus_printf_string_upper_bound (const char *format, va_list args); +DBUS_PRIVATE_EXPORT +unsigned long _dbus_current_thread_id(); /** * Portable struct with stat() results -- 1.8.4.5