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
This commit is contained in:
Jim Ingham
2012-02-21 02:23:08 +00:00
parent 926410d2db
commit 228063cd21
19 changed files with 190 additions and 116 deletions

View File

@@ -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);

View File

@@ -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<std::string, lldb::StreamSP> 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);

View File

@@ -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;

View File

@@ -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);

View File

@@ -74,7 +74,7 @@ namespace lldb {
// {
// typedef lldb_private::IntrusiveSharingPtr<_Tp> Type;
// };
typedef void (*LogOutputCallback) (const char *, void *baton);
} // namespace lldb
#if defined(__MINGW32__)

View File

@@ -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 = "<group>"; };
4C5DBBC711E3FEC60035160F /* CommandObjectCommands.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectCommands.h; path = source/Commands/CommandObjectCommands.h; sourceTree = "<group>"; };
4C626533130F1B0A00C889F6 /* StreamTee.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StreamTee.h; path = include/lldb/Core/StreamTee.h; sourceTree = "<group>"; };
4C66499F14EEE7F100B0316F /* StreamCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StreamCallback.h; path = include/lldb/Core/StreamCallback.h; sourceTree = "<group>"; };
4C6649A214EEE81000B0316F /* StreamCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StreamCallback.cpp; path = source/Core/StreamCallback.cpp; sourceTree = "<group>"; };
4C74CB6212288704006A8171 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = "<absolute>"; };
4C7CF7E31295E10E00B4FBB5 /* ThreadPlanCallUserExpression.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadPlanCallUserExpression.h; path = include/lldb/Target/ThreadPlanCallUserExpression.h; sourceTree = "<group>"; };
4C7CF7E51295E12B00B4FBB5 /* ThreadPlanCallUserExpression.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadPlanCallUserExpression.cpp; path = source/Target/ThreadPlanCallUserExpression.cpp; sourceTree = "<group>"; };
@@ -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;

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -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<std::string, StreamSP> 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

View File

@@ -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
//--------------------------------------------------

View File

@@ -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

View File

@@ -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<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;
else if (::strcasecmp (arg, "async") == 0 ) flag_bits |= KDP_LOG_ASYNC;

View File

@@ -39,10 +39,10 @@ public:
GetLogIfAllCategoriesSet(uint32_t mask = 0);
static void
DisableLog (lldb_private::Args &args, lldb_private::Stream *feedback_strm);
DisableLog (const char **categories, lldb_private::Stream *feedback_strm);
static lldb::LogSP
EnableLog (lldb::StreamSP &log_stream_sp, uint32_t log_options, lldb_private::Args &args, lldb_private::Stream *feedback_strm);
EnableLog (lldb::StreamSP &log_stream_sp, uint32_t log_options, const char **categories, lldb_private::Stream *feedback_strm);
static void
ListLogCategories (lldb_private::Stream *strm);

View File

@@ -43,20 +43,19 @@ ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (uint32_t mask)
}
void
ProcessGDBRemoteLog::DisableLog (Args &args, Stream *feedback_strm)
ProcessGDBRemoteLog::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 &= ~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; 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;
else if (::strcasecmp (arg, "async") == 0 ) flag_bits |= GDBR_LOG_ASYNC;

View File

@@ -39,10 +39,10 @@ public:
GetLogIfAllCategoriesSet(uint32_t mask = 0);
static void
DisableLog (lldb_private::Args &args, lldb_private::Stream *feedback_strm);
DisableLog (const char **categories, lldb_private::Stream *feedback_strm);
static lldb::LogSP
EnableLog (lldb::StreamSP &log_stream_sp, uint32_t log_options, lldb_private::Args &args, lldb_private::Stream *feedback_strm);
EnableLog (lldb::StreamSP &log_stream_sp, uint32_t log_options, const char **categories, lldb_private::Stream *feedback_strm);
static void
ListLogCategories (lldb_private::Stream *strm);

View File

@@ -91,17 +91,16 @@ LogChannelDWARF::Delete ()
void
LogChannelDWARF::Disable (Args &categories, Stream *feedback_strm)
LogChannelDWARF::Disable (const char **categories, Stream *feedback_strm)
{
if (!m_log_sp)
return;
g_log_channel = this;
uint32_t flag_bits = m_log_sp->GetMask().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<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;

View File

@@ -60,7 +60,7 @@ public:
GetPluginVersion();
virtual void
Disable (lldb_private::Args &args, lldb_private::Stream *feedback_strm);
Disable (const char** categories, lldb_private::Stream *feedback_strm);
void
Delete ();
@@ -69,7 +69,7 @@ public:
Enable (lldb::StreamSP &log_stream_sp,
uint32_t log_options,
lldb_private::Stream *feedback_strm, // Feedback stream for argument errors etc
const lldb_private::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
virtual void
ListCategories (lldb_private::Stream *strm);

View File

@@ -98,20 +98,19 @@ lldb_private::GetLogIfAnyCategoriesSet (uint32_t mask)
}
void
lldb_private::DisableLog (Args &args, Stream *feedback_strm)
lldb_private::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 (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<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;

View File

@@ -172,7 +172,7 @@ main (int argc, char *argv[])
{
if (log_args.GetArgumentCount() == 0)
log_args.AppendArgument("default");
ProcessGDBRemoteLog::EnableLog (log_stream_sp, 0,log_args, log_stream_sp.get());
ProcessGDBRemoteLog::EnableLog (log_stream_sp, 0,log_args.GetConstArgumentVector(), log_stream_sp.get());
}
// Skip any options we consumed with getopt_long