diff options
Diffstat (limited to 'source/Core/Log.cpp')
-rw-r--r-- | source/Core/Log.cpp | 55 |
1 files changed, 19 insertions, 36 deletions
diff --git a/source/Core/Log.cpp b/source/Core/Log.cpp index 8d415bdc0e77..a292df3ed525 100644 --- a/source/Core/Log.cpp +++ b/source/Core/Log.cpp @@ -8,30 +8,30 @@ //===----------------------------------------------------------------------===// // C Includes -#include <stdio.h> -#include <stdarg.h> -#include <stdlib.h> - // C++ Includes +#include <cstdarg> +#include <cstdio> +#include <cstdlib> #include <map> +#include <mutex> #include <string> // Other libraries and framework includes +#include "llvm/ADT/SmallString.h" +#include "llvm/Support/raw_ostream.h" +#include "llvm/Support/Signals.h" + // Project includes #include "lldb/Core/Log.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/StreamFile.h" #include "lldb/Core/StreamString.h" #include "lldb/Host/Host.h" -#include "lldb/Host/Mutex.h" #include "lldb/Host/ThisThread.h" #include "lldb/Host/TimeValue.h" #include "lldb/Interpreter/Args.h" #include "lldb/Utility/NameMatches.h" -#include "llvm/ADT/SmallString.h" -#include "llvm/Support/raw_ostream.h" -#include "llvm/Support/Signals.h" using namespace lldb; using namespace lldb_private; @@ -49,9 +49,7 @@ Log::Log (const StreamSP &stream_sp) : { } -Log::~Log () -{ -} +Log::~Log() = default; Flags & Log::GetOptions() @@ -149,8 +147,8 @@ Log::VAPrintf(const char *format, va_list args) if (m_options.Test(LLDB_LOG_OPTION_THREADSAFE)) { - static Mutex g_LogThreadedMutex(Mutex::eMutexTypeRecursive); - Mutex::Locker locker(g_LogThreadedMutex); + static std::recursive_mutex g_LogThreadedMutex; + std::lock_guard<std::recursive_mutex> guard(g_LogThreadedMutex); stream_sp->PutCString(header.GetString().c_str()); stream_sp->Flush(); } @@ -178,7 +176,6 @@ Log::Debug(const char *format, ...) va_end(args); } - //---------------------------------------------------------------------- // Print debug strings if and only if the global debug option is set to // a non-zero value. @@ -195,7 +192,6 @@ Log::DebugVerbose(const char *format, ...) va_end(args); } - //---------------------------------------------------------------------- // Log only if all of the bits are set //---------------------------------------------------------------------- @@ -223,7 +219,6 @@ Log::Error(const char *format, ...) va_end(args); } - void Log::VAError(const char *format, va_list args) { @@ -237,7 +232,6 @@ Log::VAError(const char *format, va_list args) free(arg_msg); } - //---------------------------------------------------------------------- // Printing of errors that ARE fatal. Exit with ERR exit code // immediately. @@ -259,7 +253,6 @@ Log::FatalError(int err, const char *format, ...) ::exit(err); } - //---------------------------------------------------------------------- // Printing of warnings that are not fatal only if verbose mode is // enabled. @@ -298,6 +291,7 @@ Log::WarningVerbose(const char *format, ...) Printf("warning: %s", arg_msg); free(arg_msg); } + //---------------------------------------------------------------------- // Printing of warnings that are not fatal. //---------------------------------------------------------------------- @@ -323,7 +317,6 @@ typedef CallbackMap::iterator CallbackMapIter; typedef std::map <ConstString, LogChannelSP> LogChannelMap; typedef LogChannelMap::iterator LogChannelMapIter; - // Surround our callback map with a singleton function so we don't have any // global initializers. static CallbackMap & @@ -401,13 +394,10 @@ Log::EnableLogChannel(lldb::StreamSP &log_stream_sp, } void -Log::EnableAllLogChannels -( - StreamSP &log_stream_sp, - uint32_t log_options, - const char **categories, - Stream *feedback_strm -) +Log::EnableAllLogChannels(StreamSP &log_stream_sp, + uint32_t log_options, + const char **categories, + Stream *feedback_strm) { CallbackMap &callback_map = GetCallbackMap (); CallbackMapIter pos, end = callback_map.end(); @@ -421,7 +411,6 @@ Log::EnableAllLogChannels { channel_pos->second->Enable (log_stream_sp, log_options, feedback_strm, categories); } - } void @@ -441,7 +430,6 @@ Log::AutoCompleteChannelName (const char *channel_name, StringList &matches) } else matches.AppendString(pos_channel_name); - } } @@ -471,7 +459,7 @@ Log::Initialize() void Log::Terminate () { - DisableAllLogChannels (NULL); + DisableAllLogChannels(nullptr); } void @@ -492,7 +480,7 @@ Log::ListAllLogChannels (Stream *strm) uint32_t idx = 0; const char *name; - for (idx = 0; (name = PluginManager::GetLogChannelCreateNameAtIndex (idx)) != NULL; ++idx) + for (idx = 0; (name = PluginManager::GetLogChannelCreateNameAtIndex (idx)) != nullptr; ++idx) { LogChannelSP log_channel_sp(LogChannel::FindPlugin (name)); if (log_channel_sp) @@ -529,7 +517,6 @@ Log::GetDebug() const return false; } - LogChannelSP LogChannel::FindPlugin (const char *plugin_name) { @@ -566,8 +553,4 @@ LogChannel::LogChannel () : { } -LogChannel::~LogChannel () -{ -} - - +LogChannel::~LogChannel() = default; |