OSDN Git Service

synchronize temporary interruption with running-requests
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>
Mon, 2 Nov 2009 13:40:54 +0000 (14:40 +0100)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>
Mon, 2 Nov 2009 16:13:46 +0000 (17:13 +0100)
Reviewed-by: hjk
src/plugins/debugger/gdb/gdbengine.cpp

index 45e600e..8456591 100644 (file)
@@ -730,9 +730,15 @@ void GdbEngine::postCommandHelper(const GdbCommand &cmd)
             // Queue the commands that we cannot send at once.
             debugMessage(_("QUEUING COMMAND ") + cmd.command);
             m_commandsToRunOnTemporaryBreak.append(cmd);
-            if (state() != InferiorStopping) {
+            if (state() == InferiorStopping) {
+                debugMessage(_("CHILD ALREADY BEING INTERRUPTED"));
+            } else if (state() == InferiorRunningRequested) {
+                debugMessage(_("RUNNING REQUESTED; POSTPONING INTERRUPT"));
+            } else if (state() == InferiorRunning) {
                 showStatusMessage(tr("Stopping temporarily."), 1000);
-                interruptInferior(); // FIXME: race condition between gdb and kill()
+                interruptInferior();
+            } else {
+                qDebug() << "ATTEMPTING TO QUEUE COMMAND IN INAPPROPRIATE STATE" << state();
             }
         }
     } else if (!cmd.command.isEmpty()) {
@@ -866,6 +872,13 @@ void GdbEngine::handleResultRecord(GdbResponse *response)
                       << "LEAVES PENDING AT" << m_pendingRequests);
     }
 
+    // Commands were queued, but we were in RunningRequested state, so the interrupt
+    // was postponed.
+    // This is done after the command callbacks so the running-requesting commands
+    // can assert on the right state.
+    if (state() == InferiorRunning && !m_commandsToRunOnTemporaryBreak.isEmpty())
+        interruptInferior();
+
     // Continue only if there are no commands wire anymore, so this will
     // be fully synchroneous.
     // This is somewhat inefficient, as it makes the last command synchronous.