[Lldb-commits] [lldb] r159273 - in /lldb/trunk: include/lldb/API/SBCommandReturnObject.h scripts/Python/interface/SBCommandReturnObject.i source/API/SBCommandReturnObject.cpp source/Commands/CommandObjectCommands.cpp

Jim Ingham jingham at apple.com
Wed Jun 27 10:25:36 PDT 2012


Author: jingham
Date: Wed Jun 27 12:25:36 2012
New Revision: 159273

URL: http://llvm.org/viewvc/llvm-project?rev=159273&view=rev
Log:
Make a way to set the result status for Python defined commands, and don't overwrite the status of the result if
the python command has set it.

Modified:
    lldb/trunk/include/lldb/API/SBCommandReturnObject.h
    lldb/trunk/scripts/Python/interface/SBCommandReturnObject.i
    lldb/trunk/source/API/SBCommandReturnObject.cpp
    lldb/trunk/source/Commands/CommandObjectCommands.cpp

Modified: lldb/trunk/include/lldb/API/SBCommandReturnObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCommandReturnObject.h?rev=159273&r1=159272&r2=159273&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBCommandReturnObject.h (original)
+++ lldb/trunk/include/lldb/API/SBCommandReturnObject.h Wed Jun 27 12:25:36 2012
@@ -61,6 +61,9 @@
 
     lldb::ReturnStatus
     GetStatus();
+    
+    void
+    SetStatus (lldb::ReturnStatus status);
 
     bool
     Succeeded ();

Modified: lldb/trunk/scripts/Python/interface/SBCommandReturnObject.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBCommandReturnObject.i?rev=159273&r1=159272&r2=159273&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBCommandReturnObject.i (original)
+++ lldb/trunk/scripts/Python/interface/SBCommandReturnObject.i Wed Jun 27 12:25:36 2012
@@ -50,6 +50,9 @@
     void
     Clear();
 
+    void
+    SetStatus (lldb::ReturnStatus status);
+
     lldb::ReturnStatus
     GetStatus();
 

Modified: lldb/trunk/source/API/SBCommandReturnObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommandReturnObject.cpp?rev=159273&r1=159272&r2=159273&view=diff
==============================================================================
--- lldb/trunk/source/API/SBCommandReturnObject.cpp (original)
+++ lldb/trunk/source/API/SBCommandReturnObject.cpp Wed Jun 27 12:25:36 2012
@@ -160,6 +160,13 @@
     return lldb::eReturnStatusInvalid;
 }
 
+void
+SBCommandReturnObject::SetStatus(lldb::ReturnStatus status)
+{
+    if (m_opaque_ap.get())
+         m_opaque_ap->SetStatus(status);
+}
+
 bool
 SBCommandReturnObject::Succeeded ()
 {

Modified: lldb/trunk/source/Commands/CommandObjectCommands.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCommands.cpp?rev=159273&r1=159272&r2=159273&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectCommands.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectCommands.cpp Wed Jun 27 12:25:36 2012
@@ -1214,6 +1214,8 @@
         
         Error error;
         
+        result.SetStatus(eReturnStatusInvalid);
+        
         if (!scripter || scripter->RunScriptBasedCommand(m_function_name.c_str(),
                                                          raw_command_line,
                                                          m_synchro,
@@ -1224,7 +1226,16 @@
             result.SetStatus(eReturnStatusFailed);
         }
         else
-            result.SetStatus(eReturnStatusSuccessFinishNoResult);
+        {
+            // Don't change the status if the command already set it...
+            if (result.GetStatus() == eReturnStatusInvalid)
+            {
+                if (result.GetOutputData() == NULL || result.GetOutputData()[0] == '\0')
+                    result.SetStatus(eReturnStatusSuccessFinishNoResult);
+                else
+                    result.SetStatus(eReturnStatusSuccessFinishResult);
+            }
+        }
         
         return result.Succeeded();
     }





More information about the lldb-commits mailing list