Fixed a case where the result of std::string's c_str() method was being called on a local variable and returned as a const char * incorrectly. We used to cache the thread names for threads in the current host process, but we shoudn't be caching that as the names can change over time, so now a std::string is returned from Host::GetThreadName().
llvm-svn: 176217
diff --git a/lldb/source/Core/Log.cpp b/lldb/source/Core/Log.cpp
index f8e422e..3743631 100644
--- a/lldb/source/Core/Log.cpp
+++ b/lldb/source/Core/Log.cpp
@@ -112,10 +112,9 @@
// Add the process and thread if requested
if (m_options.Test (LLDB_LOG_OPTION_PREPEND_THREAD_NAME))
{
- const char *thread_name_str = Host::GetThreadName (getpid(), Host::GetCurrentThreadID());
- if (thread_name_str)
- header.Printf ("%s ", thread_name_str);
-
+ std::string thread_name (Host::GetThreadName (getpid(), Host::GetCurrentThreadID()));
+ if (!thread_name.empty())
+ header.Printf ("%s ", thread_name.c_str());
}
header.PrintfVarArg (format, args);