From 8e0135362e4da74e171ebb2515b1f472fc61ba35 Mon Sep 17 00:00:00 2001 From: Jehan Date: Fri, 25 Jan 2019 01:07:39 +0100 Subject: [PATCH] libgimpbase: display thread id of the calling thread as hexadecimal... ... on macOS. The debugger running on macOS is usually lldb and (from the reports we get) it looks like lldb displays the tid as hexadecimal on macOS (whereas lldb displays decimal tid on Linux! I know, it's confusing, yet consistent with crash report experience!). So let's just do the same, making it easy to quickly copy-search in order to look up the crashing thread (without having to convert from decimal to hexa). This is a bit of an approximation as I imagine we could have gdb on macOS or whatever edge case. Let's say it's good for the common case and still not an error otherwise (just a base conversion away). --- libgimpbase/gimputils.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libgimpbase/gimputils.c b/libgimpbase/gimputils.c index 8758a7ab0a..08d91e0afa 100644 --- a/libgimpbase/gimputils.c +++ b/libgimpbase/gimputils.c @@ -1324,7 +1324,12 @@ gimp_stack_trace_print (const gchar *prog_name, eintr_count = 0; if (! stack_printed) { -#if defined(G_OS_WIN32) || defined(SYS_gettid) || defined(HAVE_THR_SELF) +#if defined(PLATFORM_OSX) + if (stream) + g_fprintf (stream, + "\n# Stack traces obtained from PID %d - Thread 0x%lx #\n\n", + pid, tid); +#elif defined(G_OS_WIN32) || defined(SYS_gettid) || defined(HAVE_THR_SELF) if (stream) g_fprintf (stream, "\n# Stack traces obtained from PID %d - Thread %lu #\n\n", @@ -1333,7 +1338,11 @@ gimp_stack_trace_print (const gchar *prog_name, if (trace) { gtrace = g_string_new (NULL); -#if defined(G_OS_WIN32) || defined(SYS_gettid) || defined(HAVE_THR_SELF) +#if defined(PLATFORM_OSX) + g_string_printf (gtrace, + "\n# Stack traces obtained from PID %d - Thread 0x%lx #\n\n", + pid, tid); +#elif defined(G_OS_WIN32) || defined(SYS_gettid) || defined(HAVE_THR_SELF) g_string_printf (gtrace, "\n# Stack traces obtained from PID %d - Thread %lu #\n\n", pid, tid);