[Lldb-commits] [lldb] r126015 - in /lldb/trunk: include/lldb/API/ include/lldb/Core/ include/lldb/Interpreter/ include/lldb/Symbol/ lldb.xcodeproj/ lldb.xcodeproj/xcshareddata/xcschemes/ source/API/ source/Commands/ source/Core/ source/Interpreter/ source/Symbol/ test/abbreviation_tests/ test/alias_tests/ test/breakpoint_command/ test/conditional_break/ tools/driver/

Jim Ingham jingham at apple.com
Fri Feb 18 18:53:10 PST 2011


Author: jingham
Date: Fri Feb 18 20:53:09 2011
New Revision: 126015

URL: http://llvm.org/viewvc/llvm-project?rev=126015&view=rev
Log:
- Changed all the places where CommandObjectReturn was exporting a StreamString to just exporting
a Stream, and then added GetOutputData & GetErrorData to get the accumulated data.
- Added a StreamTee that will tee output to two provided lldb::StreamSP's.
- Made the CommandObjectReturn use this so you can Tee the results immediately to
the debuggers output file, as well as saving up the results to return when the command
is done executing.
- HandleCommands now uses this so that if you have a set of commands that continue the target
you will see the commands come out as they are processed.
- The Driver now uses this to output the command results as you go, which makes the interface
more reactive seeming.


Added:
    lldb/trunk/include/lldb/Core/StreamTee.h
Modified:
    lldb/trunk/include/lldb/API/SBCommandReturnObject.h
    lldb/trunk/include/lldb/API/SBStream.h
    lldb/trunk/include/lldb/Core/UserSettingsController.h
    lldb/trunk/include/lldb/Interpreter/CommandReturnObject.h
    lldb/trunk/include/lldb/Symbol/SymbolContext.h
    lldb/trunk/lldb.xcodeproj/project.pbxproj
    lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme
    lldb/trunk/source/API/SBCommandReturnObject.cpp
    lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
    lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp
    lldb/trunk/source/Commands/CommandObjectMultiword.cpp
    lldb/trunk/source/Commands/CommandObjectProcess.cpp
    lldb/trunk/source/Commands/CommandObjectRegister.cpp
    lldb/trunk/source/Commands/CommandObjectThread.cpp
    lldb/trunk/source/Commands/CommandObjectVersion.cpp
    lldb/trunk/source/Core/UserSettingsController.cpp
    lldb/trunk/source/Interpreter/CommandInterpreter.cpp
    lldb/trunk/source/Interpreter/CommandReturnObject.cpp
    lldb/trunk/source/Symbol/SymbolContext.cpp
    lldb/trunk/test/abbreviation_tests/TestAbbreviations.py
    lldb/trunk/test/alias_tests/TestAliases.py
    lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py
    lldb/trunk/test/conditional_break/.lldb
    lldb/trunk/tools/driver/Driver.cpp

Modified: lldb/trunk/include/lldb/API/SBCommandReturnObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCommandReturnObject.h?rev=126015&r1=126014&r2=126015&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBCommandReturnObject.h (original)
+++ lldb/trunk/include/lldb/API/SBCommandReturnObject.h Fri Feb 18 20:53:09 2011
@@ -69,7 +69,13 @@
 
     bool
     GetDescription (lldb::SBStream &description);
-
+    
+    void
+    SetImmediateOutputFile (FILE *fh);
+    
+    void
+    SetImmediateErrorFile (FILE *fh);
+    
 protected:
     friend class SBCommandInterpreter;
     friend class SBOptions;

Modified: lldb/trunk/include/lldb/API/SBStream.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBStream.h?rev=126015&r1=126014&r2=126015&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBStream.h (original)
+++ lldb/trunk/include/lldb/API/SBStream.h Fri Feb 18 20:53:09 2011
@@ -21,7 +21,7 @@
 public:
 
     SBStream ();
-
+    
     ~SBStream ();
 
     bool
@@ -74,6 +74,7 @@
     friend class SBTarget;
     friend class SBThread;
     friend class SBValue;
+    friend class SBCommandReturnObject;
 
 #ifndef SWIG
 

Added: lldb/trunk/include/lldb/Core/StreamTee.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/StreamTee.h?rev=126015&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Core/StreamTee.h (added)
+++ lldb/trunk/include/lldb/Core/StreamTee.h Fri Feb 18 20:53:09 2011
@@ -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_

Modified: lldb/trunk/include/lldb/Core/UserSettingsController.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/UserSettingsController.h?rev=126015&r1=126014&r2=126015&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/UserSettingsController.h (original)
+++ lldb/trunk/include/lldb/Core/UserSettingsController.h Fri Feb 18 20:53:09 2011
@@ -137,7 +137,7 @@
     FindAllSettingsDescriptions (CommandInterpreter &interpreter,
                                  lldb::UserSettingsControllerSP root, 
                                  std::string &current_prefix, 
-                                 StreamString &result_stream,
+                                 Stream &result_stream,
                                  Error &err);
 
     static void
@@ -145,7 +145,7 @@
                               lldb::UserSettingsControllerSP root, 
                               std::string &current_prefix, 
                               const char *search_name,
-                              StreamString &result_stream,
+                              Stream &result_stream,
                               Error &err);
     
     static void
@@ -153,13 +153,13 @@
                                    lldb::UserSettingsControllerSP root,
                                    std::string &current_prefix,
                                    const char *search_word,
-                                   StreamString &result_stream);
+                                   Stream &result_stream);
 
     static void
     GetAllVariableValues (CommandInterpreter &interpreter,
                           lldb::UserSettingsControllerSP root,
                           std::string &current_prefix,
-                          StreamString &result_stream,
+                          Stream &result_stream,
                           Error &err);
 
     static int
@@ -289,14 +289,14 @@
     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, 

Modified: lldb/trunk/include/lldb/Interpreter/CommandReturnObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandReturnObject.h?rev=126015&r1=126014&r2=126015&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/CommandReturnObject.h (original)
+++ lldb/trunk/include/lldb/Interpreter/CommandReturnObject.h Fri Feb 18 20:53:09 2011
@@ -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,15 +28,89 @@
 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();
 
@@ -79,8 +155,11 @@
     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;
 };

Modified: lldb/trunk/include/lldb/Symbol/SymbolContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolContext.h?rev=126015&r1=126014&r2=126015&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/SymbolContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/SymbolContext.h Fri Feb 18 20:53:09 2011
@@ -233,6 +233,15 @@
     //------------------------------------------------------------------
     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

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=126015&r1=126014&r2=126015&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Fri Feb 18 20:53:09 2011
@@ -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;
 		};

Modified: lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme?rev=126015&r1=126014&r2=126015&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme (original)
+++ lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme Fri Feb 18 20:53:09 2011
@@ -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>

Modified: lldb/trunk/source/API/SBCommandReturnObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommandReturnObject.cpp?rev=126015&r1=126014&r2=126015&view=diff
==============================================================================
--- lldb/trunk/source/API/SBCommandReturnObject.cpp (original)
+++ lldb/trunk/source/API/SBCommandReturnObject.cpp Fri Feb 18 20:53:09 2011
@@ -63,9 +63,9 @@
     {
         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 @@
     {
         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 @@
 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 @@
 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 @@
 
     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);
+}

Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=126015&r1=126014&r2=126015&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Fri Feb 18 20:53:09 2011
@@ -34,7 +34,7 @@
 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 @@
                                                        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 @@
                                                        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 @@
                         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 @@
     
     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 @@
         return true;
     }
 
-    StreamString &output_stream = result.GetOutputStream();
+    Stream &output_stream = result.GetOutputStream();
 
     if (args.GetArgumentCount() == 0)
     {
@@ -1212,7 +1212,7 @@
 
     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();

Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp?rev=126015&r1=126014&r2=126015&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp Fri Feb 18 20:53:09 2011
@@ -790,15 +790,19 @@
     
     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 @@
                                                              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;

Modified: lldb/trunk/source/Commands/CommandObjectMultiword.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMultiword.cpp?rev=126015&r1=126014&r2=126015&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectMultiword.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectMultiword.cpp Fri Feb 18 20:53:09 2011
@@ -187,7 +187,7 @@
     // 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;

Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=126015&r1=126014&r2=126015&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Fri Feb 18 20:53:09 2011
@@ -1483,7 +1483,7 @@
         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)

Modified: lldb/trunk/source/Commands/CommandObjectRegister.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectRegister.cpp?rev=126015&r1=126014&r2=126015&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectRegister.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectRegister.cpp Fri Feb 18 20:53:09 2011
@@ -65,7 +65,7 @@
         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 ();

Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.cpp?rev=126015&r1=126014&r2=126015&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectThread.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectThread.cpp Fri Feb 18 20:53:09 2011
@@ -131,7 +131,7 @@
         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 @@
         CommandReturnObject &result
     )
     {
-        StreamString &strm = result.GetOutputStream();
+        Stream &strm = result.GetOutputStream();
         result.SetStatus (eReturnStatusSuccessFinishNoResult);
         ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext());
         if (exe_ctx.process)

Modified: lldb/trunk/source/Commands/CommandObjectVersion.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectVersion.cpp?rev=126015&r1=126014&r2=126015&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectVersion.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectVersion.cpp Fri Feb 18 20:53:09 2011
@@ -40,8 +40,7 @@
     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;
 }

Modified: lldb/trunk/source/Core/UserSettingsController.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/UserSettingsController.cpp?rev=126015&r1=126014&r2=126015&view=diff
==============================================================================
--- lldb/trunk/source/Core/UserSettingsController.cpp (original)
+++ lldb/trunk/source/Core/UserSettingsController.cpp Fri Feb 18 20:53:09 2011
@@ -22,7 +22,7 @@
 
 static void
 DumpSettingEntry (CommandInterpreter &interpreter, 
-                  StreamString &result_stream,
+                  Stream &result_stream,
                   const uint32_t max_len, 
                   const SettingEntry &entry)
 {
@@ -802,7 +802,7 @@
 }
 
 void
-UserSettingsController::GetAllDefaultSettingValues (StreamString &result_stream)
+UserSettingsController::GetAllDefaultSettingValues (Stream &result_stream)
 {
     std::string parent_prefix;
     BuildParentPrefix (parent_prefix);
@@ -845,7 +845,7 @@
 }
 
 void
-UserSettingsController::GetAllPendingSettingValues (StreamString &result_stream)
+UserSettingsController::GetAllPendingSettingValues (Stream &result_stream)
 {
     std::map<std::string, InstanceSettingsSP>::iterator pos;
 
@@ -913,7 +913,7 @@
 
 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 @@
 UserSettingsController::FindAllSettingsDescriptions (CommandInterpreter &interpreter,
                                                      UserSettingsControllerSP root, 
                                                      std::string &current_prefix, 
-                                                     StreamString &result_stream,
+                                                     Stream &result_stream,
                                                      Error &err)
 {
     // Write out current prefix line.
@@ -1156,7 +1156,7 @@
                                                   UserSettingsControllerSP root,
                                                   std::string &current_prefix,
                                                   const char *search_name,
-                                                  StreamString &result_stream,
+                                                  Stream &result_stream,
                                                   Error &err)
 {
     Args names = UserSettingsController::BreakNameIntoPieces (search_name);
@@ -1310,7 +1310,7 @@
                                                        UserSettingsControllerSP root,
                                                        std::string &current_prefix,
                                                        const char *search_word,
-                                                       StreamString &result_stream)
+                                                       Stream &result_stream)
 {
     if ((search_word == NULL) || (strlen (search_word) == 0))
         return;
@@ -1378,7 +1378,7 @@
 UserSettingsController::GetAllVariableValues (CommandInterpreter &interpreter,
                                               UserSettingsControllerSP root,
                                               std::string &current_prefix,
-                                              StreamString &result_stream,
+                                              Stream &result_stream,
                                               Error &err)
 {
     StreamString description;

Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=126015&r1=126014&r2=126015&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Fri Feb 18 20:53:09 2011
@@ -1518,6 +1518,8 @@
 {
     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 @@
         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 @@
                 result.AppendMessageWithFormat ("Command #%d '%s' failed with error: %s.\n", 
                                                 idx + 1, 
                                                 cmd, 
-                                                tmp_result.GetErrorStream().GetData());
+                                                tmp_result.GetErrorData());
             }
         }
         

Modified: lldb/trunk/source/Interpreter/CommandReturnObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandReturnObject.cpp?rev=126015&r1=126014&r2=126015&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandReturnObject.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandReturnObject.cpp Fri Feb 18 20:53:09 2011
@@ -19,6 +19,8 @@
 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 @@
 {
 }
 
-StreamString &
-CommandReturnObject::GetOutputStream ()
-{
-    return m_output_stream;
-}
-
-StreamString &
-CommandReturnObject::GetErrorStream ()
-{
-    return m_error_stream;
-}
-
 void
 CommandReturnObject::AppendErrorWithFormat (const char *format, ...)
 {
@@ -51,10 +41,9 @@
     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 @@
     sstrm.PrintfVarArg(format, args);
     va_end (args);
 
-    m_output_stream.Printf("%s", sstrm.GetData());
+    GetOutputStream().Printf("%s", sstrm.GetData());
 }
 
 void
@@ -76,7 +65,7 @@
     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 @@
 {
     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 @@
 {
     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 @@
 {
     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 @@
 
     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 @@
 {
     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 @@
 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;
 }
 

Modified: lldb/trunk/source/Symbol/SymbolContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolContext.cpp?rev=126015&r1=126014&r2=126015&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/SymbolContext.cpp (original)
+++ lldb/trunk/source/Symbol/SymbolContext.cpp Fri Feb 18 20:53:09 2011
@@ -433,6 +433,26 @@
     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

Modified: lldb/trunk/test/abbreviation_tests/TestAbbreviations.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/abbreviation_tests/TestAbbreviations.py?rev=126015&r1=126014&r2=126015&view=diff
==============================================================================
--- lldb/trunk/test/abbreviation_tests/TestAbbreviations.py (original)
+++ lldb/trunk/test/abbreviation_tests/TestAbbreviations.py Fri Feb 18 20:53:09 2011
@@ -84,7 +84,7 @@
         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:",

Modified: lldb/trunk/test/alias_tests/TestAliases.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/alias_tests/TestAliases.py?rev=126015&r1=126014&r2=126015&view=diff
==============================================================================
--- lldb/trunk/test/alias_tests/TestAliases.py (original)
+++ lldb/trunk/test/alias_tests/TestAliases.py Fri Feb 18 20:53:09 2011
@@ -72,8 +72,8 @@
                                  "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",

Modified: lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py?rev=126015&r1=126014&r2=126015&view=diff
==============================================================================
--- lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py (original)
+++ lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py Fri Feb 18 20:53:09 2011
@@ -51,8 +51,8 @@
                         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 @@
                         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.
 

Modified: lldb/trunk/test/conditional_break/.lldb
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/conditional_break/.lldb?rev=126015&r1=126014&r2=126015&view=diff
==============================================================================
--- lldb/trunk/test/conditional_break/.lldb (original)
+++ lldb/trunk/test/conditional_break/.lldb Fri Feb 18 20:53:09 2011
@@ -3,5 +3,5 @@
 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()"
 

Modified: lldb/trunk/tools/driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=126015&r1=126014&r2=126015&view=diff
==============================================================================
--- lldb/trunk/tools/driver/Driver.cpp (original)
+++ lldb/trunk/tools/driver/Driver.cpp Fri Feb 18 20:53:09 2011
@@ -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 @@
         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;





More information about the lldb-commits mailing list