From cca1030432fcd570010cae9c54f65cdd0c5abf60 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 20 Jan 2015 20:19:55 +0100 Subject: [PATCH] Debugger: Add python command to add dumpers More flexible than hacking on the C++ side. Also registers the custom dumper path to make it reloadable like the "built-in" dumpers. Change-Id: I0405f7278e28eb75d83fdd4a861f5a5c32d97a0e Reviewed-by: Orgad Shaneh --- share/qtcreator/debugger/gdbbridge.py | 10 ++++++-- src/plugins/debugger/gdb/gdbengine.cpp | 32 +++++++++----------------- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/share/qtcreator/debugger/gdbbridge.py b/share/qtcreator/debugger/gdbbridge.py index 379db22d2c7..e8966afea4e 100644 --- a/share/qtcreator/debugger/gdbbridge.py +++ b/share/qtcreator/debugger/gdbbridge.py @@ -1930,8 +1930,14 @@ registerCommand("stackListFrames", stackListFrames) ####################################################################### # -# Mixed C++/Qml debugging +# AddExtraDumpers Command # ####################################################################### -bbsetup() +def addExtraDumper(args): + (head, tail) = os.path.split(args) + sys.path.insert(1, head) + dumpermodules.append(os.path.splitext(tail)[0]) + return str((head, tail)) + +registerCommand("addExtraDumper", addExtraDumper) diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 1141c85943f..aee9b572db5 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -1727,25 +1727,6 @@ void GdbEngine::handlePythonSetup(const GdbResponse &response) { QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state()); if (response.resultClass == GdbResultDone) { - bool needSetup = false; - - const QString path = stringSetting(ExtraDumperFile); - if (!path.isEmpty()) { - QFileInfo fi(path); - postCommand("python sys.path.insert(1, '" + fi.absolutePath().toUtf8() + "')"); - postCommand("python from " + fi.baseName().toUtf8() + " import *"); - needSetup = true; - } - - const QString commands = stringSetting(ExtraDumperCommands); - if (!commands.isEmpty()) { - postCommand(commands.toLocal8Bit()); - needSetup = true; - } - - if (needSetup) - postCommand("bbsetup"); - GdbMi data; data.fromStringMultiple(response.consoleStreamOutput); const GdbMi dumpers = data["dumpers"]; @@ -4350,14 +4331,23 @@ void GdbEngine::startGdb(const QStringList &args) 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)); + postCommand("python from gdbbridge import *", flags); + + const QString path = stringSetting(ExtraDumperFile); + if (!path.isEmpty()) + postCommand("python addExtraDumper('" + path.toUtf8() + "')", flags); + + const QString commands = stringSetting(ExtraDumperCommands); + if (!commands.isEmpty()) + postCommand(commands.toLocal8Bit(), flags); + + postCommand("bbsetup", flags, CB(handlePythonSetup)); } void GdbEngine::handleGdbStartFailed() { } - void GdbEngine::loadInitScript() { const QString script = startParameters().overrideStartScript;