Skip to content

Commit 097bce2

Browse files
committed
Merge #24: Don't print a dash if thread name is not known
570db83 Don't print a dash if thread name is not known (Vasil Dimov) Pull request description: 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. Top commit has no ACKs. Tree-SHA512: 06c5b85c4f8edc800e37b54c6153c6eb63b34508b93dd75c8e5f06186bda4a4e2b69504b0ec478772db20067de311bc5abc777ef7980c87c228c4ee049d7310a
2 parents a440eda + 570db83 commit 097bce2

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)