Hi abidh, clayborg,

Previously lldb-mi contains a stub for that but it didn't work and all 
CommanInterpreter's events were ignored.
This commit adds a handling of CommandInterpreter's events in lldb-mi.

Steps:
# Add SBBroadcaster::CheckInWithManager
# Fix CMICmnLLDBDebugger::InitSBListener
# Add SBCommandInterpreter::EventIsCommandInterpreterEvent
# Exit on lldb::SBCommandInterpreter::eBroadcastBitQuitCommandReceived

All tests pass on OS X.

In further we can remove "quit" hack in lldb-mi.

http://reviews.llvm.org/D8382

Files:
  include/lldb/API/SBBroadcaster.h
  include/lldb/API/SBCommandInterpreter.h
  source/API/SBBroadcaster.cpp
  source/API/SBCommandInterpreter.cpp
  tools/lldb-mi/MICmnLLDBDebugger.cpp
  tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
Index: include/lldb/API/SBBroadcaster.h
===================================================================
--- include/lldb/API/SBBroadcaster.h
+++ include/lldb/API/SBBroadcaster.h
@@ -55,6 +55,9 @@
     bool
     RemoveListener (const lldb::SBListener &listener, uint32_t event_mask = UINT32_MAX);
 
+    void
+    CheckInWithManager ();
+
     // This comparison is checking if the internal opaque pointer value
     // is equal to that in "rhs".
     bool
Index: include/lldb/API/SBCommandInterpreter.h
===================================================================
--- include/lldb/API/SBCommandInterpreter.h
+++ include/lldb/API/SBCommandInterpreter.h
@@ -94,6 +94,9 @@
     
     static const char *
     GetArgumentDescriptionAsCString (const lldb::CommandArgumentType arg_type);
+
+    static bool
+    EventIsCommandInterpreterEvent (const lldb::SBEvent &event);
     
     bool
     IsValid() const;
Index: source/API/SBBroadcaster.cpp
===================================================================
--- source/API/SBBroadcaster.cpp
+++ source/API/SBBroadcaster.cpp
@@ -152,6 +152,13 @@
     return false;
 }
 
+void
+SBBroadcaster::CheckInWithManager ()
+{
+    if (m_opaque_ptr)
+        return m_opaque_ptr->CheckInWithManager ();
+}
+
 Broadcaster *
 SBBroadcaster::get () const
 {
Index: source/API/SBCommandInterpreter.cpp
===================================================================
--- source/API/SBCommandInterpreter.cpp
+++ source/API/SBCommandInterpreter.cpp
@@ -20,6 +20,7 @@
 #include "lldb/API/SBBroadcaster.h"
 #include "lldb/API/SBCommandReturnObject.h"
 #include "lldb/API/SBCommandInterpreter.h"
+#include "lldb/API/SBEvent.h"
 #include "lldb/API/SBExecutionContext.h"
 #include "lldb/API/SBProcess.h"
 #include "lldb/API/SBTarget.h"
@@ -548,6 +549,12 @@
 }
 
 bool
+SBCommandInterpreter::EventIsCommandInterpreterEvent (const lldb::SBEvent &event)
+{
+    return strcmp (event.GetBroadcasterClass(), SBCommandInterpreter::GetBroadcasterClass()) == 0;
+}
+
+bool
 SBCommandInterpreter::SetCommandOverrideCallback (const char *command_name,
                                                   lldb::CommandOverrideCallback callback,
                                                   void *baton)
Index: tools/lldb-mi/MICmnLLDBDebugger.cpp
===================================================================
--- tools/lldb-mi/MICmnLLDBDebugger.cpp
+++ tools/lldb-mi/MICmnLLDBDebugger.cpp
@@ -297,6 +297,7 @@
                 lldb::SBCommandInterpreter::eBroadcastBitAsynchronousOutputData |
                 lldb::SBCommandInterpreter::eBroadcastBitAsynchronousErrorData;
     bOk = bOk && RegisterForEvent(strDbgId, CMIUtilString(lldb::SBCommandInterpreter::GetBroadcasterClass()), eventMask);
+    m_lldbDebugger.GetCommandInterpreter().GetBroadcaster().CheckInWithManager();
 
     return bOk;
 }
Index: tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
===================================================================
--- tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
+++ tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
@@ -28,6 +28,7 @@
 #include "MICmnLLDBDebuggerHandleEvents.h"
 #include "MICmnResources.h"
 #include "MICmnLog.h"
+#include "MICmnLLDBDebugger.h"
 #include "MICmnLLDBDebugSessionInfo.h"
 #include "MICmnMIResultRecord.h"
 #include "MICmnMIValueConst.h"
@@ -146,6 +147,11 @@
         vrbHandledEvent = true;
         bOk = HandleEventSBTarget(vEvent);
     }
+    else if (lldb::SBCommandInterpreter::EventIsCommandInterpreterEvent(vEvent))
+    {
+        vrbHandledEvent = true;
+        bOk = HandleEventSBCommandInterpreter(vEvent);
+    }
 
     return bOk;
 }
@@ -756,8 +762,12 @@
             pEventType = "eBroadcastBitResetPrompt";
             break;
         case lldb::SBCommandInterpreter::eBroadcastBitQuitCommandReceived:
+        {
             pEventType = "eBroadcastBitQuitCommandReceived";
+            const bool bForceExit = true;
+            CMICmnLLDBDebugger::Instance().GetDriver().SetExitApplicationFlag(bForceExit);
             break;
+        }
         case lldb::SBCommandInterpreter::eBroadcastBitAsynchronousOutputData:
             pEventType = "eBroadcastBitAsynchronousOutputData";
             break;
_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits

Reply via email to