forked from qt-creator/qt-creator
debugger: work on trk exit/restart
This commit is contained in:
@@ -687,6 +687,7 @@ void GdbEngine::readGdbStandardOutput()
|
||||
|
||||
void GdbEngine::interruptInferior()
|
||||
{
|
||||
debugMessage(_("GDBENGINE INTERRUPT INFERIOR: %1").arg(m_gdbAdapter->state()));
|
||||
qq->notifyInferiorStopRequested();
|
||||
|
||||
if (m_gdbAdapter->state() == QProcess::NotRunning) {
|
||||
@@ -1478,6 +1479,7 @@ void GdbEngine::shutdown()
|
||||
void GdbEngine::detachDebugger()
|
||||
{
|
||||
postCommand(_("detach"));
|
||||
// FIXME: use postCommand(_("detach"), CB(handleExitHelper)) ?
|
||||
postCommand(_("-gdb-exit"), CB(handleExit));
|
||||
}
|
||||
|
||||
@@ -1500,9 +1502,21 @@ void GdbEngine::exitDebugger()
|
||||
interruptInferior();
|
||||
}
|
||||
if (startMode() == AttachExternal || startMode() == AttachCrashedExternal)
|
||||
postCommand(_("detach"));
|
||||
postCommand(_("detach"), CB(handleExitHelper));
|
||||
else
|
||||
postCommand(_("kill"));
|
||||
postCommand(_("kill"), CB(handleExitHelper));
|
||||
} else {
|
||||
exitDebugger2();
|
||||
}
|
||||
}
|
||||
|
||||
void GdbEngine::handleExitHelper(const GdbResultRecord &, const QVariant &)
|
||||
{
|
||||
exitDebugger2();
|
||||
}
|
||||
|
||||
void GdbEngine::exitDebugger2()
|
||||
{
|
||||
postCommand(_("-gdb-exit"), CB(handleExit));
|
||||
// 20s can easily happen when loading webkit debug information
|
||||
if (!m_gdbAdapter->waitForFinished(20000)) {
|
||||
@@ -1511,7 +1525,7 @@ void GdbEngine::exitDebugger()
|
||||
m_gdbAdapter->terminate();
|
||||
m_gdbAdapter->waitForFinished(20000);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_gdbAdapter->state() != QProcess::NotRunning) {
|
||||
debugMessage(_("PROBLEM STOPPING DEBUGGER: STATE %1")
|
||||
.arg(m_gdbAdapter->state()));
|
||||
|
||||
@@ -147,6 +147,7 @@ private:
|
||||
void startDebugger(const QSharedPointer<DebuggerStartParameters> &sp);
|
||||
Q_SLOT void startDebugger2();
|
||||
void exitDebugger();
|
||||
void exitDebugger2();
|
||||
void detachDebugger();
|
||||
|
||||
void continueInferior();
|
||||
@@ -284,6 +285,7 @@ private:
|
||||
void handleQuerySources(const GdbResultRecord &response, const QVariant &);
|
||||
void handleTargetCore(const GdbResultRecord &, const QVariant &);
|
||||
void handleExit(const GdbResultRecord &, const QVariant &);
|
||||
void handleExitHelper(const GdbResultRecord &, const QVariant &);
|
||||
void handleSetTargetAsync(const GdbResultRecord &, const QVariant &);
|
||||
void handleTargetRemote(const GdbResultRecord &, const QVariant &);
|
||||
void handleWatchPoint(const GdbResultRecord &, const QVariant &);
|
||||
|
||||
@@ -488,13 +488,12 @@ void TrkGdbAdapter::handleGdbServerCommand(const QByteArray &cmd)
|
||||
else if (cmd == "k" || cmd.startsWith("vKill")) {
|
||||
// Kill inferior process
|
||||
logMessage(msgGdbPacket(QLatin1String("kill")));
|
||||
sendGdbServerAck();
|
||||
QByteArray ba;
|
||||
appendByte(&ba, 0); // ?
|
||||
appendByte(&ba, 0); // Sub-command: Delete Process
|
||||
appendInt(&ba, m_session.pid);
|
||||
sendTrkMessage(0x41, TrkCallback(), ba, "Delete process"); // Delete Item
|
||||
sendGdbServerMessageAfterTrkResponse("", "process killed");
|
||||
sendTrkMessage(0x41, TrkCB(handleDeleteProcess),
|
||||
ba, "Delete process"); // Delete Item
|
||||
}
|
||||
|
||||
else if (cmd.startsWith("m")) {
|
||||
@@ -935,6 +934,22 @@ void TrkGdbAdapter::handleCreateProcess(const TrkResult &result)
|
||||
startGdb();
|
||||
}
|
||||
|
||||
void TrkGdbAdapter::handleDeleteProcess(const TrkResult &result)
|
||||
{
|
||||
Q_UNUSED(result);
|
||||
logMessage("TRK Process killed");
|
||||
//sendTrkMessage(0x01, TrkCB(handleDeleteProcess2)); // Ping
|
||||
sendTrkMessage(0x02, TrkCB(handleDeleteProcess2)); // Disconnect
|
||||
}
|
||||
|
||||
void TrkGdbAdapter::handleDeleteProcess2(const TrkResult &result)
|
||||
{
|
||||
Q_UNUSED(result);
|
||||
logMessage("process killed");
|
||||
sendGdbServerAck();
|
||||
sendGdbServerMessage("", "process killed");
|
||||
}
|
||||
|
||||
void TrkGdbAdapter::handleReadRegisters(const TrkResult &result)
|
||||
{
|
||||
logMessage(" RESULT: " + result.toString());
|
||||
@@ -1269,7 +1284,7 @@ void TrkGdbAdapter::handleGdbStateChanged(QProcess::ProcessState newState)
|
||||
void TrkGdbAdapter::run()
|
||||
{
|
||||
emit output("### Starting TrkGdbAdapter");
|
||||
m_rfcommProc.start("rfcomm listen " + m_rfcommDevice + " 1");
|
||||
m_rfcommProc.start("rfcomm -r listen " + m_rfcommDevice + " 1");
|
||||
m_rfcommProc.waitForStarted();
|
||||
|
||||
if (m_rfcommProc.state() != QProcess::Running) {
|
||||
@@ -1369,16 +1384,26 @@ void TrkGdbAdapter::start(const QString &program, const QStringList &args,
|
||||
|
||||
void TrkGdbAdapter::kill()
|
||||
{
|
||||
m_rfcommProc.kill();
|
||||
m_gdbProc.kill();
|
||||
}
|
||||
|
||||
void TrkGdbAdapter::terminate()
|
||||
{
|
||||
m_rfcommProc.terminate();
|
||||
m_gdbProc.terminate();
|
||||
}
|
||||
|
||||
bool TrkGdbAdapter::waitForFinished(int msecs)
|
||||
{
|
||||
QByteArray ba;
|
||||
ba.append(0x03);
|
||||
m_rfcommProc.write(ba);
|
||||
m_rfcommProc.terminate();
|
||||
m_rfcommProc.waitForFinished();
|
||||
QProcess proc;
|
||||
proc.start("rfcomm release " + m_rfcommDevice.toLatin1());
|
||||
proc.waitForFinished();
|
||||
return m_gdbProc.waitForFinished(msecs);
|
||||
}
|
||||
|
||||
|
||||
@@ -156,6 +156,8 @@ public:
|
||||
void handleSupportMask(const TrkResult &result);
|
||||
void handleTrkVersions(const TrkResult &result);
|
||||
void handleDisconnect(const TrkResult &result);
|
||||
void handleDeleteProcess(const TrkResult &result);
|
||||
void handleDeleteProcess2(const TrkResult &result);
|
||||
|
||||
void handleAndReportCreateProcess(const TrkResult &result);
|
||||
void handleAndReportReadRegistersAfterStop(const TrkResult &result);
|
||||
|
||||
Reference in New Issue
Block a user