debugger: make the selection of detach or kill explicit

Change-Id: I6f80047ad229e0be851b06a277ab2f899757828f
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
hjk
2012-03-26 16:03:25 +02:00
committed by hjk
parent bbd5d2ddfe
commit 95e2c9ca57
18 changed files with 25 additions and 48 deletions

View File

@@ -134,6 +134,12 @@ enum DebuggerStartMode
StartRemoteEngine // Start ipc guest engine on other machine StartRemoteEngine // Start ipc guest engine on other machine
}; };
enum DebuggerCloseMode
{
KillAtClose,
DetachAtClose
};
enum DebuggerCapabilities enum DebuggerCapabilities
{ {
ReverseSteppingCapability = 0x1, ReverseSteppingCapability = 0x1,

View File

@@ -1339,6 +1339,7 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it,
qulonglong pid = it->toULongLong(); qulonglong pid = it->toULongLong();
if (pid) { if (pid) {
sp.startMode = AttachExternal; sp.startMode = AttachExternal;
sp.closeMode = DetachAtClose;
sp.attachPID = pid; sp.attachPID = pid;
sp.displayName = tr("Process %1").arg(sp.attachPID); sp.displayName = tr("Process %1").arg(sp.attachPID);
sp.startMessage = tr("Attaching to local process %1.").arg(sp.attachPID); sp.startMessage = tr("Attaching to local process %1.").arg(sp.attachPID);
@@ -1560,6 +1561,7 @@ void DebuggerPluginPrivate::attachExternalApplication()
sp.displayName = tr("Process %1").arg(dlg.attachPID()); sp.displayName = tr("Process %1").arg(dlg.attachPID());
sp.executable = dlg.executable(); sp.executable = dlg.executable();
sp.startMode = AttachExternal; sp.startMode = AttachExternal;
sp.closeMode = DetachAtClose;
sp.toolChainAbi = dlg.abi(); sp.toolChainAbi = dlg.abi();
sp.debuggerCommand = dlg.debuggerCommand(); sp.debuggerCommand = dlg.debuggerCommand();
if (DebuggerRunControl *rc = createDebugger(sp)) if (DebuggerRunControl *rc = createDebugger(sp))
@@ -1572,6 +1574,7 @@ void DebuggerPluginPrivate::attachExternalApplication(RunControl *rc)
sp.attachPID = rc->applicationProcessHandle().pid(); sp.attachPID = rc->applicationProcessHandle().pid();
sp.displayName = tr("Debugger attached to %1").arg(rc->displayName()); sp.displayName = tr("Debugger attached to %1").arg(rc->displayName());
sp.startMode = AttachExternal; sp.startMode = AttachExternal;
sp.closeMode = DetachAtClose;
sp.toolChainAbi = rc->abi(); sp.toolChainAbi = rc->abi();
if (DebuggerRunControl *rc = createDebugger(sp)) if (DebuggerRunControl *rc = createDebugger(sp))
startDebugger(rc); startDebugger(rc);
@@ -1617,6 +1620,7 @@ void DebuggerPluginPrivate::attachToRemoteServer(const QString &spec)
sp.remoteArchitecture = spec.section(QLatin1Char('@'), 2, 2); sp.remoteArchitecture = spec.section(QLatin1Char('@'), 2, 2);
sp.displayName = tr("Remote: \"%1\"").arg(sp.remoteChannel); sp.displayName = tr("Remote: \"%1\"").arg(sp.remoteChannel);
sp.startMode = AttachToRemoteServer; sp.startMode = AttachToRemoteServer;
sp.closeMode = KillAtClose;
sp.toolChainAbi = anyAbiOfBinary(sp.executable); sp.toolChainAbi = anyAbiOfBinary(sp.executable);
if (DebuggerRunControl *rc = createDebugger(sp)) if (DebuggerRunControl *rc = createDebugger(sp))
startDebugger(rc); startDebugger(rc);
@@ -1630,6 +1634,7 @@ void DebuggerPluginPrivate::startRemoteCdbSession()
sp.toolChainAbi = Abi(hostAbi.architecture(), Abi::WindowsOS, sp.toolChainAbi = Abi(hostAbi.architecture(), Abi::WindowsOS,
Abi::WindowsMsvc2010Flavor, Abi::PEFormat, hostAbi.wordWidth()); Abi::WindowsMsvc2010Flavor, Abi::PEFormat, hostAbi.wordWidth());
sp.startMode = AttachToRemoteServer; sp.startMode = AttachToRemoteServer;
sp.closeMode = KillAtClose;
StartRemoteCdbDialog dlg(mainWindow()); StartRemoteCdbDialog dlg(mainWindow());
QString previousConnection = configValue(connectionKey).toString(); QString previousConnection = configValue(connectionKey).toString();
if (previousConnection.isEmpty()) if (previousConnection.isEmpty())
@@ -1666,6 +1671,7 @@ void DebuggerPluginPrivate::attachToRemoteServer()
DebuggerStartParameters sp; DebuggerStartParameters sp;
if (StartRemoteDialog::run(mainWindow(), m_coreSettings, false, &sp)) { if (StartRemoteDialog::run(mainWindow(), m_coreSettings, false, &sp)) {
sp.startMode = AttachToRemoteServer; sp.startMode = AttachToRemoteServer;
sp.closeMode = KillAtClose;
sp.useServerStartScript = false; sp.useServerStartScript = false;
sp.serverStartScript.clear(); sp.serverStartScript.clear();
if (RunControl *rc = createDebugger(sp)) if (RunControl *rc = createDebugger(sp))
@@ -1742,6 +1748,7 @@ void DebuggerPluginPrivate::attachedToProcess(const QString &channel,
sp.sysroot = sysroot; sp.sysroot = sysroot;
sp.executable = localExecutable; sp.executable = localExecutable;
sp.startMode = AttachToRemoteServer; sp.startMode = AttachToRemoteServer;
sp.closeMode = KillAtClose;
sp.overrideStartScript.clear(); sp.overrideStartScript.clear();
sp.useServerStartScript = false; sp.useServerStartScript = false;
sp.serverStartScript.clear(); sp.serverStartScript.clear();
@@ -1785,6 +1792,7 @@ void DebuggerPluginPrivate::attachToQmlPort()
sp.sysroot = dlg.sysroot(); sp.sysroot = dlg.sysroot();
sp.startMode = AttachToRemoteServer; sp.startMode = AttachToRemoteServer;
sp.closeMode = KillAtClose;
sp.languages = QmlLanguage; sp.languages = QmlLanguage;
// //

View File

@@ -67,6 +67,7 @@ public:
useServerStartScript(false), useServerStartScript(false),
requestRemoteSetup(false), requestRemoteSetup(false),
startMode(NoStartMode), startMode(NoStartMode),
closeMode(KillAtClose),
executableUid(0), executableUid(0),
communicationChannel(CommunicationChannelTcpIp), communicationChannel(CommunicationChannelTcpIp),
serverPort(0), serverPort(0),
@@ -125,6 +126,7 @@ public:
QString dumperLibrary; QString dumperLibrary;
QStringList dumperLibraryLocations; QStringList dumperLibraryLocations;
DebuggerStartMode startMode; DebuggerStartMode startMode;
DebuggerCloseMode closeMode;
// For Symbian debugging. // For Symbian debugging.
quint32 executableUid; quint32 executableUid;

View File

@@ -75,7 +75,6 @@ public:
virtual void setupInferior() = 0; virtual void setupInferior() = 0;
virtual void runEngine() = 0; virtual void runEngine() = 0;
virtual void interruptInferior() = 0; virtual void interruptInferior() = 0;
virtual void shutdownInferior() = 0;
virtual void shutdownAdapter() = 0; virtual void shutdownAdapter() = 0;
virtual AbstractGdbProcess *gdbProc() = 0; virtual AbstractGdbProcess *gdbProc() = 0;

View File

@@ -116,11 +116,6 @@ void AttachGdbAdapter::interruptInferior()
interruptLocalInferior(startParameters().attachPID); interruptLocalInferior(startParameters().attachPID);
} }
void AttachGdbAdapter::shutdownInferior()
{
m_engine->defaultInferiorShutdown("detach");
}
void AttachGdbAdapter::shutdownAdapter() void AttachGdbAdapter::shutdownAdapter()
{ {
m_engine->notifyAdapterShutdownOk(); m_engine->notifyAdapterShutdownOk();

View File

@@ -59,7 +59,6 @@ private:
void setupInferior(); void setupInferior();
void runEngine(); void runEngine();
void interruptInferior(); void interruptInferior();
void shutdownInferior();
void shutdownAdapter(); void shutdownAdapter();
AbstractGdbProcess *gdbProc() { return &m_gdbProc; } AbstractGdbProcess *gdbProc() { return &m_gdbProc; }

View File

@@ -1237,11 +1237,6 @@ void CodaGdbAdapter::cleanup()
} }
} }
void CodaGdbAdapter::shutdownInferior()
{
m_engine->defaultInferiorShutdown("kill");
}
void CodaGdbAdapter::shutdownAdapter() void CodaGdbAdapter::shutdownAdapter()
{ {
if (m_gdbProc.state() == QProcess::Running) { if (m_gdbProc.state() == QProcess::Running) {

View File

@@ -114,7 +114,6 @@ private:
void setupInferior(); void setupInferior();
void runEngine(); void runEngine();
void interruptInferior(); void interruptInferior();
void shutdownInferior();
void shutdownAdapter(); void shutdownAdapter();
void sendRunControlTerminateCommand(); void sendRunControlTerminateCommand();
void handleRunControlTerminate(const Coda::CodaCommandResult &); void handleRunControlTerminate(const Coda::CodaCommandResult &);

View File

@@ -1893,13 +1893,15 @@ void GdbEngine::shutdownInferior()
{ {
QTC_ASSERT(state() == InferiorShutdownRequested, qDebug() << state()); QTC_ASSERT(state() == InferiorShutdownRequested, qDebug() << state());
m_commandsToRunOnTemporaryBreak.clear(); m_commandsToRunOnTemporaryBreak.clear();
m_gdbAdapter->shutdownInferior(); switch (startParameters().closeMode) {
case KillAtClose:
postCommand("kill", NeedsStop | LosesChild, CB(handleInferiorShutdown));
break;
case DetachAtClose:
postCommand("detach", NeedsStop | LosesChild, CB(handleInferiorShutdown));
break;
} }
QTC_ASSERT(false, notifyInferiorShutdownFailed());
void GdbEngine::defaultInferiorShutdown(const char *cmd)
{
QTC_ASSERT(state() == InferiorShutdownRequested, qDebug() << state());
postCommand(cmd, NeedsStop | LosesChild, CB(handleInferiorShutdown));
} }
void GdbEngine::handleInferiorShutdown(const GdbResponse &response) void GdbEngine::handleInferiorShutdown(const GdbResponse &response)

View File

@@ -264,7 +264,6 @@ private: ////////// Gdb Process Management //////////
void handleNamespaceExtraction(const GdbResponse &response); void handleNamespaceExtraction(const GdbResponse &response);
void handleAdapterStarted(); void handleAdapterStarted();
void defaultInferiorShutdown(const char *cmd);
void loadInitScript(); void loadInitScript();
void loadPythonDumpers(); void loadPythonDumpers();
void pythonDumpersFailed(); void pythonDumpersFailed();

View File

@@ -114,11 +114,6 @@ void LocalPlainGdbAdapter::runEngine()
AbstractPlainGdbAdapter::runEngine(); AbstractPlainGdbAdapter::runEngine();
} }
void LocalPlainGdbAdapter::shutdownInferior()
{
m_engine->defaultInferiorShutdown("kill");
}
void LocalPlainGdbAdapter::shutdownAdapter() void LocalPlainGdbAdapter::shutdownAdapter()
{ {
showMessage(_("PLAIN ADAPTER SHUTDOWN %1").arg(state())); showMessage(_("PLAIN ADAPTER SHUTDOWN %1").arg(state()));

View File

@@ -58,7 +58,6 @@ private:
void setupInferior(); void setupInferior();
void runEngine(); void runEngine();
void interruptInferior(); void interruptInferior();
void shutdownInferior();
void shutdownAdapter(); void shutdownAdapter();
DumperHandling dumperHandling() const; DumperHandling dumperHandling() const;

View File

@@ -365,14 +365,6 @@ void RemoteGdbServerAdapter::handleInterruptInferior(const GdbResponse &response
} }
} }
void RemoteGdbServerAdapter::shutdownInferior()
{
if (m_engine->startParameters().startMode == AttachToRemoteServer)
m_engine->defaultInferiorShutdown("detach");
else
m_engine->defaultInferiorShutdown("kill");
}
void RemoteGdbServerAdapter::shutdownAdapter() void RemoteGdbServerAdapter::shutdownAdapter()
{ {
m_engine->notifyAdapterShutdownOk(); m_engine->notifyAdapterShutdownOk();

View File

@@ -59,7 +59,6 @@ private:
void setupInferior(); void setupInferior();
void runEngine(); void runEngine();
void interruptInferior(); void interruptInferior();
void shutdownInferior();
void shutdownAdapter(); void shutdownAdapter();
AbstractGdbProcess *gdbProc() { return &m_gdbProc; } AbstractGdbProcess *gdbProc() { return &m_gdbProc; }

View File

@@ -98,11 +98,6 @@ void RemotePlainGdbAdapter::handleApplicationOutput(const QByteArray &output)
showMessage(QString::fromUtf8(output), AppOutput); showMessage(QString::fromUtf8(output), AppOutput);
} }
void RemotePlainGdbAdapter::shutdownInferior()
{
m_engine->defaultInferiorShutdown("kill");
}
void RemotePlainGdbAdapter::shutdownAdapter() void RemotePlainGdbAdapter::shutdownAdapter()
{ {
m_engine->notifyAdapterShutdownOk(); m_engine->notifyAdapterShutdownOk();

View File

@@ -55,7 +55,6 @@ private:
void startAdapter(); void startAdapter();
void setupInferior(); void setupInferior();
void interruptInferior(); void interruptInferior();
void shutdownInferior();
void shutdownAdapter(); void shutdownAdapter();
void handleRemoteSetupDone(int gdbServerPort, int qmlPort); void handleRemoteSetupDone(int gdbServerPort, int qmlPort);
void handleRemoteSetupFailed(const QString &reason); void handleRemoteSetupFailed(const QString &reason);

View File

@@ -210,11 +210,6 @@ void TermGdbAdapter::stubExited()
m_engine->notifyEngineIll(); m_engine->notifyEngineIll();
} }
void TermGdbAdapter::shutdownInferior()
{
m_engine->defaultInferiorShutdown("kill");
}
void TermGdbAdapter::shutdownAdapter() void TermGdbAdapter::shutdownAdapter()
{ {
m_engine->notifyAdapterShutdownOk(); m_engine->notifyAdapterShutdownOk();

View File

@@ -62,7 +62,6 @@ private:
void setupInferior(); void setupInferior();
void runEngine(); void runEngine();
void interruptInferior(); void interruptInferior();
void shutdownInferior();
void shutdownAdapter(); void shutdownAdapter();
AbstractGdbProcess *gdbProc() { return &m_gdbProc; } AbstractGdbProcess *gdbProc() { return &m_gdbProc; }