changeset 6352:288bfdf03d95

set thread names at system level too to make them visible in GDB
author Alain Mazy <am@orthanc.team>
date Fri, 24 Oct 2025 14:53:55 +0200
parents add962490217
children 6bd98dfa6bb8
files OrthancFramework/Sources/Logging.cpp
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancFramework/Sources/Logging.cpp	Fri Oct 24 14:26:52 2025 +0200
+++ b/OrthancFramework/Sources/Logging.cpp	Fri Oct 24 14:53:55 2025 +0200
@@ -658,6 +658,11 @@
       }
 
       threadNames_[id] = name;
+
+#if defined(__linux__)
+      // set the thread name at "system" level too -> required to have the thread names visible in GDB !
+      pthread_setname_np(pthread_self(), name.substr(0, 15).c_str());  // thread names are limited to 15 in Linux
+#endif              
     }
 
     void SetCurrentThreadName(const std::string& name)