[Lldb-commits] [lldb] r151018 - in /lldb/trunk: include/lldb/ include/lldb/API/ include/lldb/Core/ lldb.xcodeproj/ scripts/Python/interface/ source/ source/API/ source/Commands/ source/Core/ source/Plugins/Process/MacOSX-Kernel/ source/Plugins/Process/gdb-remote/ source/Plugins/SymbolFile/DWARF/ tools/lldb-platform/
Jim Ingham
jingham at apple.com
Mon Feb 20 18:23:08 PST 2012
Author: jingham
Date: Mon Feb 20 20:23:08 2012
New Revision: 151018
URL: http://llvm.org/viewvc/llvm-project?rev=151018&view=rev
Log:
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.
Modified:
lldb/trunk/include/lldb/API/SBDebugger.h
lldb/trunk/include/lldb/Core/Debugger.h
lldb/trunk/include/lldb/Core/Log.h
lldb/trunk/include/lldb/lldb-private-log.h
lldb/trunk/include/lldb/lldb-types.h
lldb/trunk/lldb.xcodeproj/project.pbxproj
lldb/trunk/scripts/Python/interface/SBDebugger.i
lldb/trunk/source/API/SBDebugger.cpp
lldb/trunk/source/Commands/CommandObjectLog.cpp
lldb/trunk/source/Core/Debugger.cpp
lldb/trunk/source/Core/Log.cpp
lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp
lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.h
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h
lldb/trunk/source/lldb-log.cpp
lldb/trunk/tools/lldb-platform/lldb-platform.cpp
Modified: lldb/trunk/include/lldb/API/SBDebugger.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDebugger.h?rev=151018&r1=151017&r2=151018&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBDebugger.h (original)
+++ lldb/trunk/include/lldb/API/SBDebugger.h Mon Feb 20 20:23:08 2012
@@ -32,6 +32,9 @@
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 @@
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);
Modified: lldb/trunk/include/lldb/Core/Debugger.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=151018&r1=151017&r2=151018&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Debugger.h (original)
+++ lldb/trunk/include/lldb/Core/Debugger.h Mon Feb 20 20:23:08 2012
@@ -289,7 +289,7 @@
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 @@
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 @@
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);
Modified: lldb/trunk/include/lldb/Core/Log.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Log.h?rev=151018&r1=151017&r2=151018&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Log.h (original)
+++ lldb/trunk/include/lldb/Core/Log.h Mon Feb 20 20:23:08 2012
@@ -59,10 +59,10 @@
//------------------------------------------------------------------
// 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 @@
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 @@
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;
Modified: lldb/trunk/include/lldb/lldb-private-log.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private-log.h?rev=151018&r1=151017&r2=151018&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-private-log.h (original)
+++ lldb/trunk/include/lldb/lldb-private-log.h Mon Feb 20 20:23:08 2012
@@ -75,10 +75,10 @@
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);
Modified: lldb/trunk/include/lldb/lldb-types.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-types.h?rev=151018&r1=151017&r2=151018&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-types.h (original)
+++ lldb/trunk/include/lldb/lldb-types.h Mon Feb 20 20:23:08 2012
@@ -74,7 +74,7 @@
// {
// typedef lldb_private::IntrusiveSharingPtr<_Tp> Type;
// };
-
+ typedef void (*LogOutputCallback) (const char *, void *baton);
} // namespace lldb
#if defined(__MINGW32__)
Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=151018&r1=151017&r2=151018&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Feb 20 20:23:08 2012
@@ -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;
Modified: lldb/trunk/scripts/Python/interface/SBDebugger.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBDebugger.i?rev=151018&r1=151017&r2=151018&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBDebugger.i (original)
+++ lldb/trunk/scripts/Python/interface/SBDebugger.i Mon Feb 20 20:23:08 2012
@@ -119,6 +119,9 @@
static lldb::SBDebugger
Create();
+ static lldb::SBDebugger
+ Create(bool source_init_files);
+
static void
Destroy (lldb::SBDebugger &debugger);
@@ -262,6 +265,9 @@
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);
Modified: lldb/trunk/source/API/SBDebugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=151018&r1=151017&r2=151018&view=diff
==============================================================================
--- lldb/trunk/source/API/SBDebugger.cpp (original)
+++ lldb/trunk/source/API/SBDebugger.cpp Mon Feb 20 20:23:08 2012
@@ -81,16 +81,23 @@
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 @@
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;
+}
Modified: lldb/trunk/source/Commands/CommandObjectLog.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectLog.cpp?rev=151018&r1=151017&r2=151018&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectLog.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectLog.cpp Mon Feb 20 20:23:08 2012
@@ -120,58 +120,18 @@
}
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));
- }
- 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);
- }
+ 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
- {
- 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 @@
};
protected:
- typedef std::map<std::string, StreamSP> LogStreamMap;
CommandOptions m_options;
- LogStreamMap m_log_streams;
};
OptionDefinition
@@ -316,7 +274,7 @@
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 @@
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
Modified: lldb/trunk/source/Core/Debugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=151018&r1=151017&r2=151018&view=diff
==============================================================================
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Mon Feb 20 20:23:08 2012
@@ -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 @@
}
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::Debugger () :
+Debugger::Debugger (lldb::LogOutputCallback log_callback, void *baton) :
UserID (g_unique_id++),
DebuggerInstanceSettings (GetSettingsController()),
m_input_comm("debugger.input"),
@@ -342,6 +343,8 @@
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 @@
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
//--------------------------------------------------
Modified: lldb/trunk/source/Core/Log.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Log.cpp?rev=151018&r1=151017&r2=151018&view=diff
==============================================================================
--- lldb/trunk/source/Core/Log.cpp (original)
+++ lldb/trunk/source/Core/Log.cpp Mon Feb 20 20:23:08 2012
@@ -118,6 +118,7 @@
header.PrintfVarArg (format, args);
m_stream_sp->Printf("%s\n", header.GetData());
+ m_stream_sp->Flush();
}
}
@@ -362,7 +363,7 @@
(
StreamSP &log_stream_sp,
uint32_t log_options,
- Args &args,
+ const char **categories,
Stream *feedback_strm
)
{
@@ -370,13 +371,13 @@
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 @@
{
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
Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp?rev=151018&r1=151017&r2=151018&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp Mon Feb 20 20:23:08 2012
@@ -43,20 +43,19 @@
}
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 @@
}
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 @@
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;
Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.h?rev=151018&r1=151017&r2=151018&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.h (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.h Mon Feb 20 20:23:08 2012
@@ -39,10 +39,10 @@
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);
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp?rev=151018&r1=151017&r2=151018&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp Mon Feb 20 20:23:08 2012
@@ -43,20 +43,19 @@
}
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 @@
}
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 @@
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;
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h?rev=151018&r1=151017&r2=151018&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h Mon Feb 20 20:23:08 2012
@@ -39,10 +39,10 @@
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);
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp?rev=151018&r1=151017&r2=151018&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp Mon Feb 20 20:23:08 2012
@@ -91,17 +91,16 @@
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 @@
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 @@
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;
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h?rev=151018&r1=151017&r2=151018&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h Mon Feb 20 20:23:08 2012
@@ -60,7 +60,7 @@
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 @@
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);
Modified: lldb/trunk/source/lldb-log.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb-log.cpp?rev=151018&r1=151017&r2=151018&view=diff
==============================================================================
--- lldb/trunk/source/lldb-log.cpp (original)
+++ lldb/trunk/source/lldb-log.cpp Mon Feb 20 20:23:08 2012
@@ -98,20 +98,19 @@
}
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 @@
}
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 @@
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;
Modified: lldb/trunk/tools/lldb-platform/lldb-platform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-platform/lldb-platform.cpp?rev=151018&r1=151017&r2=151018&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-platform/lldb-platform.cpp (original)
+++ lldb/trunk/tools/lldb-platform/lldb-platform.cpp Mon Feb 20 20:23:08 2012
@@ -172,7 +172,7 @@
{
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
More information about the lldb-commits
mailing list