[Lldb-commits] [PATCH] Fix Target::Launch in case of synchronous execution

Ilia K ki.stfu at gmail.com
Mon Mar 23 06:07:51 PDT 2015


Hi jingham, clayborg,

This patch fixes Target::Launch in case of synchronous execution.

http://reviews.llvm.org/D8541

Files:
  source/Target/Target.cpp

Index: source/Target/Target.cpp
===================================================================
--- source/Target/Target.cpp
+++ source/Target/Target.cpp
@@ -2573,41 +2573,58 @@
 
     if (error.Success())
     {
-        if (launch_info.GetFlags().Test(eLaunchFlagStopAtEntry) == false)
+        if (synchronous_execution || launch_info.GetFlags().Test(eLaunchFlagStopAtEntry) == false)
         {
+            EventSP event_sp;
             ListenerSP hijack_listener_sp (launch_info.GetHijackListener());
 
-            StateType state = m_process_sp->WaitForProcessToStop (NULL, NULL, false, hijack_listener_sp.get(), NULL);
+            StateType state = m_process_sp->WaitForProcessToStop (NULL, &event_sp, false, hijack_listener_sp.get(), NULL);
             
             if (state == eStateStopped)
             {
-                if (!synchronous_execution)
-                    m_process_sp->RestoreProcessEvents ();
-
-                error = m_process_sp->PrivateResume();
-
-                if (error.Success())
+                if (launch_info.GetFlags().Test(eLaunchFlagStopAtEntry) == false)
                 {
-                    // there is a race condition where this thread will return up the call stack to the main command
-                    // handler and show an (lldb) prompt before HandlePrivateEvent (from PrivateStateThread) has
-                    // a chance to call PushProcessIOHandler()
-                    m_process_sp->SyncIOHandler(2000);
+                    if (!synchronous_execution)
+                        m_process_sp->RestoreProcessEvents ();
+
+                    error = m_process_sp->PrivateResume();
 
-                    if (synchronous_execution)
+                    if (error.Success())
                     {
-                        state = m_process_sp->WaitForProcessToStop (NULL, NULL, true, hijack_listener_sp.get(), stream);
-                        const bool must_be_alive = false; // eStateExited is ok, so this must be false
-                        if (!StateIsStoppedState(state, must_be_alive))
+                        // there is a race condition where this thread will return up the call stack to the main command
+                        // handler and show an (lldb) prompt before HandlePrivateEvent (from PrivateStateThread) has
+                        // a chance to call PushProcessIOHandler()
+                        m_process_sp->SyncIOHandler(2000);
+
+                        if (synchronous_execution)
                         {
-                            error.SetErrorStringWithFormat("process isn't stopped: %s", StateAsCString(state));
+                            state = m_process_sp->WaitForProcessToStop (NULL, NULL, true, hijack_listener_sp.get(), stream);
+                            const bool must_be_alive = false; // eStateExited is ok, so this must be false
+                            if (!StateIsStoppedState(state, must_be_alive))
+                            {
+                                error.SetErrorStringWithFormat("process isn't stopped: %s", StateAsCString(state));
+                            }
                         }
                     }
+                    else
+                    {
+                        Error error2;
+                        error2.SetErrorStringWithFormat("process resume at entry point failed: %s", error.AsCString());
+                        error = error2;
+                    }
                 }
                 else
                 {
-                    Error error2;
-                    error2.SetErrorStringWithFormat("process resume at entry point failed: %s", error.AsCString());
-                    error = error2;
+                    assert(synchronous_execution && launch_info.GetFlags().Test(eLaunchFlagStopAtEntry) == true);
+
+                    // 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);
+
+                    // there is a race condition where this thread will return up the call stack to the main command
+                    // handler and show an (lldb) prompt before HandlePrivateEvent (from PrivateStateThread) has
+                    // a chance to call PushProcessIOHandler()
+                    m_process_sp->SyncIOHandler(2000);
                 }
             }
             else if (state == eStateExited)

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8541.22461.patch
Type: text/x-patch
Size: 4479 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150323/08c77948/attachment.bin>


More information about the lldb-commits mailing list