From 228063cd21c4e13aba0ef7a4522b1f32e3116c18 Mon Sep 17 00:00:00 2001 From: Jim Ingham Date: Tue, 21 Feb 2012 02:23:08 +0000 Subject: [PATCH] Add a logging mode that takes a callback and flush'es to that callback. Also add SB API's to set this callback, and to enable the log channels. llvm-svn: 151018 --- lldb/include/lldb/API/SBDebugger.h | 6 ++ lldb/include/lldb/Core/Debugger.h | 13 ++- lldb/include/lldb/Core/Log.h | 11 +-- lldb/include/lldb/lldb-private-log.h | 4 +- lldb/include/lldb/lldb-types.h | 2 +- lldb/lldb.xcodeproj/project.pbxproj | 8 ++ lldb/scripts/Python/interface/SBDebugger.i | 6 ++ lldb/source/API/SBDebugger.cpp | 24 +++++- lldb/source/Commands/CommandObjectLog.cpp | 64 +++------------ lldb/source/Core/Debugger.cpp | 79 ++++++++++++++++++- lldb/source/Core/Log.cpp | 13 +-- .../Process/MacOSX-Kernel/ProcessKDPLog.cpp | 16 ++-- .../Process/MacOSX-Kernel/ProcessKDPLog.h | 4 +- .../gdb-remote/ProcessGDBRemoteLog.cpp | 16 ++-- .../Process/gdb-remote/ProcessGDBRemoteLog.h | 4 +- .../SymbolFile/DWARF/LogChannelDWARF.cpp | 14 ++-- .../SymbolFile/DWARF/LogChannelDWARF.h | 4 +- lldb/source/lldb-log.cpp | 16 ++-- lldb/tools/lldb-platform/lldb-platform.cpp | 2 +- 19 files changed, 190 insertions(+), 116 deletions(-) diff --git a/lldb/include/lldb/API/SBDebugger.h b/lldb/include/lldb/API/SBDebugger.h index 34ef7fb1fc9f..cf9dc59ec7cb 100644 --- a/lldb/include/lldb/API/SBDebugger.h +++ b/lldb/include/lldb/API/SBDebugger.h @@ -32,6 +32,9 @@ public: static lldb::SBDebugger Create(bool source_init_files); + static lldb::SBDebugger + Create(bool source_init_files, lldb::LogOutputCallback callback, void *baton); + static void Destroy (lldb::SBDebugger &debugger); @@ -180,6 +183,9 @@ public: static bool StateIsStoppedState (lldb::StateType state); + + bool + EnableLog (const char *channel, const char **categories); void DispatchInput (void *baton, const void *data, size_t data_len); diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index 8997d98bf3c1..417a6925135b 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -289,7 +289,7 @@ public: GetSettingsController (); static lldb::DebuggerSP - CreateInstance (); + CreateInstance (lldb::LogOutputCallback log_callback = NULL, void *baton = NULL); static lldb::TargetSP FindTargetWithProcessID (lldb::pid_t pid); @@ -480,9 +480,15 @@ public: void SetCloseInputOnEOF (bool b); + + bool + EnableLog (const char *channel, const char **categories, const char *log_file, uint32_t log_options, Stream &error_stream); protected: + void + SetLoggingCallback (lldb::LogOutputCallback log_callback, void *baton); + static void DispatchInputCallback (void *baton, const void *bytes, size_t bytes_len); @@ -521,12 +527,15 @@ protected: InputReaderStack m_input_reader_stack; std::string m_input_reader_data; + typedef std::map LogStreamMap; + LogStreamMap m_log_streams; + lldb::StreamSP m_log_callback_stream_sp; private: // Use Debugger::CreateInstance() to get a shared pointer to a new // debugger object - Debugger (); + Debugger (lldb::LogOutputCallback m_log_callback, void *baton); DISALLOW_COPY_AND_ASSIGN (Debugger); diff --git a/lldb/include/lldb/Core/Log.h b/lldb/include/lldb/Core/Log.h index d34fa85ce0bb..1f808874b7ef 100644 --- a/lldb/include/lldb/Core/Log.h +++ b/lldb/include/lldb/Core/Log.h @@ -59,10 +59,10 @@ public: //------------------------------------------------------------------ // Callback definitions for abstracted plug-in log access. //------------------------------------------------------------------ - typedef void (*DisableCallback) (Args &args, Stream *feedback_strm); + typedef void (*DisableCallback) (const char **categories, Stream *feedback_strm); typedef lldb::LogSP (*EnableCallback) (lldb::StreamSP &log_stream_sp, uint32_t log_options, - Args &args, + const char **categories, Stream *feedback_strm); typedef void (*ListCategoriesCallback) (Stream *strm); @@ -91,7 +91,7 @@ public: static void EnableAllLogChannels (lldb::StreamSP &log_stream_sp, uint32_t log_options, - Args &args, + const char **categories, Stream *feedback_strm); static void @@ -203,14 +203,15 @@ public: static lldb::LogChannelSP FindPlugin (const char *plugin_name); + // categories is a an array of chars that ends with a NULL element. virtual void - Disable (Args &args, Stream *feedback_strm) = 0; + Disable (const char **categories, Stream *feedback_strm) = 0; virtual bool Enable (lldb::StreamSP &log_stream_sp, uint32_t log_options, Stream *feedback_strm, // Feedback stream for argument errors etc - const Args &categories) = 0;// The categories to enable within this logging stream, if empty, enable default set + const char **categories) = 0;// The categories to enable within this logging stream, if empty, enable default set virtual void ListCategories (Stream *strm) = 0; diff --git a/lldb/include/lldb/lldb-private-log.h b/lldb/include/lldb/lldb-private-log.h index 41bbf7a16b4d..fe6aacbb2c84 100644 --- a/lldb/include/lldb/lldb-private-log.h +++ b/lldb/include/lldb/lldb-private-log.h @@ -75,10 +75,10 @@ bool IsLogVerbose (); void -DisableLog (Args &args, Stream *feedback_strm); +DisableLog (const char **categories, Stream *feedback_strm); lldb::LogSP -EnableLog (lldb::StreamSP &log_stream_sp, uint32_t log_options, Args &args, Stream *feedback_strm); +EnableLog (lldb::StreamSP &log_stream_sp, uint32_t log_options, const char **categories, Stream *feedback_strm); void ListLogCategories (Stream *strm); diff --git a/lldb/include/lldb/lldb-types.h b/lldb/include/lldb/lldb-types.h index fd96feb1a461..20f9ae9e8a40 100644 --- a/lldb/include/lldb/lldb-types.h +++ b/lldb/include/lldb/lldb-types.h @@ -74,7 +74,7 @@ namespace lldb { // { // typedef lldb_private::IntrusiveSharingPtr<_Tp> Type; // }; - + typedef void (*LogOutputCallback) (const char *, void *baton); } // namespace lldb #if defined(__MINGW32__) diff --git a/lldb/lldb.xcodeproj/project.pbxproj b/lldb/lldb.xcodeproj/project.pbxproj index 8bfc61ecf561..bd1c32be2426 100644 --- a/lldb/lldb.xcodeproj/project.pbxproj +++ b/lldb/lldb.xcodeproj/project.pbxproj @@ -394,6 +394,8 @@ 49C8507C1384A786007DB519 /* ProcessDataAllocator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49C850781384A0CA007DB519 /* ProcessDataAllocator.cpp */; }; 49D8FB3913B5598F00411094 /* ClangASTImporter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49D8FB3513B558DE00411094 /* ClangASTImporter.cpp */; }; 49DA65031485C92A005FF180 /* AppleObjCSymbolVendor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49DA65021485C92A005FF180 /* AppleObjCSymbolVendor.cpp */; }; + 4C6649A014EEE7F100B0316F /* StreamCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C66499F14EEE7F100B0316F /* StreamCallback.h */; }; + 4C6649A314EEE81000B0316F /* StreamCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C6649A214EEE81000B0316F /* StreamCallback.cpp */; }; 4CAA56131422D96A001FFA01 /* BreakpointResolverFileRegex.h in Headers */ = {isa = PBXBuildFile; fileRef = 4CAA56121422D96A001FFA01 /* BreakpointResolverFileRegex.h */; }; 4CAA56151422D986001FFA01 /* BreakpointResolverFileRegex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CAA56141422D986001FFA01 /* BreakpointResolverFileRegex.cpp */; }; 4CABA9E0134A8BCD00539BDD /* ValueObjectMemory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CABA9DF134A8BCD00539BDD /* ValueObjectMemory.cpp */; }; @@ -1216,6 +1218,8 @@ 4C5DBBC611E3FEC60035160F /* CommandObjectCommands.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectCommands.cpp; path = source/Commands/CommandObjectCommands.cpp; sourceTree = ""; }; 4C5DBBC711E3FEC60035160F /* CommandObjectCommands.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectCommands.h; path = source/Commands/CommandObjectCommands.h; sourceTree = ""; }; 4C626533130F1B0A00C889F6 /* StreamTee.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StreamTee.h; path = include/lldb/Core/StreamTee.h; sourceTree = ""; }; + 4C66499F14EEE7F100B0316F /* StreamCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StreamCallback.h; path = include/lldb/Core/StreamCallback.h; sourceTree = ""; }; + 4C6649A214EEE81000B0316F /* StreamCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StreamCallback.cpp; path = source/Core/StreamCallback.cpp; sourceTree = ""; }; 4C74CB6212288704006A8171 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = ""; }; 4C7CF7E31295E10E00B4FBB5 /* ThreadPlanCallUserExpression.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadPlanCallUserExpression.h; path = include/lldb/Target/ThreadPlanCallUserExpression.h; sourceTree = ""; }; 4C7CF7E51295E12B00B4FBB5 /* ThreadPlanCallUserExpression.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadPlanCallUserExpression.cpp; path = source/Target/ThreadPlanCallUserExpression.cpp; sourceTree = ""; }; @@ -2209,6 +2213,8 @@ 9A4F35111368A54100823F52 /* StreamAsynchronousIO.h */, 9A4F350F1368A51A00823F52 /* StreamAsynchronousIO.cpp */, 2623096E13D0EFFB006381D9 /* StreamBuffer.h */, + 4C66499F14EEE7F100B0316F /* StreamCallback.h */, + 4C6649A214EEE81000B0316F /* StreamCallback.cpp */, 26BC7D7A10F1B77400F91463 /* StreamFile.h */, 26BC7E9210F1B85900F91463 /* StreamFile.cpp */, 26BC7D7B10F1B77400F91463 /* StreamString.h */, @@ -2952,6 +2958,7 @@ files = ( 26A527C214E24F5F00F3A14A /* ProcessMachCore.h in Headers */, 26A527C414E24F5F00F3A14A /* ThreadMachCore.h in Headers */, + 4C6649A014EEE7F100B0316F /* StreamCallback.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3619,6 +3626,7 @@ 4966DCC4148978A10028481B /* ClangExternalASTSourceCommon.cpp in Sources */, 26A527C114E24F5F00F3A14A /* ProcessMachCore.cpp in Sources */, 26A527C314E24F5F00F3A14A /* ThreadMachCore.cpp in Sources */, + 4C6649A314EEE81000B0316F /* StreamCallback.cpp in Sources */, B299580B14F2FA1400050A04 /* DisassemblerLLVMC.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/lldb/scripts/Python/interface/SBDebugger.i b/lldb/scripts/Python/interface/SBDebugger.i index 5048a83d0ec8..465c856f3930 100644 --- a/lldb/scripts/Python/interface/SBDebugger.i +++ b/lldb/scripts/Python/interface/SBDebugger.i @@ -119,6 +119,9 @@ public: static lldb::SBDebugger Create(); + static lldb::SBDebugger + Create(bool source_init_files); + static void Destroy (lldb::SBDebugger &debugger); @@ -262,6 +265,9 @@ public: static bool StateIsStoppedState (lldb::StateType state); + bool + EnableLog (const char *channel, const char ** types); + void DispatchInput (void *baton, const void *data, size_t data_len); diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index f98ca35f813f..8150cb04b933 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -81,16 +81,23 @@ SBDebugger::Clear () SBDebugger SBDebugger::Create() { - return SBDebugger::Create(false); + return SBDebugger::Create(false, NULL, NULL); } SBDebugger SBDebugger::Create(bool source_init_files) +{ + return SBDebugger::Create (source_init_files, NULL, NULL); +} + +SBDebugger +SBDebugger::Create(bool source_init_files, lldb::LogOutputCallback callback, void *baton) + { LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBDebugger debugger; - debugger.reset(Debugger::CreateInstance()); + debugger.reset(Debugger::CreateInstance(callback, baton)); if (log) { @@ -1200,3 +1207,16 @@ SBDebugger::GetSyntheticForType (SBTypeNameSpecifier type_name) return synth_chosen; } +bool +SBDebugger::EnableLog (const char *channel, const char **categories) +{ + if (m_opaque_sp) + { + uint32_t log_options = LLDB_LOG_OPTION_PREPEND_TIMESTAMP | LLDB_LOG_OPTION_PREPEND_THREAD_NAME; + StreamString errors; + return m_opaque_sp->EnableLog (channel, categories, NULL, log_options, errors); + + } + else + return false; +} diff --git a/lldb/source/Commands/CommandObjectLog.cpp b/lldb/source/Commands/CommandObjectLog.cpp index 8a1688e7052c..611c76b961c8 100644 --- a/lldb/source/Commands/CommandObjectLog.cpp +++ b/lldb/source/Commands/CommandObjectLog.cpp @@ -120,58 +120,18 @@ public: } else { - Log::Callbacks log_callbacks; - std::string channel(args.GetArgumentAtIndex(0)); args.Shift (); // Shift off the channel - StreamSP log_stream_sp; - if (m_options.log_file.empty()) - { - log_stream_sp.reset(new StreamFile(m_interpreter.GetDebugger().GetOutputFile().GetDescriptor(), false)); - } + bool success = m_interpreter.GetDebugger().EnableLog (channel.c_str(), + args.GetConstArgumentVector(), + m_options.log_file.c_str(), + m_options.log_options, + result.GetErrorStream()); + if (success) + result.SetStatus (eReturnStatusSuccessFinishNoResult); else - { - LogStreamMap::iterator pos = m_log_streams.find(m_options.log_file); - if (pos == m_log_streams.end()) - { - log_stream_sp.reset (new StreamFile (m_options.log_file.c_str())); - m_log_streams[m_options.log_file] = log_stream_sp; - } - else - log_stream_sp = pos->second; - } - assert (log_stream_sp.get()); - - uint32_t log_options = m_options.log_options; - if (log_options == 0) - log_options = LLDB_LOG_OPTION_PREPEND_THREAD_NAME | LLDB_LOG_OPTION_THREADSAFE; - if (Log::GetLogChannelCallbacks (channel.c_str(), log_callbacks)) - { - log_callbacks.enable (log_stream_sp, log_options, args, &result.GetErrorStream()); - result.SetStatus(eReturnStatusSuccessFinishNoResult); - } - else - { - LogChannelSP log_channel_sp (LogChannel::FindPlugin (channel.c_str())); - if (log_channel_sp) - { - if (log_channel_sp->Enable (log_stream_sp, log_options, &result.GetErrorStream(), args)) - { - result.SetStatus (eReturnStatusSuccessFinishNoResult); - } - else - { - result.AppendErrorWithFormat("Invalid log channel '%s'.\n", channel.c_str()); - result.SetStatus (eReturnStatusFailed); - } - } - else - { - result.AppendErrorWithFormat("Invalid log channel '%s'.\n", channel.c_str()); - result.SetStatus (eReturnStatusFailed); - } - } - } + result.SetStatus (eReturnStatusFailed); + } return result.Succeeded(); } @@ -241,9 +201,7 @@ public: }; protected: - typedef std::map LogStreamMap; CommandOptions m_options; - LogStreamMap m_log_streams; }; OptionDefinition @@ -316,7 +274,7 @@ public: args.Shift (); // Shift off the channel if (Log::GetLogChannelCallbacks (channel.c_str(), log_callbacks)) { - log_callbacks.disable (args, &result.GetErrorStream()); + log_callbacks.disable (args.GetConstArgumentVector(), &result.GetErrorStream()); result.SetStatus(eReturnStatusSuccessFinishNoResult); } else if (channel == "all") @@ -328,7 +286,7 @@ public: LogChannelSP log_channel_sp (LogChannel::FindPlugin(channel.c_str())); if (log_channel_sp) { - log_channel_sp->Disable(args, &result.GetErrorStream()); + log_channel_sp->Disable(args.GetConstArgumentVector(), &result.GetErrorStream()); result.SetStatus(eReturnStatusSuccessFinishNoResult); } else diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 0c17ca9735b6..abf23eab1ca4 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -21,6 +21,7 @@ #include "lldb/Core/RegisterValue.h" #include "lldb/Core/State.h" #include "lldb/Core/StreamAsynchronousIO.h" +#include "lldb/Core/StreamCallback.h" #include "lldb/Core/StreamString.h" #include "lldb/Core/Timer.h" #include "lldb/Core/ValueObject.h" @@ -241,9 +242,9 @@ Debugger::SettingsTerminate () } DebuggerSP -Debugger::CreateInstance () +Debugger::CreateInstance (lldb::LogOutputCallback log_callback, void *baton) { - DebuggerSP debugger_sp (new Debugger); + DebuggerSP debugger_sp (new Debugger(log_callback, baton)); // Scope for locker { Mutex::Locker locker (GetDebuggerListMutex ()); @@ -326,7 +327,7 @@ Debugger::FindTargetWithProcess (Process *process) } -Debugger::Debugger () : +Debugger::Debugger (lldb::LogOutputCallback log_callback, void *baton) : UserID (g_unique_id++), DebuggerInstanceSettings (GetSettingsController()), m_input_comm("debugger.input"), @@ -342,6 +343,8 @@ Debugger::Debugger () : m_input_reader_stack (), m_input_reader_data () { + if (log_callback) + m_log_callback_stream_sp.reset (new StreamCallback (log_callback, baton)); m_command_interpreter_ap->Initialize (); // Always add our default platform to the platform list PlatformSP default_platform_sp (Platform::GetDefaultPlatform()); @@ -2306,6 +2309,76 @@ Debugger::FormatPrompt return success; } +void +Debugger::SetLoggingCallback (lldb::LogOutputCallback log_callback, void *baton) +{ + // For simplicity's sake, I am only allowing the logging callback to get + // set when the debugger is created. Otherwise, I'd have to go turn off + // all the log channels using this callback, and switch them to the new one... + m_log_callback_stream_sp.reset (new StreamCallback (log_callback, baton)); +} + +bool +Debugger::EnableLog (const char *channel, const char **categories, const char *log_file, uint32_t log_options, Stream &error_stream) +{ + Log::Callbacks log_callbacks; + + StreamSP log_stream_sp; + if (m_log_callback_stream_sp != NULL) + { + log_stream_sp = m_log_callback_stream_sp; + // For now when using the callback mode you always get thread & timestamp. + log_options |= LLDB_LOG_OPTION_PREPEND_TIMESTAMP | LLDB_LOG_OPTION_PREPEND_THREAD_NAME; + } + else if (log_file == NULL || *log_file == '\0') + { + log_stream_sp.reset(new StreamFile(GetOutputFile().GetDescriptor(), false)); + } + else + { + LogStreamMap::iterator pos = m_log_streams.find(log_file); + if (pos == m_log_streams.end()) + { + log_stream_sp.reset (new StreamFile (log_file)); + m_log_streams[log_file] = log_stream_sp; + } + else + log_stream_sp = pos->second; + } + assert (log_stream_sp.get()); + + if (log_options == 0) + log_options = LLDB_LOG_OPTION_PREPEND_THREAD_NAME | LLDB_LOG_OPTION_THREADSAFE; + + if (Log::GetLogChannelCallbacks (channel, log_callbacks)) + { + log_callbacks.enable (log_stream_sp, log_options, categories, &error_stream); + return true; + } + else + { + LogChannelSP log_channel_sp (LogChannel::FindPlugin (channel)); + if (log_channel_sp) + { + if (log_channel_sp->Enable (log_stream_sp, log_options, &error_stream, categories)) + { + return true; + } + else + { + error_stream.Printf ("Invalid log channel '%s'.\n", channel); + return false; + } + } + else + { + error_stream.Printf ("Invalid log channel '%s'.\n", channel); + return false; + } + } + return false; +} + #pragma mark Debugger::SettingsController //-------------------------------------------------- diff --git a/lldb/source/Core/Log.cpp b/lldb/source/Core/Log.cpp index 68a0b1469e72..0b163fb04f54 100644 --- a/lldb/source/Core/Log.cpp +++ b/lldb/source/Core/Log.cpp @@ -118,6 +118,7 @@ Log::PrintfWithFlagsVarArg (uint32_t flags, const char *format, va_list args) header.PrintfVarArg (format, args); m_stream_sp->Printf("%s\n", header.GetData()); + m_stream_sp->Flush(); } } @@ -362,7 +363,7 @@ Log::EnableAllLogChannels ( StreamSP &log_stream_sp, uint32_t log_options, - Args &args, + const char **categories, Stream *feedback_strm ) { @@ -370,13 +371,13 @@ Log::EnableAllLogChannels CallbackMapIter pos, end = callback_map.end(); for (pos = callback_map.begin(); pos != end; ++pos) - pos->second.enable (log_stream_sp, log_options, args, feedback_strm); + pos->second.enable (log_stream_sp, log_options, categories, feedback_strm); LogChannelMap &channel_map = GetChannelMap (); LogChannelMapIter channel_pos, channel_end = channel_map.end(); for (channel_pos = channel_map.begin(); channel_pos != channel_end; ++channel_pos) { - channel_pos->second->Enable (log_stream_sp, log_options, feedback_strm, args); + channel_pos->second->Enable (log_stream_sp, log_options, feedback_strm, categories); } } @@ -407,15 +408,15 @@ Log::DisableAllLogChannels (Stream *feedback_strm) { CallbackMap &callback_map = GetCallbackMap (); CallbackMapIter pos, end = callback_map.end(); - Args args; + const char *categories[1] = {NULL}; for (pos = callback_map.begin(); pos != end; ++pos) - pos->second.disable (args, feedback_strm); + pos->second.disable (categories, feedback_strm); LogChannelMap &channel_map = GetChannelMap (); LogChannelMapIter channel_pos, channel_end = channel_map.end(); for (channel_pos = channel_map.begin(); channel_pos != channel_end; ++channel_pos) - channel_pos->second->Disable (args, feedback_strm); + channel_pos->second->Disable (categories, feedback_strm); } void diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp index 6e230fb19175..ff3c46ece3fd 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp @@ -43,20 +43,19 @@ ProcessKDPLog::GetLogIfAllCategoriesSet (uint32_t mask) } void -ProcessKDPLog::DisableLog (Args &args, Stream *feedback_strm) +ProcessKDPLog::DisableLog (const char **categories, Stream *feedback_strm) { LogSP log (GetLog ()); if (log) { uint32_t flag_bits = 0; - const size_t argc = args.GetArgumentCount (); - if (argc > 0) + if (categories[0] != NULL) { flag_bits = log->GetMask().Get(); - for (size_t i = 0; i < argc; ++i) + for (size_t i = 0; categories[i] != NULL; ++i) { - const char *arg = args.GetArgumentAtIndex (i); + const char *arg = categories[i]; if (::strcasecmp (arg, "all") == 0 ) flag_bits &= ~KDP_LOG_ALL; @@ -92,7 +91,7 @@ ProcessKDPLog::DisableLog (Args &args, Stream *feedback_strm) } LogSP -ProcessKDPLog::EnableLog (StreamSP &log_stream_sp, uint32_t log_options, Args &args, Stream *feedback_strm) +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. @@ -111,10 +110,9 @@ ProcessKDPLog::EnableLog (StreamSP &log_stream_sp, uint32_t log_options, Args &a if (log) { bool got_unknown_category = false; - const size_t argc = args.GetArgumentCount(); - for (size_t i=0; i 0) + if (categories[0] != NULL) { flag_bits = log->GetMask().Get(); - for (size_t i = 0; i < argc; ++i) + for (size_t i = 0; categories[i] != NULL; ++i) { - const char *arg = args.GetArgumentAtIndex (i); + const char *arg = categories[i]; if (::strcasecmp (arg, "all") == 0 ) flag_bits &= ~GDBR_LOG_ALL; @@ -92,7 +91,7 @@ ProcessGDBRemoteLog::DisableLog (Args &args, Stream *feedback_strm) } LogSP -ProcessGDBRemoteLog::EnableLog (StreamSP &log_stream_sp, uint32_t log_options, Args &args, Stream *feedback_strm) +ProcessGDBRemoteLog::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. @@ -111,10 +110,9 @@ ProcessGDBRemoteLog::EnableLog (StreamSP &log_stream_sp, uint32_t log_options, A if (log) { bool got_unknown_category = false; - const size_t argc = args.GetArgumentCount(); - for (size_t i=0; iGetMask().Get(); - const size_t argc = categories.GetArgumentCount(); - for (size_t i = 0; i < argc; ++i) + for (size_t i = 0; categories[i] != NULL; ++i) { - const char *arg = categories.GetArgumentAtIndex(i); + const char *arg = categories[i]; if (::strcasecmp (arg, "all") == 0 ) flag_bits &= ~DWARF_LOG_ALL; else if (::strcasecmp (arg, "info") == 0 ) flag_bits &= ~DWARF_LOG_DEBUG_INFO; @@ -132,7 +131,7 @@ LogChannelDWARF::Enable StreamSP &log_stream_sp, uint32_t log_options, Stream *feedback_strm, // Feedback stream for argument errors etc - const Args &categories // The categories to enable within this logging stream, if empty, enable default set + const char **categories // The categories to enable within this logging stream, if empty, enable default set ) { Delete (); @@ -141,10 +140,9 @@ LogChannelDWARF::Enable g_log_channel = this; uint32_t flag_bits = 0; bool got_unknown_category = false; - const size_t argc = categories.GetArgumentCount(); - for (size_t i=0; i 0) + if (categories[0] != NULL) { flag_bits = log->GetMask().Get(); - for (size_t i = 0; i < argc; ++i) + for (size_t i = 0; categories[i] != NULL; ++i) { - const char *arg = args.GetArgumentAtIndex (i); + const char *arg = categories[i]; if (0 == ::strcasecmp(arg, "all")) flag_bits &= ~LIBLLDB_LOG_ALL; else if (0 == ::strcasecmp(arg, "api")) flag_bits &= ~LIBLLDB_LOG_API; @@ -155,7 +154,7 @@ lldb_private::DisableLog (Args &args, Stream *feedback_strm) } LogSP -lldb_private::EnableLog (StreamSP &log_stream_sp, uint32_t log_options, Args &args, Stream *feedback_strm) +lldb_private::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. @@ -176,10 +175,9 @@ lldb_private::EnableLog (StreamSP &log_stream_sp, uint32_t log_options, Args &ar if (log) { bool got_unknown_category = false; - const size_t argc = args.GetArgumentCount(); - for (size_t i=0; i