Skip to content

Commit 570db83

Browse files
committed
Don't print a dash if thread name is not known
Normally `ThreadName()` should return `programname-PID/threadname-TID`, but if the thread name is not known it would return `programname-PID/-TID`. Change it to return `programname-PID/TID` instead.
1 parent 49a9637 commit 570db83

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/mp/util.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ std::string ThreadName(const char* exe_name)
5151
#endif // HAVE_PTHREAD_GETNAME_NP
5252

5353
std::ostringstream buffer;
54-
buffer << (exe_name ? exe_name : "") << "-" << getpid() << "/" << thread_name << "-";
54+
buffer << (exe_name ? exe_name : "") << "-" << getpid() << "/";
55+
56+
if (thread_name[0] != '\0') {
57+
buffer << thread_name << "-";
58+
}
5559

5660
// Prefer platform specific thread ids over the standard C++11 ones because
5761
// the former are shorter and are the same as what gdb prints "LWP ...".

0 commit comments

Comments
 (0)