diff options
Diffstat (limited to 'lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp')
-rw-r--r-- | lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp index ff3c46ece3f..53b08d53c24 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp @@ -22,22 +22,25 @@ using namespace lldb_private; // control access to our static g_log_sp by hiding it in a singleton function // that will construct the static g_lob_sp the first time this function is // called. -static LogSP & +static bool g_log_enabled = false; +static Log * g_log = NULL; +static Log * GetLog () { - static LogSP g_log_sp; - return g_log_sp; + if (!g_log_enabled) + return NULL; + return g_log; } -LogSP +Log * ProcessKDPLog::GetLogIfAllCategoriesSet (uint32_t mask) { - LogSP log(GetLog ()); + Log *log(GetLog ()); if (log && mask) { uint32_t log_mask = log->GetMask().Get(); if ((log_mask & mask) != mask) - return LogSP(); + return NULL; } return log; } @@ -45,7 +48,7 @@ ProcessKDPLog::GetLogIfAllCategoriesSet (uint32_t mask) void ProcessKDPLog::DisableLog (const char **categories, Stream *feedback_strm) { - LogSP log (GetLog ()); + Log *log (GetLog ()); if (log) { uint32_t flag_bits = 0; @@ -81,33 +84,33 @@ ProcessKDPLog::DisableLog (const char **categories, Stream *feedback_strm) } } + log->GetMask().Reset (flag_bits); if (flag_bits == 0) - GetLog ().reset(); - else - log->GetMask().Reset (flag_bits); + g_log_enabled = false; } return; } -LogSP +Log * ProcessKDPLog::EnableLog (StreamSP &log_stream_sp, uint32_t log_options, const char **categories, Stream *feedback_strm) { // Try see if there already is a log - that way we can reuse its settings. // We could reuse the log in toto, but we don't know that the stream is the same. uint32_t flag_bits = 0; - LogSP log(GetLog ()); - if (log) - flag_bits = log->GetMask().Get(); + if (g_log) + flag_bits = g_log->GetMask().Get(); // Now make a new log with this stream if one was provided if (log_stream_sp) { - log.reset (new Log(log_stream_sp)); - GetLog () = log; + if (g_log) + g_log->SetStream(log_stream_sp); + else + g_log = new Log(log_stream_sp); } - if (log) + if (g_log) { bool got_unknown_category = false; for (size_t i=0; categories[i] != NULL; ++i) @@ -140,10 +143,11 @@ ProcessKDPLog::EnableLog (StreamSP &log_stream_sp, uint32_t log_options, const c } if (flag_bits == 0) flag_bits = KDP_LOG_DEFAULT; - log->GetMask().Reset(flag_bits); - log->GetOptions().Reset(log_options); + g_log->GetMask().Reset(flag_bits); + g_log->GetOptions().Reset(log_options); } - return log; + g_log_enabled = true; + return g_log; } void @@ -170,7 +174,7 @@ ProcessKDPLog::ListLogCategories (Stream *strm) void ProcessKDPLog::LogIf (uint32_t mask, const char *format, ...) { - LogSP log (ProcessKDPLog::GetLogIfAllCategoriesSet (mask)); + Log *log (ProcessKDPLog::GetLogIfAllCategoriesSet (mask)); if (log) { va_list args; |