diff options
Diffstat (limited to 'source/Core/Logging.cpp')
-rw-r--r-- | source/Core/Logging.cpp | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/source/Core/Logging.cpp b/source/Core/Logging.cpp index d08d833ee469..9eb4f6676a4d 100644 --- a/source/Core/Logging.cpp +++ b/source/Core/Logging.cpp @@ -11,30 +11,31 @@ // C Includes // C++ Includes +#include <cstring> #include <atomic> + // Other libraries and framework includes // Project includes #include "lldb/Interpreter/Args.h" #include "lldb/Core/Log.h" #include "lldb/Core/StreamFile.h" -#include <string.h> using namespace lldb; using namespace lldb_private; - // We want to avoid global constructors where code needs to be run so here we // 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 std::atomic<bool> g_log_enabled {false}; -static Log * g_log = NULL; +static Log * g_log = nullptr; + static Log * GetLog () { if (!g_log_enabled) - return NULL; + return nullptr; return g_log; } @@ -62,7 +63,7 @@ lldb_private::GetLogIfAllCategoriesSet (uint32_t mask) { uint32_t log_mask = log->GetMask().Get(); if ((log_mask & mask) != mask) - return NULL; + return nullptr; } return log; } @@ -84,7 +85,7 @@ void lldb_private::LogIfAnyCategoriesSet (uint32_t mask, const char *format, ...) { Log *log(GetLogIfAnyCategoriesSet (mask)); - if (log) + if (log != nullptr) { va_list args; va_start (args, format); @@ -97,9 +98,9 @@ Log * lldb_private::GetLogIfAnyCategoriesSet (uint32_t mask) { Log *log(GetLog ()); - if (log && mask && (mask & log->GetMask().Get())) + if (log != nullptr && mask && (mask & log->GetMask().Get())) return log; - return NULL; + return nullptr; } void @@ -107,13 +108,13 @@ lldb_private::DisableLog (const char **categories, Stream *feedback_strm) { Log *log(GetLog ()); - if (log) + if (log != nullptr) { uint32_t flag_bits = 0; - if (categories[0] != NULL) + if (categories[0] != nullptr) { flag_bits = log->GetMask().Get(); - for (size_t i = 0; categories[i] != NULL; ++i) + for (size_t i = 0; categories[i] != nullptr; ++i) { const char *arg = categories[i]; @@ -149,6 +150,7 @@ lldb_private::DisableLog (const char **categories, Stream *feedback_strm) else if (0 == ::strcasecmp(arg, "jit")) flag_bits &= ~LIBLLDB_LOG_JIT_LOADER; else if (0 == ::strcasecmp(arg, "language")) flag_bits &= ~LIBLLDB_LOG_LANGUAGE; else if (0 == ::strncasecmp(arg, "formatters", 10)) flag_bits &= ~LIBLLDB_LOG_DATAFORMATTERS; + else if (0 == ::strncasecmp(arg, "demangle", 8)) flag_bits &= ~LIBLLDB_LOG_DEMANGLE; else { feedback_strm->Printf ("error: unrecognized log category '%s'\n", arg); @@ -164,8 +166,6 @@ lldb_private::DisableLog (const char **categories, Stream *feedback_strm) g_log_enabled = false; } } - - return; } Log * @@ -174,7 +174,7 @@ lldb_private::EnableLog (StreamSP &log_stream_sp, uint32_t log_options, const ch // 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; - if (g_log) + if (g_log != nullptr) flag_bits = g_log->GetMask().Get(); else flag_bits = 0; @@ -182,15 +182,15 @@ lldb_private::EnableLog (StreamSP &log_stream_sp, uint32_t log_options, const ch // Now make a new log with this stream if one was provided if (log_stream_sp) { - if (g_log) + if (g_log != nullptr) g_log->SetStream(log_stream_sp); else g_log = new Log(log_stream_sp); } - if (g_log) + if (g_log != nullptr) { - for (size_t i=0; categories[i] != NULL; ++i) + for (size_t i = 0; categories[i] != nullptr; ++i) { const char *arg = categories[i]; @@ -226,6 +226,7 @@ lldb_private::EnableLog (StreamSP &log_stream_sp, uint32_t log_options, const ch else if (0 == ::strcasecmp(arg, "jit")) flag_bits |= LIBLLDB_LOG_JIT_LOADER; else if (0 == ::strcasecmp(arg, "language")) flag_bits |= LIBLLDB_LOG_LANGUAGE; else if (0 == ::strncasecmp(arg, "formatters", 10)) flag_bits |= LIBLLDB_LOG_DATAFORMATTERS; + else if (0 == ::strncasecmp(arg, "demangle", 8)) flag_bits |= LIBLLDB_LOG_DEMANGLE; else { feedback_strm->Printf("error: unrecognized log category '%s'\n", arg); @@ -241,7 +242,6 @@ lldb_private::EnableLog (StreamSP &log_stream_sp, uint32_t log_options, const ch return g_log; } - void lldb_private::ListLogCategories (Stream *strm) { @@ -253,6 +253,7 @@ lldb_private::ListLogCategories (Stream *strm) " communication - log communication activities\n" " connection - log connection details\n" " default - enable the default set of logging categories for liblldb\n" + " demangle - log mangled names to catch demangler crashes\n" " dyld - log shared library related activities\n" " events - log broadcaster, listener and event queue activities\n" " expr - log expressions\n" |