summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core/Log.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Core/Log.cpp')
-rw-r--r--lldb/source/Core/Log.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/lldb/source/Core/Log.cpp b/lldb/source/Core/Log.cpp
index d2de299b648..692d89e1203 100644
--- a/lldb/source/Core/Log.cpp
+++ b/lldb/source/Core/Log.cpp
@@ -110,10 +110,6 @@ Log::VAPrintf(const char *format, va_list args)
{
static uint32_t g_sequence_id = 0;
StreamString header;
- // Enabling the thread safe logging actually deadlocks right now.
- // Need to fix this at some point.
-// static Mutex g_LogThreadedMutex(Mutex::eMutexTypeRecursive);
-// Mutex::Locker locker (g_LogThreadedMutex);
// Add a sequence ID if requested
if (m_options.Test (LLDB_LOG_OPTION_PREPEND_SEQUENCE))
@@ -140,16 +136,28 @@ Log::VAPrintf(const char *format, va_list args)
}
header.PrintfVarArg (format, args);
- stream_sp->Printf("%s\n", header.GetData());
-
+ header.PutCString("\n");
+
if (m_options.Test(LLDB_LOG_OPTION_BACKTRACE))
{
std::string back_trace;
llvm::raw_string_ostream stream(back_trace);
llvm::sys::PrintStackTrace(stream);
- stream_sp->PutCString(back_trace.c_str());
+ header.PutCString(back_trace.c_str());
+ }
+
+ if (m_options.Test(LLDB_LOG_OPTION_THREADSAFE))
+ {
+ static Mutex g_LogThreadedMutex(Mutex::eMutexTypeRecursive);
+ Mutex::Locker locker(g_LogThreadedMutex);
+ stream_sp->PutCString(header.GetString().c_str());
+ stream_sp->Flush();
+ }
+ else
+ {
+ stream_sp->PutCString(header.GetString().c_str());
+ stream_sp->Flush();
}
- stream_sp->Flush();
}
}
OpenPOWER on IntegriCloud