Commit 581cf86b authored by Oswald Buddenhagen's avatar Oswald Buddenhagen

make attach & detach work

Conflicts:

	src/plugins/debugger/gdbengine.cpp
parent 398c1fd9
...@@ -101,6 +101,7 @@ enum GdbCommandType ...@@ -101,6 +101,7 @@ enum GdbCommandType
GdbQuerySources, GdbQuerySources,
GdbAsyncOutput2, GdbAsyncOutput2,
GdbStart, GdbStart,
GdbAttached,
GdbExecRun, GdbExecRun,
GdbExecRunToFunction, GdbExecRunToFunction,
GdbExecStep, GdbExecStep,
...@@ -825,6 +826,9 @@ void GdbEngine::handleResult(const GdbResultRecord & record, int type, ...@@ -825,6 +826,9 @@ void GdbEngine::handleResult(const GdbResultRecord & record, int type,
case GdbStart: case GdbStart:
handleStart(record); handleStart(record);
break; break;
case GdbAttached:
handleAttach();
break;
case GdbInfoProc: case GdbInfoProc:
handleInfoProc(record); handleInfoProc(record);
break; break;
...@@ -1127,6 +1131,42 @@ static bool isStoppedReason(const QString &reason) ...@@ -1127,6 +1131,42 @@ static bool isStoppedReason(const QString &reason)
; ;
} }
void GdbEngine::handleAqcuiredInferior()
{
#if defined(Q_OS_WIN)
sendCommand("info thread", GdbInfoThreads);
#endif
#if defined(Q_OS_LINUX)
sendCommand("info proc", GdbInfoProc);
#endif
#if defined(Q_OS_MAC)
sendCommand("info pid", GdbInfoProc, QVariant(), NeedsStop);
#endif
reloadSourceFiles();
tryLoadCustomDumpers();
#ifndef Q_OS_MAC
// intentionally after tryLoadCustomDumpers(),
// otherwise we'd interupt solib loading.
if (qq->wantsAllPluginBreakpoints()) {
sendCommand("set auto-solib-add on");
sendCommand("set stop-on-solib-events 0");
sendCommand("sharedlibrary .*");
} else if (qq->wantsSelectedPluginBreakpoints()) {
sendCommand("set auto-solib-add on");
sendCommand("set stop-on-solib-events 1");
sendCommand("sharedlibrary " + qq->selectedPluginBreakpointsPattern());
} else if (qq->wantsNoPluginBreakpoints()) {
// should be like that already
sendCommand("set auto-solib-add off");
sendCommand("set stop-on-solib-events 0");
}
#endif
// nicer to see a bit of the world we live in
reloadModules();
attemptBreakpointSynchronization();
}
void GdbEngine::handleAsyncOutput(const GdbMi &data) void GdbEngine::handleAsyncOutput(const GdbMi &data)
{ {
const QString reason = data.findChild("reason").data(); const QString reason = data.findChild("reason").data();
...@@ -1162,43 +1202,11 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) ...@@ -1162,43 +1202,11 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data)
qq->notifyInferiorStopped(); qq->notifyInferiorStopped();
m_waitingForFirstBreakpointToBeHit = false; m_waitingForFirstBreakpointToBeHit = false;
// //
// that's the "early stop"
//
#if defined(Q_OS_WIN)
sendCommand("info thread", GdbInfoThreads);
#endif
#if defined(Q_OS_LINUX)
sendCommand("info proc", GdbInfoProc);
#endif
#if defined(Q_OS_MAC)
sendCommand("info pid", GdbInfoProc);
#endif
reloadSourceFiles();
tryLoadCustomDumpers();
#ifndef Q_OS_MAC
// intentionally after tryLoadCustomDumpers(),
// otherwise we'd interupt solib loading.
if (qq->wantsAllPluginBreakpoints()) {
sendCommand("set auto-solib-add on");
sendCommand("set stop-on-solib-events 0");
sendCommand("sharedlibrary .*");
} else if (qq->wantsSelectedPluginBreakpoints()) {
sendCommand("set auto-solib-add on");
sendCommand("set stop-on-solib-events 1");
sendCommand("sharedlibrary "+qq->selectedPluginBreakpointsPattern());
} else if (qq->wantsNoPluginBreakpoints()) {
// should be like that already
sendCommand("set auto-solib-add off");
sendCommand("set stop-on-solib-events 0");
}
#endif
// nicer to see a bit of the world we live in
reloadModules();
// this will "continue" if done // this will "continue" if done
m_waitingForBreakpointSynchronizationToContinue = true; m_waitingForBreakpointSynchronizationToContinue = true;
//QTimer::singleShot(0, this, SLOT(attemptBreakpointSynchronization())); //
attemptBreakpointSynchronization(); // that's the "early stop"
handleAqcuiredInferior();
return; return;
} }
...@@ -1498,8 +1506,16 @@ void GdbEngine::exitDebugger() ...@@ -1498,8 +1506,16 @@ void GdbEngine::exitDebugger()
if (m_gdbProc.state() == QProcess::Running) { if (m_gdbProc.state() == QProcess::Running) {
debugMessage(QString("WAITING FOR RUNNING GDB TO SHUTDOWN: %1") debugMessage(QString("WAITING FOR RUNNING GDB TO SHUTDOWN: %1")
.arg(m_gdbProc.state())); .arg(m_gdbProc.state()));
interruptInferior(); if (q->status() != DebuggerInferiorStopped
sendCommand("kill"); && q->status() != DebuggerProcessStartingUp) {
QTC_ASSERT(q->status() == DebuggerInferiorRunning,
qDebug() << "STATUS ON EXITDEBUGGER: " << q->status());
interruptInferior();
}
if (q->startMode() == DebuggerManager::AttachExternal)
sendCommand("detach");
else
sendCommand("kill");
sendCommand("-gdb-exit"); sendCommand("-gdb-exit");
// 20s can easily happen when loading webkit debug information // 20s can easily happen when loading webkit debug information
m_gdbProc.waitForFinished(20000); m_gdbProc.waitForFinished(20000);
...@@ -1654,7 +1670,7 @@ bool GdbEngine::startDebugger() ...@@ -1654,7 +1670,7 @@ bool GdbEngine::startDebugger()
} }
if (q->startMode() == DebuggerManager::AttachExternal) { if (q->startMode() == DebuggerManager::AttachExternal) {
sendCommand("attach " + QString::number(q->m_attachedPID)); sendCommand("attach " + QString::number(q->m_attachedPID), GdbAttached);
} else { } else {
// StartInternal or StartExternal // StartInternal or StartExternal
sendCommand("-file-exec-and-symbols " + fileName, GdbFileExecAndSymbols); sendCommand("-file-exec-and-symbols " + fileName, GdbFileExecAndSymbols);
...@@ -1714,6 +1730,37 @@ void GdbEngine::handleStart(const GdbResultRecord &response) ...@@ -1714,6 +1730,37 @@ void GdbEngine::handleStart(const GdbResultRecord &response)
} }
} }
void GdbEngine::handleAttach()
{
qq->notifyInferiorStopped();
q->showStatusMessage(tr("Attached to running process. Stopped."));
handleAqcuiredInferior();
q->resetLocation();
//
// Stack
//
qq->stackHandler()->setCurrentIndex(0);
updateLocals(); // Quick shot
sendSynchronizedCommand("-stack-list-frames", StackListFrames);
if (supportsThreads())
sendSynchronizedCommand("-thread-list-ids", StackListThreads, 0);
//
// Disassembler
//
// XXX we have no data here ...
//m_address = data.findChild("frame").findChild("addr").data();
//qq->reloadDisassembler();
//
// Registers
//
qq->reloadRegisters();
}
void GdbEngine::stepExec() void GdbEngine::stepExec()
{ {
setTokenBarrier(); setTokenBarrier();
......
...@@ -183,6 +183,8 @@ private slots: ...@@ -183,6 +183,8 @@ private slots:
private: private:
int terminationIndex(const QByteArray &buffer, int &length); int terminationIndex(const QByteArray &buffer, int &length);
void handleStart(const GdbResultRecord &response); void handleStart(const GdbResultRecord &response);
void handleAttach();
void handleAqcuiredInferior();
void handleAsyncOutput2(const GdbMi &data); void handleAsyncOutput2(const GdbMi &data);
void handleAsyncOutput(const GdbMi &data); void handleAsyncOutput(const GdbMi &data);
void handleResultRecord(const GdbResultRecord &response); void handleResultRecord(const GdbResultRecord &response);
......
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