Index: include/lldb/API/SBProcess.h =================================================================== --- include/lldb/API/SBProcess.h +++ include/lldb/API/SBProcess.h @@ -264,6 +264,9 @@ static bool EventIsProcessEvent (const lldb::SBEvent &event); + lldb::SBEvent + CreateProcessEventStateChanged (const lldb::StateType state) const; + lldb::SBBroadcaster GetBroadcaster () const; Index: source/API/SBProcess.cpp =================================================================== --- source/API/SBProcess.cpp +++ source/API/SBProcess.cpp @@ -1004,6 +1004,14 @@ return event.GetBroadcasterClass() == SBProcess::GetBroadcasterClass(); } +SBEvent +SBProcess::CreateProcessEventStateChanged (const lldb::StateType state) const +{ + EventData *event_data = new Process::ProcessEventData(GetSP(), state); + EventSP event_sp(new Event(Process::eBroadcastBitStateChanged, event_data)); + return SBEvent(event_sp); +} + SBBroadcaster SBProcess::GetBroadcaster () const { Index: source/Target/Target.cpp =================================================================== --- source/Target/Target.cpp +++ source/Target/Target.cpp @@ -2610,7 +2610,6 @@ { if (synchronous_execution || launch_info.GetFlags().Test(eLaunchFlagStopAtEntry) == false) { - EventSP event_sp; ListenerSP hijack_listener_sp (launch_info.GetHijackListener()); if (!hijack_listener_sp) { @@ -2619,7 +2618,7 @@ m_process_sp->HijackProcessEvents(hijack_listener_sp.get()); } - StateType state = m_process_sp->WaitForProcessToStop (NULL, &event_sp, false, hijack_listener_sp.get(), NULL); + StateType state = m_process_sp->WaitForProcessToStop (NULL, NULL, false, hijack_listener_sp.get(), NULL); if (state == eStateStopped) { @@ -2650,14 +2649,6 @@ error = error2; } } - else - { - assert(synchronous_execution && launch_info.GetFlags().Test(eLaunchFlagStopAtEntry)); - - // Target was stopped at entry as was intended. Need to notify the listeners about it. - m_process_sp->RestoreProcessEvents(); - m_process_sp->HandlePrivateEvent(event_sp); - } } else if (state == eStateExited) { Index: test/tools/lldb-mi/startup_options/TestMiStartupOptions.py =================================================================== --- test/tools/lldb-mi/startup_options/TestMiStartupOptions.py +++ test/tools/lldb-mi/startup_options/TestMiStartupOptions.py @@ -143,6 +143,7 @@ # After '-exec-run' self.expect("-exec-run") self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") # After '-break-insert main.cpp:BP_return' line = line_number('main.cpp', '//BP_return') @@ -152,6 +153,7 @@ # After '-exec-continue' self.expect("-exec-continue") self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") # Test that lldb-mi is ready after execution of --source start_script self.expect(self.child_prompt, exactly = True) @@ -184,6 +186,7 @@ # After '-exec-run' self.expect("-exec-run") self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") # After '-break-insert main.cpp:BP_return' line = line_number('main.cpp', '//BP_return') @@ -193,6 +196,7 @@ # After '-exec-continue' self.expect("-exec-continue") self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") # After '-data-evaluate-expression a' self.expect("-data-evaluate-expression a") Index: tools/lldb-mi/MICmdCmdGdbSet.cpp =================================================================== --- tools/lldb-mi/MICmdCmdGdbSet.cpp +++ tools/lldb-mi/MICmdCmdGdbSet.cpp @@ -16,6 +16,7 @@ #include "MICmdArgValString.h" #include "MICmdArgValListOfN.h" #include "MICmdArgValOptionLong.h" +#include "MICmnLLDBDebugger.h" #include "MICmnLLDBDebugSessionInfo.h" // Instantiations: @@ -253,6 +254,10 @@ CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance()); rSessionInfo.GetDebugger().SetAsync(bAsyncMode); + if (!bAsyncMode) + // Initialize CMICmnLLDBDebugger to generate *stopped in sync mode + CMICmnLLDBDebugger::Instance().PrepareToGenerateStoppedEvent(); + return MIstatus::success; } Index: tools/lldb-mi/MICmnLLDBDebugger.h =================================================================== --- tools/lldb-mi/MICmnLLDBDebugger.h +++ tools/lldb-mi/MICmnLLDBDebugger.h @@ -50,6 +50,8 @@ lldb::SBDebugger &GetTheDebugger(void); lldb::SBListener &GetTheListener(void); void WaitForHandleEvent(void); + void PrepareToGenerateStoppedEvent(void); + void GenerateStoppedEventIfNeeded(void); // MI Commands can use these functions to listen for events they require bool RegisterForEvent(const CMIUtilString &vClientName, const CMIUtilString &vBroadcasterClass, const MIuint vEventMask); @@ -110,4 +112,5 @@ MapIdToEventMask_t m_mapIdToEventMask; std::mutex m_mutexEventQueue; std::condition_variable m_conditionEventQueueEmpty; + uint32_t m_nLastStopId; }; Index: tools/lldb-mi/MICmnLLDBDebugger.cpp =================================================================== --- tools/lldb-mi/MICmnLLDBDebugger.cpp +++ tools/lldb-mi/MICmnLLDBDebugger.cpp @@ -243,6 +243,31 @@ m_conditionEventQueueEmpty.wait(lock); } +void +CMICmnLLDBDebugger::PrepareToGenerateStoppedEvent(void) +{ + const bool include_expression_stops = false; + m_nLastStopId = CMICmnLLDBDebugSessionInfo::Instance().GetProcess().GetStopID(include_expression_stops); +} + +void +CMICmnLLDBDebugger::GenerateStoppedEventIfNeeded(void) +{ + CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance()); + if (!rSessionInfo.GetDebugger().GetAsync()) + { + lldb::SBProcess process = rSessionInfo.GetProcess(); + const bool include_expression_stops = false; + const uint32_t nStopId = process.GetStopID(include_expression_stops); + if (nStopId != m_nLastStopId) + { + m_nLastStopId = nStopId; + lldb::SBEvent event = process.CreateProcessEventStateChanged(lldb::eStateStopped); + process.GetBroadcaster().BroadcastEvent(event); + } + } +} + //++ ------------------------------------------------------------------------------------ // Details: Initialize the LLDB Debugger object. // Type: Method. Index: tools/lldb-mi/MIDriver.cpp =================================================================== --- tools/lldb-mi/MIDriver.cpp +++ tools/lldb-mi/MIDriver.cpp @@ -828,6 +828,8 @@ if (bOk && !bCmdYesValid) bOk = InterpretCommandFallThruDriver(vTextLine, bCmdYesValid); + CMICmnLLDBDebugger::Instance().GenerateStoppedEventIfNeeded(); + return bOk; }