forked from qt-creator/qt-creator
Debugger: Move Python setup closer to debugger startup
It's unconditional nowadays, so we don't gain anything but code path complexity from defering it. Change-Id: Icc7d65835d1b2b76ecb64601822e0d70fd8f9f6e Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
@@ -92,7 +92,6 @@ void GdbAttachEngine::handleAttach(const GdbResponse &response)
|
|||||||
case GdbResultRunning:
|
case GdbResultRunning:
|
||||||
showMessage(_("INFERIOR ATTACHED"));
|
showMessage(_("INFERIOR ATTACHED"));
|
||||||
showMessage(msgAttachedToStoppedInferior(), StatusBar);
|
showMessage(msgAttachedToStoppedInferior(), StatusBar);
|
||||||
tryLoadPythonDumpers();
|
|
||||||
handleInferiorPrepared();
|
handleInferiorPrepared();
|
||||||
break;
|
break;
|
||||||
case GdbResultError:
|
case GdbResultError:
|
||||||
|
@@ -200,8 +200,6 @@ void GdbCoreEngine::handleTargetCore(const GdbResponse &response)
|
|||||||
{
|
{
|
||||||
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
|
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
|
||||||
if (response.resultClass == GdbResultDone) {
|
if (response.resultClass == GdbResultDone) {
|
||||||
// HACK: The namespace is not accessible in the initial run.
|
|
||||||
tryLoadPythonDumpers();
|
|
||||||
showMessage(tr("Attached to core."), StatusBar);
|
showMessage(tr("Attached to core."), StatusBar);
|
||||||
handleInferiorPrepared();
|
handleInferiorPrepared();
|
||||||
// Due to the auto-solib-add off setting, we don't have any
|
// Due to the auto-solib-add off setting, we don't have any
|
||||||
|
@@ -1365,8 +1365,6 @@ void GdbEngine::handleStopResponse(const GdbMi &data)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tryLoadPythonDumpers();
|
|
||||||
|
|
||||||
bool gotoHandleStop1 = true;
|
bool gotoHandleStop1 = true;
|
||||||
if (!m_fullStartDone) {
|
if (!m_fullStartDone) {
|
||||||
m_fullStartDone = true;
|
m_fullStartDone = true;
|
||||||
@@ -1723,9 +1721,7 @@ void GdbEngine::handleShowVersion(const GdbResponse &response)
|
|||||||
|
|
||||||
if (startParameters().multiProcess)
|
if (startParameters().multiProcess)
|
||||||
postCommand("set detach-on-fork off", ConsoleCommand);
|
postCommand("set detach-on-fork off", ConsoleCommand);
|
||||||
|
|
||||||
//postCommand("set build-id-verbose 2", ConsoleCommand);
|
//postCommand("set build-id-verbose 2", ConsoleCommand);
|
||||||
postCommand("python print(sys.version)", ConsoleCommand, CB(handleHasPython));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1734,13 +1730,9 @@ void GdbEngine::handleListFeatures(const GdbResponse &response)
|
|||||||
showMessage(_("FEATURES: " + response.toString()));
|
showMessage(_("FEATURES: " + response.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbEngine::handleHasPython(const GdbResponse &response)
|
|
||||||
{
|
|
||||||
Q_UNUSED(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GdbEngine::handlePythonSetup(const GdbResponse &response)
|
void GdbEngine::handlePythonSetup(const GdbResponse &response)
|
||||||
{
|
{
|
||||||
|
QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
|
||||||
if (response.resultClass == GdbResultDone) {
|
if (response.resultClass == GdbResultDone) {
|
||||||
const QString commands = debuggerCore()->stringSetting(GdbCustomDumperCommands);
|
const QString commands = debuggerCore()->stringSetting(GdbCustomDumperCommands);
|
||||||
if (!commands.isEmpty()) {
|
if (!commands.isEmpty()) {
|
||||||
@@ -1765,6 +1757,13 @@ void GdbEngine::handlePythonSetup(const GdbResponse &response)
|
|||||||
}
|
}
|
||||||
watchHandler()->addTypeFormats(type, formats);
|
watchHandler()->addTypeFormats(type, formats);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadInitScript();
|
||||||
|
QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
|
||||||
|
showMessage(_("ENGINE SUCCESSFULLY STARTED"));
|
||||||
|
notifyEngineSetupOk();
|
||||||
|
} else {
|
||||||
|
notifyEngineSetupFailed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4338,19 +4337,21 @@ void GdbEngine::startGdb(const QStringList &args)
|
|||||||
postCommand("set detach-on-fork off");
|
postCommand("set detach-on-fork off");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dummy command to guarantee a roundtrip before the adapter proceed.
|
// Finally, set up Python.
|
||||||
|
// We need to guarantee a roundtrip before the adapter proceeds.
|
||||||
// Make sure this stays the last command in startGdb().
|
// Make sure this stays the last command in startGdb().
|
||||||
// Don't use ConsoleCommand, otherwise Mac won't markup the output.
|
// Don't use ConsoleCommand, otherwise Mac won't markup the output.
|
||||||
postCommand("pwd", CB(reportEngineSetupOk));
|
const QByteArray dumperSourcePath =
|
||||||
}
|
Core::ICore::resourcePath().toLocal8Bit() + "/debugger/";
|
||||||
|
|
||||||
void GdbEngine::reportEngineSetupOk(const GdbResponse &response)
|
const QFileInfo gdbBinaryFile(m_gdb);
|
||||||
{
|
const QByteArray uninstalledData = gdbBinaryFile.absolutePath().toLocal8Bit()
|
||||||
loadInitScript();
|
+ "/data-directory/python";
|
||||||
Q_UNUSED(response);
|
|
||||||
QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
|
const GdbCommandFlags flags = ConsoleCommand | Immediate;
|
||||||
showMessage(_("ENGINE SUCCESSFULLY STARTED"));
|
postCommand("python sys.path.insert(1, '" + dumperSourcePath + "')", flags);
|
||||||
notifyEngineSetupOk();
|
postCommand("python sys.path.append('" + uninstalledData + "')", flags);
|
||||||
|
postCommand("python from gdbbridge import *", flags, CB(handlePythonSetup));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbEngine::handleGdbStartFailed()
|
void GdbEngine::handleGdbStartFailed()
|
||||||
@@ -4379,24 +4380,9 @@ void GdbEngine::loadInitScript()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbEngine::tryLoadPythonDumpers()
|
|
||||||
{
|
|
||||||
const QByteArray dumperSourcePath =
|
|
||||||
Core::ICore::resourcePath().toLocal8Bit() + "/debugger/";
|
|
||||||
|
|
||||||
const QFileInfo gdbBinaryFile(m_gdb);
|
|
||||||
const QByteArray uninstalledData = gdbBinaryFile.absolutePath().toLocal8Bit()
|
|
||||||
+ "/data-directory/python";
|
|
||||||
|
|
||||||
const GdbCommandFlags flags = ConsoleCommand | Immediate;
|
|
||||||
postCommand("python sys.path.insert(1, '" + dumperSourcePath + "')", flags);
|
|
||||||
postCommand("python sys.path.append('" + uninstalledData + "')", flags);
|
|
||||||
postCommand("python from gdbbridge import *", flags, CB(handlePythonSetup));
|
|
||||||
}
|
|
||||||
|
|
||||||
void GdbEngine::reloadDebuggingHelpers()
|
void GdbEngine::reloadDebuggingHelpers()
|
||||||
{
|
{
|
||||||
tryLoadPythonDumpers();
|
postCommand("bbsetup");
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbEngine::handleGdbError(QProcess::ProcessError error)
|
void GdbEngine::handleGdbError(QProcess::ProcessError error)
|
||||||
|
@@ -94,14 +94,11 @@ private: ////////// General State //////////
|
|||||||
protected: ////////// Gdb Process Management //////////
|
protected: ////////// Gdb Process Management //////////
|
||||||
|
|
||||||
void startGdb(const QStringList &args = QStringList());
|
void startGdb(const QStringList &args = QStringList());
|
||||||
void reportEngineSetupOk(const GdbResponse &response);
|
|
||||||
void handleCheckForPython(const GdbResponse &response);
|
|
||||||
void handleInferiorShutdown(const GdbResponse &response);
|
void handleInferiorShutdown(const GdbResponse &response);
|
||||||
void handleGdbExit(const GdbResponse &response);
|
void handleGdbExit(const GdbResponse &response);
|
||||||
void handleNamespaceExtraction(const GdbResponse &response);
|
void handleNamespaceExtraction(const GdbResponse &response);
|
||||||
|
|
||||||
void loadInitScript();
|
void loadInitScript();
|
||||||
void tryLoadPythonDumpers();
|
|
||||||
|
|
||||||
// Something went wrong with the adapter *before* adapterStarted() was emitted.
|
// Something went wrong with the adapter *before* adapterStarted() was emitted.
|
||||||
// Make sure to clean up everything before emitting this signal.
|
// Make sure to clean up everything before emitting this signal.
|
||||||
@@ -251,7 +248,6 @@ protected:
|
|||||||
// Gdb initialization sequence
|
// Gdb initialization sequence
|
||||||
void handleShowVersion(const GdbResponse &response);
|
void handleShowVersion(const GdbResponse &response);
|
||||||
void handleListFeatures(const GdbResponse &response);
|
void handleListFeatures(const GdbResponse &response);
|
||||||
void handleHasPython(const GdbResponse &response);
|
|
||||||
void handlePythonSetup(const GdbResponse &response);
|
void handlePythonSetup(const GdbResponse &response);
|
||||||
|
|
||||||
int m_gdbVersion; // 7.6.1 is 70601
|
int m_gdbVersion; // 7.6.1 is 70601
|
||||||
|
Reference in New Issue
Block a user