Debugger[CDB]: Enable engine restart.

This commit is contained in:
Friedemann Kleint
2011-02-08 12:08:59 +01:00
parent a57da84be8
commit a9982cac70
2 changed files with 45 additions and 6 deletions

View File

@@ -408,7 +408,8 @@ CdbEngine::CdbEngine(const DebuggerStartParameters &sp,
m_sourceStepInto(false), m_sourceStepInto(false),
m_wX86BreakpointCount(0), m_wX86BreakpointCount(0),
m_watchPointX(0), m_watchPointX(0),
m_watchPointY(0) m_watchPointY(0),
m_ignoreCdbOutput(false)
{ {
Utils::SavedAction *assemblerAction = theAssemblerAction(); Utils::SavedAction *assemblerAction = theAssemblerAction();
m_operateByInstructionPending = assemblerAction->isChecked(); m_operateByInstructionPending = assemblerAction->isChecked();
@@ -421,6 +422,31 @@ CdbEngine::CdbEngine(const DebuggerStartParameters &sp,
connect(&m_process, SIGNAL(readyReadStandardError()), this, SLOT(readyReadStandardOut())); connect(&m_process, SIGNAL(readyReadStandardError()), this, SLOT(readyReadStandardOut()));
} }
void CdbEngine::init()
{
m_effectiveStartMode = NoStartMode;
m_inferiorPid = 0;
m_accessible = false;
m_specialStopMode = NoSpecialStop;
m_nextCommandToken = 0;
m_currentBuiltinCommandIndex = -1;
m_operateByInstructionPending = true;
m_operateByInstruction = true; // Default CDB setting
m_notifyEngineShutdownOnTermination = false;
m_hasDebuggee = false;
m_sourceStepInto = false;
m_wX86BreakpointCount = 0;
m_watchPointX = m_watchPointY = 0;
m_ignoreCdbOutput = false;
m_outputBuffer.clear();
m_builtinCommandQueue.clear();
m_extensionCommandQueue.clear();
m_extensionMessageBuffer.clear();
m_pendingBreakpointMap.clear();
QTC_ASSERT(m_process.state() != QProcess::Running, Utils::SynchronousProcess::stopProcess(m_process); )
}
CdbEngine::~CdbEngine() CdbEngine::~CdbEngine()
{ {
} }
@@ -592,6 +618,8 @@ void CdbEngine::setupEngine()
&(m_options->symbolPaths))) &(m_options->symbolPaths)))
m_options->toSettings(Core::ICore::instance()->settings()); m_options->toSettings(Core::ICore::instance()->settings());
init();
if (!m_logTime.elapsed())
m_logTime.start(); m_logTime.start();
QString errorMessage; QString errorMessage;
// Console: Launch the stub with the suspended application and attach to it // Console: Launch the stub with the suspended application and attach to it
@@ -756,6 +784,11 @@ void CdbEngine::shutdownInferior()
return; return;
} }
if (!canInterruptInferior() || commandsPending()) { if (!canInterruptInferior() || commandsPending()) {
QString msg = QLatin1String("Cannot interrupt the inferior");
if (commandsPending())
msg += QLatin1String(" (pending)");
msg += QLatin1Char('.');
showMessage(msg, LogWarning);
STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorShutdownFailed") STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorShutdownFailed")
notifyInferiorShutdownFailed(); notifyInferiorShutdownFailed();
return; return;
@@ -794,8 +827,7 @@ void CdbEngine::shutdownEngine()
} }
// No longer trigger anything from messages // No longer trigger anything from messages
disconnect(&m_process, SIGNAL(readyReadStandardOutput()), this, 0); m_ignoreCdbOutput = true;
disconnect(&m_process, SIGNAL(readyReadStandardError()), this, 0);
// Go for kill if there are commands pending. // Go for kill if there are commands pending.
if (m_accessible && !commandsPending()) { if (m_accessible && !commandsPending()) {
// detach: Wait for debugger to finish. // detach: Wait for debugger to finish.
@@ -1001,11 +1033,13 @@ void CdbEngine::doContinueInferior()
bool CdbEngine::canInterruptInferior() const bool CdbEngine::canInterruptInferior() const
{ {
return m_effectiveStartMode != AttachToRemote; return m_effectiveStartMode != AttachToRemote && m_inferiorPid;
} }
void CdbEngine::interruptInferior() void CdbEngine::interruptInferior()
{ {
if (debug)
qDebug() << "CdbEngine::interruptInferior()" << stateName(state());
if (canInterruptInferior()) { if (canInterruptInferior()) {
doInterruptInferior(NoSpecialStop); doInterruptInferior(NoSpecialStop);
} else { } else {
@@ -1025,9 +1059,10 @@ void CdbEngine::doInterruptInferior(SpecialStopMode sm)
const SpecialStopMode oldSpecialMode = m_specialStopMode; const SpecialStopMode oldSpecialMode = m_specialStopMode;
m_specialStopMode = sm; m_specialStopMode = sm;
QString errorMessage; QString errorMessage;
showMessage(QString::fromLatin1("Interrupting process %1...").arg(m_inferiorPid), LogMisc);
if (!winDebugBreakProcess(m_inferiorPid, &errorMessage)) { if (!winDebugBreakProcess(m_inferiorPid, &errorMessage)) {
m_specialStopMode = oldSpecialMode; m_specialStopMode = oldSpecialMode;
showMessage(errorMessage, LogError); showMessage(QString::fromLatin1("Cannot interrupt process %1: %2").arg(m_inferiorPid).arg(errorMessage), LogError);
} }
#else #else
Q_UNUSED(sm) Q_UNUSED(sm)
@@ -2057,6 +2092,8 @@ void CdbEngine::parseOutputLine(QByteArray line)
void CdbEngine::readyReadStandardOut() void CdbEngine::readyReadStandardOut()
{ {
if (m_ignoreCdbOutput)
return;
m_outputBuffer += m_process.readAllStandardOutput(); m_outputBuffer += m_process.readAllStandardOutput();
// Split into lines and parse line by line. // Split into lines and parse line by line.
while (true) { while (true) {

View File

@@ -176,6 +176,7 @@ private:
bool startConsole(const DebuggerStartParameters &sp, QString *errorMessage); bool startConsole(const DebuggerStartParameters &sp, QString *errorMessage);
void init();
unsigned examineStopReason(const GdbMi &stopReason, QString *message, unsigned examineStopReason(const GdbMi &stopReason, QString *message,
QString *exceptionBoxMessage); QString *exceptionBoxMessage);
bool commandsPending() const; bool commandsPending() const;
@@ -251,6 +252,7 @@ private:
int m_watchPointY; int m_watchPointY;
PendingBreakPointMap m_pendingBreakpointMap; PendingBreakPointMap m_pendingBreakpointMap;
QHash<QString, QString> m_fileNameModuleHash; QHash<QString, QString> m_fileNameModuleHash;
bool m_ignoreCdbOutput;
}; };
} // namespace Internal } // namespace Internal