Commit 755f5fc3 authored by hjk's avatar hjk Committed by hjk

debugger: cleaner debugger aborting

Make the second "Abort Debugger" kill the gdb process directly
instead of relying on further communication.

Also fix some "unexpected" (but harmless) state transitions.

Change-Id: I0938ec76420fbd77ec4b7348819dd7f63763547f
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 384a8ed1
......@@ -60,7 +60,7 @@ const char INTERRUPT[] = "Debugger.Interrupt";
const char CONTINUE[] = "Debugger.Continue";
const char STOP[] = "Debugger.Stop";
const char HIDDEN_STOP[] = "Debugger.HiddenStop";
const char RESET[] = "Debugger.Reset";
const char ABORT[] = "Debugger.Abort";
const char STEP[] = "Debugger.StepLine";
const char STEPOUT[] = "Debugger.StepOut";
const char NEXT[] = "Debugger.NextLine";
......
......@@ -1209,7 +1209,7 @@ bool DebuggerEngine::isReverseDebugging() const
// Called by DebuggerRunControl.
void DebuggerEngine::quitDebugger()
{
showMessage("QUIT DEBUGGER REQUESTED");
showMessage(_("QUIT DEBUGGER REQUESTED IN STATE %1").arg(state()));
d->m_targetState = DebuggerFinished;
switch (state()) {
case InferiorStopOk:
......@@ -1225,6 +1225,9 @@ void DebuggerEngine::quitDebugger()
case EngineRunFailed:
case DebuggerFinished:
break;
case InferiorSetupRequested:
notifyInferiorSetupFailed();
break;
default:
// FIXME: We should disable the actions connected to that.
notifyInferiorIll();
......@@ -1232,6 +1235,12 @@ void DebuggerEngine::quitDebugger()
}
}
void DebuggerEngine::abortDebugger()
{
// Overridden in e.g. GdbEngine.
quitDebugger();
}
void DebuggerEngine::requestInterruptInferior()
{
d->doInterruptInferior();
......
......@@ -267,6 +267,7 @@ public:
virtual void resetLocation();
virtual void gotoLocation(const Internal::Location &location);
virtual void quitDebugger(); // called by DebuggerRunControl
virtual void abortDebugger(); // called by DebuggerPlugin
virtual void updateViews();
bool isSlaveEngine() const;
......@@ -342,7 +343,7 @@ protected:
virtual void detachDebugger();
virtual void exitDebugger();
virtual void executeStep();
virtual void executeStepOut() ;
virtual void executeStepOut();
virtual void executeNext();
virtual void executeStepI();
virtual void executeNextI();
......
......@@ -809,10 +809,10 @@ public slots:
currentEngine()->requestInterruptInferior();
}
void handleExecReset()
void handleAbort()
{
currentEngine()->resetLocation();
currentEngine()->notifyEngineIll(); // FIXME: Check.
currentEngine()->abortDebugger();
}
void handleExecStep()
......@@ -1040,7 +1040,7 @@ public:
QAction *m_exitAction; // On application output button if "Stop" is possible
QAction *m_interruptAction; // On the fat debug button if "Pause" is possible
QAction *m_undisturbableAction; // On the fat debug button if nothing can be done
QAction *m_resetAction;
QAction *m_abortAction;
QAction *m_stepAction;
QAction *m_stepOutAction;
QAction *m_runToLineAction; // In the debug menu
......@@ -2070,7 +2070,7 @@ void DebuggerPluginPrivate::setInitialState()
action(OperateByInstruction)->setEnabled(false);
m_exitAction->setEnabled(false);
m_resetAction->setEnabled(false);
m_abortAction->setEnabled(false);
m_interruptAction->setEnabled(false);
m_continueAction->setEnabled(false);
......@@ -2201,7 +2201,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
&& (stopped || isCore);
action(OperateByInstruction)->setEnabled(canOperateByInstruction);
m_resetAction->setEnabled(state != DebuggerNotReady
m_abortAction->setEnabled(state != DebuggerNotReady
&& state != DebuggerFinished);
m_stepAction->setEnabled(stopped || state == DebuggerNotReady);
......@@ -2792,10 +2792,10 @@ void DebuggerPluginPrivate::extensionsInitialized()
act->setIcon(m_interruptIcon);
act->setEnabled(false);
act = m_resetAction = new QAction(tr("Abort Debugging"), this);
act = m_abortAction = new QAction(tr("Abort Debugging"), this);
act->setToolTip(tr("Aborts debugging and "
"resets the debugger to the initial state."));
connect(act, SIGNAL(triggered()), SLOT(handleExecReset()));
connect(act, SIGNAL(triggered()), SLOT(handleAbort()));
act = m_nextAction = new QAction(tr("Step Over"), this);
act->setIcon(QIcon(__(":/debugger/images/debugger_stepover_small.png")));
......@@ -3063,8 +3063,8 @@ void DebuggerPluginPrivate::extensionsInitialized()
Constants::HIDDEN_STOP, globalcontext);
cmd->setDefaultKeySequence(QKeySequence(Constants::STOP_KEY));
cmd = am->registerAction(m_resetAction,
Constants::RESET, globalcontext);
cmd = am->registerAction(m_abortAction,
Constants::ABORT, globalcontext);
//cmd->setDefaultKeySequence(QKeySequence(Constants::RESET_KEY));
cmd->setDefaultText(tr("Reset Debugger"));
debugMenu->addAction(cmd, CC::G_DEFAULT_ONE);
......
......@@ -261,8 +261,11 @@ QString GdbEngine::errorMessage(QProcess::ProcessError error)
"permissions to invoke the program.\n%2")
.arg(m_gdb, gdbProc()->errorString());
case QProcess::Crashed:
return tr("The gdb process crashed some time after starting "
"successfully.");
if (targetState() == DebuggerFinished)
return tr("The gdb process crashed some time after starting "
"successfully.");
else
return tr("The gdb process was ended forcefully");
case QProcess::Timedout:
return tr("The last waitFor...() function timed out. "
"The state of QProcess is unchanged, and you can try calling "
......@@ -4730,6 +4733,21 @@ void GdbEngine::handleGdbFinished(int code, QProcess::ExitStatus type)
}
}
void GdbEngine::abortDebugger()
{
if (targetState() == DebuggerFinished) {
// We already tried. Try harder.
showMessage(_("ABORTING DEBUGGER. SECOND TIME."));
QTC_ASSERT(m_gdbAdapter, return);
QTC_ASSERT(m_gdbAdapter->gdbProc(), return);
m_gdbAdapter->gdbProc()->kill();
} else {
// Be friendly the first time. This will change targetState().
showMessage(_("ABORTING DEBUGGER. FIRST TIME."));
quitDebugger();
}
}
void GdbEngine::handleAdapterStartFailed(const QString &msg,
const QString &settingsIdHint)
{
......
......@@ -242,6 +242,7 @@ private: ////////// General Interface //////////
virtual void shutdownEngine();
virtual void shutdownInferior();
virtual void notifyInferiorSetupFailed();
virtual void abortDebugger();
virtual bool acceptsDebuggerCommands() const;
virtual void executeDebuggerCommand(const QString &command);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment