Commit 885f8b34 authored by hjk's avatar hjk

Debugger: Move python initialization after first stop

This enables access to object-specific plain gdb pretty printers
which are not available before startup.

Change-Id: Icc8cbec177825d4d1adb1957a618abb33cbbf319
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 88c1d9f1
......@@ -185,7 +185,7 @@ void GdbCoreEngine::handleTargetCore(const GdbResponse &response)
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
if (response.resultClass == GdbResultDone) {
// HACK: The namespace is not accessible in the initial run.
loadPythonDumpers();
tryLoadPythonDumpers();
showMessage(tr("Attached to core."), StatusBar);
handleInferiorPrepared();
// Due to the auto-solib-add off setting, we don't have any
......
......@@ -262,6 +262,7 @@ GdbEngine::GdbEngine(const DebuggerStartParameters &startParameters)
m_terminalTrap = startParameters.useTerminal;
m_fullStartDone = false;
m_forceAsyncModel = false;
m_pythonAttemptedToLoad = false;
invalidateSourcesList();
......@@ -1433,11 +1434,12 @@ void GdbEngine::handleStopResponse(const GdbMi &data)
return;
}
tryLoadPythonDumpers();
bool gotoHandleStop1 = true;
if (!m_fullStartDone) {
m_fullStartDone = true;
postCommand("sharedlibrary .*");
loadPythonDumpers();
postCommand("p 3", CB(handleStop1));
gotoHandleStop1 = false;
}
......@@ -4842,16 +4844,19 @@ void GdbEngine::startGdb(const QStringList &args)
} else {
m_fullStartDone = true;
postCommand("set auto-solib-add on", ConsoleCommand);
loadPythonDumpers();
}
// Dummy command to guarantee a roundtrip before the adapter proceed.
postCommand("pwd", ConsoleCommand, CB(reportEngineSetupOk));
if (debuggerCore()->boolSetting(MultiInferior)) {
//postCommand("set follow-exec-mode new");
postCommand("set detach-on-fork off");
}
// Quick check whether we have python.
postCommand("python print 43", ConsoleCommand, CB(handleHasPython));
// Dummy command to guarantee a roundtrip before the adapter proceed.
// Make sure this stays the last command in startGdb().
postCommand("pwd", ConsoleCommand, CB(reportEngineSetupOk));
}
void GdbEngine::reportEngineSetupOk(const GdbResponse &response)
......@@ -4888,10 +4893,15 @@ void GdbEngine::loadInitScript()
}
}
void GdbEngine::loadPythonDumpers()
void GdbEngine::tryLoadPythonDumpers()
{
if (m_forceAsyncModel)
return;
if (!m_hasPython)
return;
if (m_pythonAttemptedToLoad)
return;
m_pythonAttemptedToLoad = true;
const QByteArray dumperSourcePath =
Core::ICore::resourcePath().toLocal8Bit() + "/dumper/";
......@@ -4909,7 +4919,7 @@ void GdbEngine::loadPythonDumpers()
loadInitScript();
postCommand("bbsetup", ConsoleCommand, CB(handleHasPython));
postCommand("bbsetup", ConsoleCommand);
}
void GdbEngine::handleGdbError(QProcess::ProcessError error)
......
......@@ -230,12 +230,13 @@ protected: ////////// Gdb Process Management //////////
void startGdb(const QStringList &args = QStringList());
void reportEngineSetupOk(const GdbResponse &response);
void handleCheckForPython(const GdbResponse &response);
void handleInferiorShutdown(const GdbResponse &response);
void handleGdbExit(const GdbResponse &response);
void handleNamespaceExtraction(const GdbResponse &response);
void loadInitScript();
void loadPythonDumpers();
void tryLoadPythonDumpers();
void pythonDumpersFailed();
// Something went wrong with the adapter *before* adapterStarted() was emitted.
......@@ -705,6 +706,7 @@ protected:
// debug information.
bool attemptQuickStart() const;
bool m_fullStartDone;
bool m_pythonAttemptedToLoad;
// Test
bool m_forceAsyncModel;
......
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