diff options
author | Jim Ingham <jingham@apple.com> | 2012-02-21 02:23:08 +0000 |
---|---|---|
committer | Jim Ingham <jingham@apple.com> | 2012-02-21 02:23:08 +0000 |
commit | 228063cd21c4e13aba0ef7a4522b1f32e3116c18 (patch) | |
tree | 73697c5ec27b8e8f282974db7db4f18de99b770b /lldb/source/Commands/CommandObjectLog.cpp | |
parent | 926410d2db727c5093bda792cb8b2025d7f02cc3 (diff) | |
download | bcm5719-llvm-228063cd21c4e13aba0ef7a4522b1f32e3116c18.tar.gz bcm5719-llvm-228063cd21c4e13aba0ef7a4522b1f32e3116c18.zip |
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
Diffstat (limited to 'lldb/source/Commands/CommandObjectLog.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectLog.cpp | 64 |
1 files changed, 11 insertions, 53 deletions
diff --git a/lldb/source/Commands/CommandObjectLog.cpp b/lldb/source/Commands/CommandObjectLog.cpp index 8a1688e7052..611c76b961c 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)); - } - 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 @@ 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 |