forked from qt-creator/qt-creator
Debugger: Force flushing of GDB output
... after continue and step. Otherwise there would be no reaction after the inferior gets an external SIGKILL while stopped. Task-number: QTCREATORBUG-17280 Change-Id: I57933e92194a3320d7aba81055755477f34af382 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -966,6 +966,8 @@ void GdbEngine::runCommand(const DebuggerCommand &command)
|
|||||||
Q_ARG(QString, buffer));
|
Q_ARG(QString, buffer));
|
||||||
} else {
|
} else {
|
||||||
write(cmd.function.toUtf8() + "\r\n");
|
write(cmd.function.toUtf8() + "\r\n");
|
||||||
|
if (command.flags & NeedsFlush)
|
||||||
|
write("p 0\r\n");
|
||||||
|
|
||||||
// Start Watchdog.
|
// Start Watchdog.
|
||||||
if (m_commandTimer.interval() <= 20000)
|
if (m_commandTimer.interval() <= 20000)
|
||||||
@@ -1103,6 +1105,8 @@ void GdbEngine::handleResultRecord(DebuggerResponse *response)
|
|||||||
// the exception now in a box.
|
// the exception now in a box.
|
||||||
if (msg.startsWith("During startup program exited with"))
|
if (msg.startsWith("During startup program exited with"))
|
||||||
notifyInferiorExited();
|
notifyInferiorExited();
|
||||||
|
else if (msg.contains("Command aborted."))
|
||||||
|
notifyInferiorSpontaneousStop();
|
||||||
QString logMsg;
|
QString logMsg;
|
||||||
if (!m_lastWinException.isEmpty())
|
if (!m_lastWinException.isEmpty())
|
||||||
logMsg = m_lastWinException + '\n';
|
logMsg = m_lastWinException + '\n';
|
||||||
@@ -2009,7 +2013,7 @@ void GdbEngine::continueInferiorInternal()
|
|||||||
cmd.callback = CB(handleExecuteContinue);
|
cmd.callback = CB(handleExecuteContinue);
|
||||||
runCommand(cmd);
|
runCommand(cmd);
|
||||||
} else {
|
} else {
|
||||||
DebuggerCommand cmd("-exec-continue", RunRequest);
|
DebuggerCommand cmd("-exec-continue", RunRequest|NeedsFlush);
|
||||||
cmd.callback = CB(handleExecuteContinue);
|
cmd.callback = CB(handleExecuteContinue);
|
||||||
runCommand(cmd);
|
runCommand(cmd);
|
||||||
}
|
}
|
||||||
@@ -2034,7 +2038,7 @@ void GdbEngine::executeStep()
|
|||||||
runCommand(cmd);
|
runCommand(cmd);
|
||||||
} else {
|
} else {
|
||||||
DebuggerCommand cmd;
|
DebuggerCommand cmd;
|
||||||
cmd.flags = RunRequest;
|
cmd.flags = RunRequest|NeedsFlush;
|
||||||
cmd.function = QLatin1String(isReverseDebugging() ? "reverse-step" : "-exec-step");
|
cmd.function = QLatin1String(isReverseDebugging() ? "reverse-step" : "-exec-step");
|
||||||
cmd.callback = CB(handleExecuteStep);
|
cmd.callback = CB(handleExecuteStep);
|
||||||
runCommand(cmd);
|
runCommand(cmd);
|
||||||
@@ -2084,7 +2088,7 @@ void GdbEngine::executeStepI()
|
|||||||
notifyInferiorRunRequested();
|
notifyInferiorRunRequested();
|
||||||
showStatusMessage(tr("Step by instruction requested..."), 5000);
|
showStatusMessage(tr("Step by instruction requested..."), 5000);
|
||||||
DebuggerCommand cmd;
|
DebuggerCommand cmd;
|
||||||
cmd.flags = RunRequest;
|
cmd.flags = RunRequest|NeedsFlush;
|
||||||
cmd.function = QLatin1String(isReverseDebugging() ? "reverse-stepi" : "-exec-step-instruction");
|
cmd.function = QLatin1String(isReverseDebugging() ? "reverse-stepi" : "-exec-step-instruction");
|
||||||
cmd.callback = CB(handleExecuteContinue);
|
cmd.callback = CB(handleExecuteContinue);
|
||||||
runCommand(cmd);
|
runCommand(cmd);
|
||||||
@@ -2100,12 +2104,11 @@ void GdbEngine::executeStepOut()
|
|||||||
if (isNativeMixedActiveFrame()) {
|
if (isNativeMixedActiveFrame()) {
|
||||||
runCommand({"executeStepOut", RunRequest|PythonCommand});
|
runCommand({"executeStepOut", RunRequest|PythonCommand});
|
||||||
} else {
|
} else {
|
||||||
runCommand({"-exec-finish", RunRequest, CB(handleExecuteContinue)});
|
|
||||||
// -exec-finish in 'main' results (correctly) in
|
// -exec-finish in 'main' results (correctly) in
|
||||||
// 40^error,msg="\"finish\" not meaningful in the outermost frame."
|
// 40^error,msg="\"finish\" not meaningful in the outermost frame."
|
||||||
// However, this message does not seem to get flushed before
|
// However, this message does not seem to get flushed before
|
||||||
// anything else happen - i.e. "never". Force some extra output.
|
// anything else happen - i.e. "never". Force some extra output.
|
||||||
runCommand({"print 32"});
|
runCommand({"-exec-finish", RunRequest|NeedsFlush, CB(handleExecuteContinue)});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -154,6 +154,8 @@ private: ////////// Gdb Command Management //////////
|
|||||||
NeedsStop = 1,
|
NeedsStop = 1,
|
||||||
// No need to wait for the reply before continuing inferior.
|
// No need to wait for the reply before continuing inferior.
|
||||||
Discardable = 2,
|
Discardable = 2,
|
||||||
|
// Needs a dummy extra command to force GDB output flushing.
|
||||||
|
NeedsFlush = 4,
|
||||||
// Callback expects ResultRunning instead of ResultDone.
|
// Callback expects ResultRunning instead of ResultDone.
|
||||||
RunRequest = 16,
|
RunRequest = 16,
|
||||||
// Callback expects ResultExit instead of ResultDone.
|
// Callback expects ResultExit instead of ResultDone.
|
||||||
|
|||||||
Reference in New Issue
Block a user