diff options
25 files changed, 318 insertions, 98 deletions
diff --git a/lldb/include/lldb/API/SBCommandReturnObject.h b/lldb/include/lldb/API/SBCommandReturnObject.h index e270e7ddd09..9058122c030 100644 --- a/lldb/include/lldb/API/SBCommandReturnObject.h +++ b/lldb/include/lldb/API/SBCommandReturnObject.h @@ -69,7 +69,13 @@ public: bool GetDescription (lldb::SBStream &description); - + + void + SetImmediateOutputFile (FILE *fh); + + void + SetImmediateErrorFile (FILE *fh); + protected: friend class SBCommandInterpreter; friend class SBOptions; diff --git a/lldb/include/lldb/API/SBStream.h b/lldb/include/lldb/API/SBStream.h index 6888943e310..ba533f8436a 100644 --- a/lldb/include/lldb/API/SBStream.h +++ b/lldb/include/lldb/API/SBStream.h @@ -21,7 +21,7 @@ class SBStream public: SBStream (); - + ~SBStream (); bool @@ -74,6 +74,7 @@ protected: friend class SBTarget; friend class SBThread; friend class SBValue; + friend class SBCommandReturnObject; #ifndef SWIG diff --git a/lldb/include/lldb/Core/StreamTee.h b/lldb/include/lldb/Core/StreamTee.h new file mode 100644 index 00000000000..aa1b579d0dd --- /dev/null +++ b/lldb/include/lldb/Core/StreamTee.h @@ -0,0 +1,97 @@ +//===-- StreamTee.h ------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_StreamTee_h_ +#define liblldb_StreamTee_h_ + +#include "lldb/Core/Stream.h" + +namespace lldb_private { + +class StreamTee : public Stream +{ +public: + StreamTee () : + Stream() + { + } + + StreamTee (lldb::StreamSP &stream_1_sp, lldb::StreamSP &stream_2_sp): + m_stream_1_sp (stream_1_sp), + m_stream_2_sp (stream_2_sp) + { + } + + StreamTee (lldb::StreamSP &stream_1_sp): + m_stream_1_sp (stream_1_sp), + m_stream_2_sp () + { + } + + virtual + ~StreamTee () + { + } + + virtual void + Flush () + { + if (m_stream_1_sp) + m_stream_1_sp->Flush (); + + if (m_stream_2_sp) + m_stream_2_sp->Flush (); + } + + virtual int + Write (const void *s, size_t length) + { + int ret_1; + int ret_2; + if (m_stream_1_sp) + ret_1 = m_stream_1_sp->Write (s, length); + + if (m_stream_2_sp) + ret_2 = m_stream_2_sp->Write (s, length); + + return ret_1 < ret_2 ? ret_1 : ret_2; + } + + void + SetStream1 (lldb::StreamSP &stream_1_sp) + { + m_stream_1_sp = stream_1_sp; + } + + void + SetStream2 (lldb::StreamSP &stream_2_sp) + { + m_stream_2_sp = stream_2_sp; + } + + lldb::StreamSP & + GetStream1 () + { + return m_stream_1_sp; + } + + lldb::StreamSP & + GetStream2 () + { + return m_stream_2_sp; + } + +protected: + lldb::StreamSP m_stream_1_sp; + lldb::StreamSP m_stream_2_sp; + +}; + +} // namespace lldb_private +#endif // #ifndef liblldb_StreamTee_h_ diff --git a/lldb/include/lldb/Core/UserSettingsController.h b/lldb/include/lldb/Core/UserSettingsController.h index 3c071b1057f..b2b8adaa1e6 100644 --- a/lldb/include/lldb/Core/UserSettingsController.h +++ b/lldb/include/lldb/Core/UserSettingsController.h @@ -137,7 +137,7 @@ public: FindAllSettingsDescriptions (CommandInterpreter &interpreter, lldb::UserSettingsControllerSP root, std::string ¤t_prefix, - StreamString &result_stream, + Stream &result_stream, Error &err); static void @@ -145,7 +145,7 @@ public: lldb::UserSettingsControllerSP root, std::string ¤t_prefix, const char *search_name, - StreamString &result_stream, + Stream &result_stream, Error &err); static void @@ -153,13 +153,13 @@ public: lldb::UserSettingsControllerSP root, std::string ¤t_prefix, const char *search_word, - StreamString &result_stream); + Stream &result_stream); static void GetAllVariableValues (CommandInterpreter &interpreter, lldb::UserSettingsControllerSP root, std::string ¤t_prefix, - StreamString &result_stream, + Stream &result_stream, Error &err); static int @@ -289,14 +289,14 @@ protected: FindSettingsForInstance (const ConstString &instance_name); void - GetAllPendingSettingValues (StreamString &result_stream); + GetAllPendingSettingValues (Stream &result_stream); void - GetAllDefaultSettingValues (StreamString &result_stream); + GetAllDefaultSettingValues (Stream &result_stream); void GetAllInstanceVariableValues (CommandInterpreter &interpreter, - StreamString &result_stream); + Stream &result_stream); void OverrideAllInstances (const ConstString &var_name, diff --git a/lldb/include/lldb/Interpreter/CommandReturnObject.h b/lldb/include/lldb/Interpreter/CommandReturnObject.h index c95caa26002..e63ea796939 100644 --- a/lldb/include/lldb/Interpreter/CommandReturnObject.h +++ b/lldb/include/lldb/Interpreter/CommandReturnObject.h @@ -16,7 +16,9 @@ // Project includes #include "lldb/lldb-private.h" #include "lldb/Core/STLUtils.h" +#include "lldb/Core/StreamFile.h" #include "lldb/Core/StreamString.h" +#include "lldb/Core/StreamTee.h" namespace lldb_private { @@ -26,16 +28,90 @@ class CommandReturnObject public: CommandReturnObject (); - + ~CommandReturnObject (); - StreamString & - GetOutputStream (); - - StreamString & - GetErrorStream (); + const char * + GetOutputData () + { + if (m_output_stream_string_sp) + return static_cast<StreamString *>(m_output_stream_string_sp.get())->GetData(); + else + return ""; + } + + const char * + GetErrorData () + { + if (m_error_stream_string_sp) + return static_cast<StreamString *>(m_error_stream_string_sp.get())->GetData(); + else + return ""; + } + + Stream & + GetOutputStream () + { + if (!m_output_stream_string_sp) + { + StreamString *new_stream = new StreamString(); + m_output_stream_string_sp.reset (new_stream); + m_output_stream.SetStream1 (m_output_stream_string_sp); + } + return m_output_stream; + } + + Stream & + GetErrorStream () + { + if (!m_error_stream_string_sp) + { + StreamString *new_stream = new StreamString(); + m_error_stream_string_sp.reset (new_stream); + m_error_stream.SetStream1 (m_error_stream_string_sp); + } + return m_error_stream; + } void + SetImmediateOutputFile (FILE *fh) + { + lldb::StreamSP new_stream_sp (new StreamFile (fh, false)); + m_output_stream.SetStream2 (new_stream_sp); + } + + void + SetImmediateErrorFile (FILE *fh) + { + lldb::StreamSP new_stream_sp (new StreamFile (fh, false)); + SetImmediateOutputStream (new_stream_sp); + } + + void + SetImmediateOutputStream (lldb::StreamSP &new_stream_sp) + { + m_output_stream.SetStream2 (new_stream_sp); + } + + void + SetImmediateErrorStream (lldb::StreamSP &new_stream_sp) + { + m_error_stream.SetStream2 (new_stream_sp); + } + + lldb::StreamSP & + GetImmediateOutputStream () + { + return m_output_stream.GetStream2 (); + } + + lldb::StreamSP & + GetImmediateErrorStream () + { + return m_error_stream.GetStream2 (); + } + + void Clear(); void @@ -79,8 +155,11 @@ public: void SetDidChangeProcessState (bool b); private: - StreamString m_output_stream; - StreamString m_error_stream; + lldb::StreamSP m_output_stream_string_sp; + lldb::StreamSP m_error_stream_string_sp; + StreamTee m_output_stream; + StreamTee m_error_stream; + lldb::ReturnStatus m_status; bool m_did_change_process_state; }; diff --git a/lldb/include/lldb/Symbol/SymbolContext.h b/lldb/include/lldb/Symbol/SymbolContext.h index f1c96de3d4d..e8f8f19b869 100644 --- a/lldb/include/lldb/Symbol/SymbolContext.h +++ b/lldb/include/lldb/Symbol/SymbolContext.h @@ -233,6 +233,15 @@ public: //------------------------------------------------------------------ lldb::TypeSP FindTypeByName (const ConstString &name) const; + +// static SymbolContext +// CreateSymbolContextFromDescription (lldb::TargetSP &target, +// const char *module, +// const char *comp_unit, +// const char *function, +// const char *block_spec +// const char *line_number, +// const char *symbol); //------------------------------------------------------------------ // Member variables diff --git a/lldb/lldb.xcodeproj/project.pbxproj b/lldb/lldb.xcodeproj/project.pbxproj index 96770f96bb0..37e9b9c6105 100644 --- a/lldb/lldb.xcodeproj/project.pbxproj +++ b/lldb/lldb.xcodeproj/project.pbxproj @@ -347,6 +347,7 @@ 4C61978D12823D4300FAFFCC /* AppleObjCRuntime.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C61978912823D4300FAFFCC /* AppleObjCRuntime.h */; }; 4C61978E12823D4300FAFFCC /* AppleObjCRuntimeV1.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C61978A12823D4300FAFFCC /* AppleObjCRuntimeV1.cpp */; }; 4C61978F12823D4300FAFFCC /* AppleObjCRuntimeV1.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C61978B12823D4300FAFFCC /* AppleObjCRuntimeV1.h */; }; + 4C626534130F1B0A00C889F6 /* StreamTee.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C626533130F1B0A00C889F6 /* StreamTee.h */; }; 4C74CB6312288704006A8171 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C74CB6212288704006A8171 /* Carbon.framework */; }; 4C7CF7E41295E10E00B4FBB5 /* ThreadPlanCallUserExpression.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C7CF7E31295E10E00B4FBB5 /* ThreadPlanCallUserExpression.h */; }; 4C7CF7E61295E12B00B4FBB5 /* ThreadPlanCallUserExpression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C7CF7E51295E12B00B4FBB5 /* ThreadPlanCallUserExpression.cpp */; }; @@ -1001,6 +1002,7 @@ 4C61978912823D4300FAFFCC /* AppleObjCRuntime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppleObjCRuntime.h; path = LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h; sourceTree = "<group>"; }; 4C61978A12823D4300FAFFCC /* AppleObjCRuntimeV1.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AppleObjCRuntimeV1.cpp; path = LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp; sourceTree = "<group>"; }; 4C61978B12823D4300FAFFCC /* AppleObjCRuntimeV1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppleObjCRuntimeV1.h; path = LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.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>"; }; 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>"; }; @@ -1741,6 +1743,7 @@ 26BC7E9210F1B85900F91463 /* StreamFile.cpp */, 26BC7D7B10F1B77400F91463 /* StreamString.h */, 26BC7E9310F1B85900F91463 /* StreamString.cpp */, + 4C626533130F1B0A00C889F6 /* StreamTee.h */, 9A35765E116E76A700E8ED2F /* StringList.h */, 9A35765F116E76B900E8ED2F /* StringList.cpp */, 26B167A41123BF5500DC7B4F /* ThreadSafeValue.h */, @@ -2356,6 +2359,7 @@ 268DA872130095D000C9483A /* Terminal.h in Headers */, 26FA4316130103F400E71120 /* FileSpec.h in Headers */, 260C6EA113011578005E16B0 /* File.h in Headers */, + 4C626534130F1B0A00C889F6 /* StreamTee.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/lldb/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme b/lldb/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme index 338a8758f9a..62ebd01993b 100644 --- a/lldb/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme +++ b/lldb/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme @@ -72,11 +72,11 @@ </EnvironmentVariables> </TestAction> <LaunchAction - selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" - selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" displayScaleIsEnabled = "NO" displayScale = "1.00" - launchStyle = "0" + launchStyle = "1" useCustomWorkingDirectory = "NO" buildConfiguration = "Debug"> <BuildableProductRunnable> diff --git a/lldb/source/API/SBCommandReturnObject.cpp b/lldb/source/API/SBCommandReturnObject.cpp index 69dcab68432..8377c1fc3a1 100644 --- a/lldb/source/API/SBCommandReturnObject.cpp +++ b/lldb/source/API/SBCommandReturnObject.cpp @@ -63,9 +63,9 @@ SBCommandReturnObject::GetOutput () { if (log) log->Printf ("SBCommandReturnObject(%p)::GetOutput () => \"%s\"", m_opaque_ap.get(), - m_opaque_ap->GetOutputStream().GetData()); + m_opaque_ap->GetOutputData()); - return m_opaque_ap->GetOutputStream().GetData(); + return m_opaque_ap->GetOutputData(); } if (log) @@ -83,9 +83,9 @@ SBCommandReturnObject::GetError () { if (log) log->Printf ("SBCommandReturnObject(%p)::GetError () => \"%s\"", m_opaque_ap.get(), - m_opaque_ap->GetErrorStream().GetData()); + m_opaque_ap->GetErrorData()); - return m_opaque_ap->GetErrorStream().GetData(); + return m_opaque_ap->GetErrorData(); } if (log) @@ -98,7 +98,7 @@ size_t SBCommandReturnObject::GetOutputSize () { if (m_opaque_ap.get()) - return m_opaque_ap->GetOutputStream().GetSize(); + return strlen (m_opaque_ap->GetOutputData()); return 0; } @@ -106,7 +106,7 @@ size_t SBCommandReturnObject::GetErrorSize () { if (m_opaque_ap.get()) - return m_opaque_ap->GetErrorStream().GetSize(); + return strlen(m_opaque_ap->GetErrorData()); return 0; } @@ -234,3 +234,17 @@ SBCommandReturnObject::GetDescription (SBStream &description) return true; } + +void +SBCommandReturnObject::SetImmediateOutputFile (FILE *fh) +{ + if (m_opaque_ap.get()) + m_opaque_ap->SetImmediateOutputFile (fh); +} + +void +SBCommandReturnObject::SetImmediateErrorFile (FILE *fh) +{ + if (m_opaque_ap.get()) + m_opaque_ap->SetImmediateErrorFile (fh); +} diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp index 4dff1420c4e..e291d93df56 100644 --- a/lldb/source/Commands/CommandObjectBreakpoint.cpp +++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp @@ -34,7 +34,7 @@ using namespace lldb; using namespace lldb_private; static void -AddBreakpointDescription (StreamString *s, Breakpoint *bp, lldb::DescriptionLevel level) +AddBreakpointDescription (Stream *s, Breakpoint *bp, lldb::DescriptionLevel level) { s->IndentMore(); bp->GetDescription (s, level, true); @@ -370,8 +370,8 @@ CommandObjectBreakpointSet::Execute m_options.m_check_inlines).get(); if (bp) { - StreamString &output_stream = result.GetOutputStream(); - output_stream.Printf ("Breakpoint created: "); + Stream &output_stream = result.GetOutputStream(); + result.AppendMessage ("Breakpoint created: "); bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief); output_stream.EOL(); if (bp->GetNumLocations() == 0) @@ -417,7 +417,7 @@ CommandObjectBreakpointSet::Execute Breakpoint::Exact).get(); if (bp) { - StreamString &output_stream = result.GetOutputStream(); + Stream &output_stream = result.GetOutputStream(); output_stream.Printf ("Breakpoint created: "); bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief); output_stream.EOL(); @@ -450,7 +450,7 @@ CommandObjectBreakpointSet::Execute bp = target->CreateBreakpoint (&module_spec, regexp).get(); if (bp) { - StreamString &output_stream = result.GetOutputStream(); + Stream &output_stream = result.GetOutputStream(); output_stream.Printf ("Breakpoint created: "); bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief); output_stream.EOL(); @@ -497,7 +497,7 @@ CommandObjectBreakpointSet::Execute if (bp && !use_module) { - StreamString &output_stream = result.GetOutputStream(); + Stream &output_stream = result.GetOutputStream(); output_stream.Printf ("Breakpoint created: "); bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief); output_stream.EOL(); @@ -775,7 +775,7 @@ CommandObjectBreakpointList::Execute return true; } - StreamString &output_stream = result.GetOutputStream(); + Stream &output_stream = result.GetOutputStream(); if (args.GetArgumentCount() == 0) { @@ -1212,7 +1212,7 @@ CommandObjectBreakpointClear::Execute if (num_cleared > 0) { - StreamString &output_stream = result.GetOutputStream(); + Stream &output_stream = result.GetOutputStream(); output_stream.Printf ("%d breakpoints cleared:\n", num_cleared); output_stream << ss.GetData(); output_stream.EOL(); diff --git a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp index edca869e48a..f88264b6c1b 100644 --- a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp +++ b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp @@ -790,15 +790,19 @@ CommandObjectBreakpointCommand::BreakpointOptionsCallbackFunction BreakpointOptions::CommandData *data = (BreakpointOptions::CommandData *) baton; StringList &commands = data->user_source; - + if (commands.GetSize() > 0) { - CommandReturnObject result; if (context->exe_ctx.target) { - + CommandReturnObject result; Debugger &debugger = context->exe_ctx.target->GetDebugger(); - + // Rig up the results secondary output stream to the debugger's, so the output will come out synchronously + // if the debugger is set up that way. + + result.SetImmediateOutputFile (debugger.GetOutputFile().GetStream()); + result.SetImmediateErrorFile (debugger.GetErrorFile().GetStream()); + bool stop_on_continue = true; bool echo_commands = false; bool print_results = true; @@ -810,14 +814,6 @@ CommandObjectBreakpointCommand::BreakpointOptionsCallbackFunction echo_commands, print_results, result); - // Now dump the commands to the debugger's output: - if (!result.Succeeded()) - { - debugger.GetErrorFile().Printf ("%s", result.GetErrorStream().GetData()); - } - - debugger.GetOutputFile().Printf ("%s", result.GetOutputStream().GetData()); - } } return ret_value; diff --git a/lldb/source/Commands/CommandObjectMultiword.cpp b/lldb/source/Commands/CommandObjectMultiword.cpp index db500a7f66c..e5435fc648a 100644 --- a/lldb/source/Commands/CommandObjectMultiword.cpp +++ b/lldb/source/Commands/CommandObjectMultiword.cpp @@ -187,7 +187,7 @@ CommandObjectMultiword::GenerateHelpText (CommandReturnObject &result) // First time through here, generate the help text for the object and // push it to the return result object as well - StreamString &output_stream = result.GetOutputStream(); + Stream &output_stream = result.GetOutputStream(); output_stream.PutCString ("The following subcommands are supported:\n\n"); CommandMap::iterator pos; diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index 7329ccbb1d9..22fd6c2406b 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -1483,7 +1483,7 @@ public: CommandReturnObject &result ) { - StreamString &output_stream = result.GetOutputStream(); + Stream &output_stream = result.GetOutputStream(); result.SetStatus (eReturnStatusSuccessFinishNoResult); ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); if (exe_ctx.process) diff --git a/lldb/source/Commands/CommandObjectRegister.cpp b/lldb/source/Commands/CommandObjectRegister.cpp index 4bcf681f633..d9cb5de6fe6 100644 --- a/lldb/source/Commands/CommandObjectRegister.cpp +++ b/lldb/source/Commands/CommandObjectRegister.cpp @@ -65,7 +65,7 @@ public: CommandReturnObject &result ) { - StreamString &output_stream = result.GetOutputStream(); + Stream &output_stream = result.GetOutputStream(); DataExtractor reg_data; ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); RegisterContext *reg_context = exe_ctx.GetRegisterContext (); diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp index af11fa7bf6f..487cfc96b56 100644 --- a/lldb/source/Commands/CommandObjectThread.cpp +++ b/lldb/source/Commands/CommandObjectThread.cpp @@ -131,7 +131,7 @@ lldb_private::DisplayThreadsInfo if (num_thread_infos_dumped < num_threads) result.GetOutputStream().Printf("%u of %u threads stopped with reasons:\n", num_thread_infos_dumped, num_threads); - result.GetOutputStream().GetString().append(strm.GetString()); + result.AppendMessage (strm.GetString().c_str()); result.SetStatus (eReturnStatusSuccessFinishNoResult); } return num_thread_infos_dumped; @@ -1379,7 +1379,7 @@ public: CommandReturnObject &result ) { - StreamString &strm = result.GetOutputStream(); + Stream &strm = result.GetOutputStream(); result.SetStatus (eReturnStatusSuccessFinishNoResult); ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); if (exe_ctx.process) diff --git a/lldb/source/Commands/CommandObjectVersion.cpp b/lldb/source/Commands/CommandObjectVersion.cpp index 5e159e1cbc8..99b92e7a407 100644 --- a/lldb/source/Commands/CommandObjectVersion.cpp +++ b/lldb/source/Commands/CommandObjectVersion.cpp @@ -40,8 +40,7 @@ CommandObjectVersion::Execute CommandReturnObject &result ) { - StreamString &output_stream = result.GetOutputStream(); - output_stream.Printf ("%s\n", lldb_private::GetVersion()); + result.AppendMessageWithFormat ("%s\n", lldb_private::GetVersion()); result.SetStatus (eReturnStatusSuccessFinishResult); return true; } diff --git a/lldb/source/Core/UserSettingsController.cpp b/lldb/source/Core/UserSettingsController.cpp index f9d6c68dfd3..60c2aa36b13 100644 --- a/lldb/source/Core/UserSettingsController.cpp +++ b/lldb/source/Core/UserSettingsController.cpp @@ -22,7 +22,7 @@ using namespace lldb_private; static void DumpSettingEntry (CommandInterpreter &interpreter, - StreamString &result_stream, + Stream &result_stream, const uint32_t max_len, const SettingEntry &entry) { @@ -802,7 +802,7 @@ UserSettingsController::PendingSettingsForInstance (const ConstString &instance_ } void -UserSettingsController::GetAllDefaultSettingValues (StreamString &result_stream) +UserSettingsController::GetAllDefaultSettingValues (Stream &result_stream) { std::string parent_prefix; BuildParentPrefix (parent_prefix); @@ -845,7 +845,7 @@ UserSettingsController::GetAllDefaultSettingValues (StreamString &result_stream) } void -UserSettingsController::GetAllPendingSettingValues (StreamString &result_stream) +UserSettingsController::GetAllPendingSettingValues (Stream &result_stream) { std::map<std::string, InstanceSettingsSP>::iterator pos; @@ -913,7 +913,7 @@ UserSettingsController::FindSettingsForInstance (const ConstString &instance_nam void UserSettingsController::GetAllInstanceVariableValues (CommandInterpreter &interpreter, - StreamString &result_stream) + Stream &result_stream) { std::map<std::string, InstanceSettings *>::iterator pos; std::string parent_prefix; @@ -1092,7 +1092,7 @@ void UserSettingsController::FindAllSettingsDescriptions (CommandInterpreter &interpreter, UserSettingsControllerSP root, std::string ¤t_prefix, - StreamString &result_stream, + Stream &result_stream, Error &err) { // Write out current prefix line. @@ -1156,7 +1156,7 @@ UserSettingsController::FindSettingsDescriptions (CommandInterpreter &interprete UserSettingsControllerSP root, std::string ¤t_prefix, const char *search_name, - StreamString &result_stream, + Stream &result_stream, Error &err) { Args names = UserSettingsController::BreakNameIntoPieces (search_name); @@ -1310,7 +1310,7 @@ UserSettingsController::SearchAllSettingsDescriptions (CommandInterpreter &inter UserSettingsControllerSP root, std::string ¤t_prefix, const char *search_word, - StreamString &result_stream) + Stream &result_stream) { if ((search_word == NULL) || (strlen (search_word) == 0)) return; @@ -1378,7 +1378,7 @@ void UserSettingsController::GetAllVariableValues (CommandInterpreter &interpreter, UserSettingsControllerSP root, std::string ¤t_prefix, - StreamString &result_stream, + Stream &result_stream, Error &err) { StreamString description; diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index b6cd3c73818..a6906709340 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -1518,6 +1518,8 @@ CommandInterpreter::HandleCommands (StringList &commands, { size_t num_lines = commands.GetSize(); CommandReturnObject tmp_result; + tmp_result.SetImmediateOutputStream (result.GetImmediateOutputStream ()); + tmp_result.SetImmediateErrorStream (result.GetImmediateErrorStream ()); // If we are going to continue past a "continue" then we need to run the commands synchronously. // Make sure you reset this value anywhere you return from the function. @@ -1554,7 +1556,7 @@ CommandInterpreter::HandleCommands (StringList &commands, if (print_results) { if (tmp_result.Succeeded()) - result.AppendMessageWithFormat("%s", tmp_result.GetOutputStream().GetData()); + result.AppendMessageWithFormat("%s", tmp_result.GetOutputData()); } if (!success || !tmp_result.Succeeded()) @@ -1572,7 +1574,7 @@ CommandInterpreter::HandleCommands (StringList &commands, result.AppendMessageWithFormat ("Command #%d '%s' failed with error: %s.\n", idx + 1, cmd, - tmp_result.GetErrorStream().GetData()); + tmp_result.GetErrorData()); } } diff --git a/lldb/source/Interpreter/CommandReturnObject.cpp b/lldb/source/Interpreter/CommandReturnObject.cpp index f634e3c7df5..3faf912bd7d 100644 --- a/lldb/source/Interpreter/CommandReturnObject.cpp +++ b/lldb/source/Interpreter/CommandReturnObject.cpp @@ -19,6 +19,8 @@ using namespace lldb; using namespace lldb_private; CommandReturnObject::CommandReturnObject () : + m_error_stream_string_sp (), + m_output_stream_string_sp (), m_output_stream (), m_error_stream (), m_status (eReturnStatusStarted), @@ -30,18 +32,6 @@ CommandReturnObject::~CommandReturnObject () { } -StreamString & -CommandReturnObject::GetOutputStream () -{ - return m_output_stream; -} - -StreamString & -CommandReturnObject::GetErrorStream () -{ - return m_error_stream; -} - void CommandReturnObject::AppendErrorWithFormat (const char *format, ...) { @@ -51,10 +41,9 @@ CommandReturnObject::AppendErrorWithFormat (const char *format, ...) sstrm.PrintfVarArg(format, args); va_end (args); - m_error_stream.Printf("error: %s", sstrm.GetData()); + GetErrorStream().Printf("error: %s", sstrm.GetData()); } - void CommandReturnObject::AppendMessageWithFormat (const char *format, ...) { @@ -64,7 +53,7 @@ CommandReturnObject::AppendMessageWithFormat (const char *format, ...) sstrm.PrintfVarArg(format, args); va_end (args); - m_output_stream.Printf("%s", sstrm.GetData()); + GetOutputStream().Printf("%s", sstrm.GetData()); } void @@ -76,7 +65,7 @@ CommandReturnObject::AppendWarningWithFormat (const char *format, ...) sstrm.PrintfVarArg(format, args); va_end (args); - m_error_stream.Printf("warning: %s", sstrm.GetData()); + GetErrorStream().Printf("warning: %s", sstrm.GetData()); } void @@ -84,7 +73,7 @@ CommandReturnObject::AppendMessage (const char *in_string, int len) { if (len < 0) len = ::strlen (in_string); - m_output_stream.Printf("%*.*s\n", len, len, in_string); + GetOutputStream().Printf("%*.*s\n", len, len, in_string); } void @@ -92,7 +81,7 @@ CommandReturnObject::AppendWarning (const char *in_string, int len) { if (len < 0) len = ::strlen (in_string); - m_error_stream.Printf("warning: %*.*s\n", len, len, in_string); + GetErrorStream().Printf("warning: %*.*s\n", len, len, in_string); } // Similar to AppendWarning, but do not prepend 'warning: ' to message, and @@ -103,7 +92,7 @@ CommandReturnObject::AppendRawWarning (const char *in_string, int len) { if (len < 0) len = ::strlen (in_string); - m_error_stream.Printf("%*.*s", len, len, in_string); + GetErrorStream().Printf("%*.*s", len, len, in_string); } void @@ -114,7 +103,7 @@ CommandReturnObject::AppendError (const char *in_string, int len) if (len < 0) len = ::strlen (in_string); - m_error_stream.Printf ("error: %*.*s\n", len, len, in_string); + GetErrorStream().Printf ("error: %*.*s\n", len, len, in_string); } // Similar to AppendError, but do not prepend 'Error: ' to message, and @@ -125,7 +114,7 @@ CommandReturnObject::AppendRawError (const char *in_string, int len) { if (len < 0) len = ::strlen (in_string); - m_error_stream.Printf ("%*.*s", len, len, in_string); + GetErrorStream().Printf ("%*.*s", len, len, in_string); } void @@ -156,8 +145,10 @@ CommandReturnObject::HasResult () void CommandReturnObject::Clear() { - m_output_stream.Clear(); - m_error_stream.Clear(); + if (m_output_stream_string_sp) + static_cast<StreamString *>(m_output_stream_string_sp.get())->Clear(); + if (m_error_stream_string_sp) + static_cast<StreamString *>(m_error_stream_string_sp.get())->Clear(); m_status = eReturnStatusStarted; } diff --git a/lldb/source/Symbol/SymbolContext.cpp b/lldb/source/Symbol/SymbolContext.cpp index a877aeae35f..9b7f20561b7 100644 --- a/lldb/source/Symbol/SymbolContext.cpp +++ b/lldb/source/Symbol/SymbolContext.cpp @@ -433,6 +433,26 @@ SymbolContext::FindTypeByName (const ConstString &name) const return return_value; } +//SymbolContext +//SymbolContext::CreateSymbolContextFromDescription (lldb::TargetSP &target_sp, +// const char *module, +// const char *comp_unit, +// const char *function, +// const char *block_spec +// const char *line_number, +// const char *symbol) +//{ +// SymbolContext sc; +// sc.target = target_sp; +// +// if (module != NULL && module[0] != '0') +// { +// +// } +// +// return sc; +//} + //---------------------------------------------------------------------- // // SymbolContextList diff --git a/lldb/test/abbreviation_tests/TestAbbreviations.py b/lldb/test/abbreviation_tests/TestAbbreviations.py index 1809ece4888..ca801f280de 100644 --- a/lldb/test/abbreviation_tests/TestAbbreviations.py +++ b/lldb/test/abbreviation_tests/TestAbbreviations.py @@ -84,7 +84,7 @@ class AbbreviationsTestCase(TestBase): self.expect("br s -f main.cpp -l 32", startstr = "Breakpoint created: 3: file ='main.cpp', line = 32, locations = 1") - self.runCmd("br co a -p 1 -o 'print frame'") + self.runCmd("br co a -s python 1 -o 'print frame'") self.expect("br co l 1", substrs = [ "Breakpoint 1:", "Breakpoint commands:", diff --git a/lldb/test/alias_tests/TestAliases.py b/lldb/test/alias_tests/TestAliases.py index 9cb26c44a9a..ccc27f77940 100644 --- a/lldb/test/alias_tests/TestAliases.py +++ b/lldb/test/alias_tests/TestAliases.py @@ -72,8 +72,8 @@ class AliasTestCase(TestBase): "2: name = 'sum', locations = 1", "3: file ='main.cpp', line = 32, locations = 1" ]) - self.runCmd ("bpa -p 1 -o 'print frame; print bp_loc'") - self.runCmd ("bpa -c 2 -o 'frame variable b'") + self.runCmd ("bpa -s python 1 -o 'print frame; print bp_loc'") + self.runCmd ("bpa -s command 2 -o 'frame variable b'") self.expect ("bpi -f", substrs = [ "Current breakpoints:", "1: name = 'foo', locations = 1", diff --git a/lldb/test/breakpoint_command/TestBreakpointCommand.py b/lldb/test/breakpoint_command/TestBreakpointCommand.py index 73e46b78adc..850aff5c42a 100644 --- a/lldb/test/breakpoint_command/TestBreakpointCommand.py +++ b/lldb/test/breakpoint_command/TestBreakpointCommand.py @@ -51,8 +51,8 @@ class BreakpointCommandTestCase(TestBase): self.line) # Now add callbacks for the breakpoints just created. - self.runCmd("breakpoint command add -c -o 'frame variable -t -s' 1") - self.runCmd("breakpoint command add -p -o 'here = open(\"output.txt\", \"w\"); print >> here, \"lldb\"; here.close()' 2") + self.runCmd("breakpoint command add -s command -o 'frame variable -t -s' 1") + self.runCmd("breakpoint command add -s python -o 'here = open(\"output.txt\", \"w\"); print >> here, \"lldb\"; here.close()' 2") # Check that the breakpoint commands are correctly set. @@ -145,7 +145,7 @@ class BreakpointCommandTestCase(TestBase): self.line) # Now add callbacks for the breakpoints just created. - self.runCmd("breakpoint command add -p -o 'here = open(\"output-2.txt\", \"w\"); print >> here, frame; print >> here, bp_loc; here.close()' 1") + self.runCmd("breakpoint command add -s python -o 'here = open(\"output-2.txt\", \"w\"); print >> here, frame; print >> here, bp_loc; here.close()' 1") # Remove 'output-2.txt' if it already exists. diff --git a/lldb/test/conditional_break/.lldb b/lldb/test/conditional_break/.lldb index 7330dcec50a..6774cfc7e89 100644 --- a/lldb/test/conditional_break/.lldb +++ b/lldb/test/conditional_break/.lldb @@ -3,5 +3,5 @@ breakpoint set -n c script import sys, os script sys.path.append(os.path.join(os.getcwd(), os.pardir)) script import conditional_break -breakpoint command add -p 1 -o "conditional_break.stop_if_called_from_a()" +breakpoint command add -s python 1 -o "conditional_break.stop_if_called_from_a()" diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp index 3cf542ff447..04e69e45e16 100644 --- a/lldb/tools/driver/Driver.cpp +++ b/lldb/tools/driver/Driver.cpp @@ -30,6 +30,7 @@ #include "lldb/API/SBHostOS.h" #include "lldb/API/SBListener.h" #include "lldb/API/SBSourceManager.h" +#include "lldb/API/SBStream.h" #include "lldb/API/SBTarget.h" #include "lldb/API/SBThread.h" #include "lldb/API/SBProcess.h" @@ -894,11 +895,12 @@ Driver::HandleIOEvent (const SBEvent &event) if (command_string == NULL) command_string = ""; SBCommandReturnObject result; - if (m_debugger.GetCommandInterpreter().HandleCommand (command_string, result, true) != lldb::eReturnStatusQuit) - { - m_io_channel_ap->ErrWrite (result.GetError(), result.GetErrorSize()); - m_io_channel_ap->OutWrite (result.GetOutput(), result.GetOutputSize()); - } + result.SetImmediateOutputFile (m_debugger.GetOutputFileHandle()); + result.SetImmediateErrorFile (m_debugger.GetErrorFileHandle()); + + // We've set the result to dump immediately. + m_debugger.GetCommandInterpreter().HandleCommand (command_string, result, true); + // We are done getting and running our command, we can now clear the // m_waiting_for_command so we can get another one. m_waiting_for_command = false; |

