From e19cd3bdf16b80faef2af785f38787795cbc38e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Sat, 12 Dec 2015 12:16:49 -0800 Subject: [PATCH] Updated Remotery. --- 3rdparty/remotery/lib/Remotery.c | 15 ++++++++++++++- 3rdparty/remotery/lib/Remotery.h | 5 +++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/3rdparty/remotery/lib/Remotery.c b/3rdparty/remotery/lib/Remotery.c index eebd845f..f77df720 100644 --- a/3rdparty/remotery/lib/Remotery.c +++ b/3rdparty/remotery/lib/Remotery.c @@ -106,6 +106,7 @@ static rmtBool g_SettingsInitialized = RMT_FALSE; #ifdef RMT_PLATFORM_LINUX #include + #include #endif #if defined(RMT_PLATFORM_POSIX) @@ -3664,10 +3665,14 @@ static rmtError ThreadSampler_Constructor(ThreadSampler* thread_sampler) thread_sampler->sample_trees[i] = NULL; thread_sampler->next = NULL; - // Set the initial name to Thread0 etc. + // Set the initial name to Thread0 etc. or use the existing Linux name. thread_sampler->name[0] = 0; + #if defined(RMT_PLATFORM_LINUX) && RMT_USE_POSIX_THREADNAMES + prctl(PR_GET_NAME,thread_sampler->name,0,0,0); + #else strncat_s(thread_sampler->name, sizeof(thread_sampler->name), "Thread", 6); itoahex_s(thread_sampler->name + 6, sizeof(thread_sampler->name) - 6, AtomicAdd(&countThreads, 1)); + #endif // Create the CPU sample tree only - the rest are created on-demand as they need // extra context information to function correctly. @@ -4369,6 +4374,14 @@ static void SetDebuggerThreadName(const char* name) #else RMT_UNREFERENCED_PARAMETER(name); #endif + + #ifdef RMT_PLATFORM_LINUX + // pthread_setname_np is a non-standard GNU extension. + char name_clamp[16]; + name_clamp[0] = 0; + strncat_s(name_clamp, sizeof(name_clamp), name, 15); + prctl(PR_SET_NAME,name_clamp,0,0,0); + #endif } diff --git a/3rdparty/remotery/lib/Remotery.h b/3rdparty/remotery/lib/Remotery.h index 803a596d..20836f68 100644 --- a/3rdparty/remotery/lib/Remotery.h +++ b/3rdparty/remotery/lib/Remotery.h @@ -67,6 +67,11 @@ documented just below this comment. #define RMT_USE_OPENGL 0 #endif +// Initially use POSIX thread names to name threads instead of Thread0, 1, ... +#ifndef RMT_USE_POSIX_THREADNAMES +#define RMT_USE_POSIX_THREADNAMES 0 +#endif + /* ------------------------------------------------------------------------------------------------------------------------