Index: source/Target/Process.cpp =================================================================== --- source/Target/Process.cpp +++ source/Target/Process.cpp @@ -3121,6 +3121,11 @@ StartPrivateStateThread (); m_stop_info_override_callback = GetTarget().GetArchitecture().GetStopInfoOverrideCallback(); + + // Target was stopped at entry as was intended. Need to notify the listeners + // about it. + if (launch_info.GetFlags().Test(eLaunchFlagStopAtEntry) == true) + m_private_state_broadcaster.BroadcastEvent(event_sp); } else if (state == eStateExited) { Index: test/tools/lldb-mi/TestMiNotification.py =================================================================== --- test/tools/lldb-mi/TestMiNotification.py +++ test/tools/lldb-mi/TestMiNotification.py @@ -0,0 +1,69 @@ +""" +Test that the lldb-mi driver nofities user properly. +""" + +import lldbmi_testcase +from lldbtest import * +import unittest2 + +class MiNotificationTestCase(lldbmi_testcase.MiTestCaseBase): + + @lldbmi_test + @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows") + def test_lldbmi_stopped_when_stopatentry_local(self): + """Test that 'lldb-mi --interpreter' notifies after it was stopped on entry (local).""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run with stop-at-entry flag + self.runCmd("-interpreter-exec command \"process launch -s\"") + self.expect("\^done") + + # Test that *stopped is printed + self.expect("\*stopped,reason=\"signal-received\",signal=\"17\",stopped-threads=\"all\"") #FIXME add thread-id + + @lldbmi_test + @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows") + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_lldbmi_stopped_when_stopatentry_remote(self): + """Test that 'lldb-mi --interpreter' notifies after it was stopped on entry (remote).""" + + # Prepare debugserver + import lldbgdbserverutils + debugserver_exe = lldbgdbserverutils.get_debugserver_exe() + if not debugserver_exe: + raise Exception("debugserver not found") + hostname = "localhost" + import random + port = 12000 + random.randint(0,3999) # the same as GdbRemoteTestCaseBase.get_next_port + import pexpect + debugserver_child = pexpect.spawn("%s %s:%d" % (debugserver_exe, hostname, port)) + + self.spawnLldbMi(args = None) + + # Connect to debugserver + self.runCmd("-interpreter-exec command \"platform select remote-macosx --sysroot /\"") + self.expect("\^done") + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + self.runCmd("-interpreter-exec command \"process connect connect://%s:%d\"" % (hostname, port)) + self.expect("\^done") + + try: + # Run with stop-at-entry flag + self.runCmd("-interpreter-exec command \"process launch -s\"") + self.expect("\^done") + + # Test that *stopped is printed + self.expect("\*stopped,reason=\"signal-received\",signal=\"17\",stopped-threads=\"all\"") #FIXME add thread-id + + finally: + # Clean up + debugserver_child.terminate(force = True) + +if __name__ == '__main__': + unittest2.main()