Fix Linux Host::GetCurrentThreadID() to return real tid (not pthread_t).
This fixes threadname logging (--thread-name)
Add "-t" to TestLogging.py script to enable threadsafe and disable threadname logging
llvm-svn: 187599
diff --git a/lldb/source/Host/linux/Host.cpp b/lldb/source/Host/linux/Host.cpp
index c7120e2..0efc89a 100644
--- a/lldb/source/Host/linux/Host.cpp
+++ b/lldb/source/Host/linux/Host.cpp
@@ -451,18 +451,17 @@
std::string
Host::GetThreadName (lldb::pid_t pid, lldb::tid_t tid)
{
+ assert(pid != LLDB_INVALID_PROCESS_ID);
+ assert(tid != LLDB_INVALID_THREAD_ID);
+
// Read /proc/$TID/comm file.
lldb::DataBufferSP buf_sp = ReadProcPseudoFile (tid, "comm");
- if (buf_sp->GetByteSize())
- {
- const char *comm_str = (const char *)buf_sp->GetBytes();
- const char *cr_str = ::strchr(comm_str, '\n');
- size_t length = cr_str ? (cr_str - comm_str) : buf_sp->GetByteSize();
+ const char *comm_str = (const char *)buf_sp->GetBytes();
+ const char *cr_str = ::strchr(comm_str, '\n');
+ size_t length = cr_str ? (cr_str - comm_str) : strlen(comm_str);
- std::string thread_name(comm_str, length);
- return thread_name;
- }
- return std::string("");
+ std::string thread_name(comm_str, length);
+ return thread_name;
}
void