diff options
author | Ralf Habacker <ralf.habacker@freenet.de> | 2016-05-10 16:51:25 +0200 |
---|---|---|
committer | Ralf Habacker <ralf.habacker@freenet.de> | 2016-05-13 15:28:56 +0200 |
commit | dc71d0401022557c5169d10d2ec2de56c875dac0 (patch) | |
tree | d32e21b2b61228bd75176d1211d661d9f912b14d /dbus/dbus-sysdeps-pthread.c | |
parent | 9ab7fe33f8af43dc276f34a9cfd8f1048bd625be (diff) | |
download | dbus-dc71d0401022557c5169d10d2ec2de56c875dac0.tar.gz |
Display thread id in _dbus_verbose to be able to see threading issues.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=95191
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Diffstat (limited to 'dbus/dbus-sysdeps-pthread.c')
-rw-r--r-- | dbus/dbus-sysdeps-pthread.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/dbus/dbus-sysdeps-pthread.c b/dbus/dbus-sysdeps-pthread.c index 1300ec35..bc0b2c35 100644 --- a/dbus/dbus-sysdeps-pthread.c +++ b/dbus/dbus-sysdeps-pthread.c @@ -28,6 +28,7 @@ #include <sys/time.h> #include <pthread.h> +#include <stdio.h> #include <string.h> #ifdef HAVE_ERRNO_H @@ -300,3 +301,20 @@ _dbus_threads_unlock_platform_specific (void) { pthread_mutex_unlock (&init_mutex); } + +#ifdef DBUS_ENABLE_VERBOSE_MODE +/* + * If we can identify the current process and/or thread, print them to stderr followed by a colon. + */ +void +_dbus_print_thread (void) +{ +#ifdef __linux__ + /* we know a pthread_t is numeric on Linux */ + fprintf (stderr, "%lu: 0x%lx: ", _dbus_pid_for_log (), (unsigned long) pthread_self ()); +#else + /* in principle pthread_t isn't required to be printable */ + fprintf (stderr, "%lu: ", _dbus_pid_for_log ()); +#endif +} +#endif |