From fe0bddbd637806da13f5cb7077b993a95aee3610 Mon Sep 17 00:00:00 2001 From: hjk <hjk121@nokiamail.com> Date: Thu, 31 Oct 2013 16:04:18 +0100 Subject: [PATCH] Debugger: Rework dumper detection Recent versions of GDB seem to require 'make install' to find their Python bits. Given that this is not really an option, check the usual suspects, too. Change-Id: I5217c0184681d4a86992fe0b8989498843b26cea Reviewed-by: David Schulz <david.schulz@digia.com> Reviewed-by: hjk <hjk121@nokiamail.com> --- share/qtcreator/debugger/gdbbridge.py | 12 +++++------- src/plugins/debugger/gdb/gdbengine.cpp | 5 +++++ tests/auto/debugger/tst_dumpers.cpp | 5 +++++ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/share/qtcreator/debugger/gdbbridge.py b/share/qtcreator/debugger/gdbbridge.py index c4c7011ea84..787a84252c8 100644 --- a/share/qtcreator/debugger/gdbbridge.py +++ b/share/qtcreator/debugger/gdbbridge.py @@ -520,7 +520,6 @@ class Dumper(DumperBase): #warn("WATCHERS: %s" % watchers) #warn("PARTIAL: %s" % self.partialUpdate) #warn("NO LOCALS: %s" % self.noLocals) - module = sys.modules[__name__] # # Locals @@ -1759,13 +1758,12 @@ class Dumper(DumperBase): self.qqFormats = {} self.qqEditable = {} self.typeCache = {} - module = sys.modules[__name__] - #warn("KEYS: %s " % module.__dict__.keys()) - for name in module.__dict__.keys(): - #warn("KEY: %s " % name) - #warn("FUNCT: %s " % module.__dict__[name]) - self.registerDumper(name, module.__dict__[name]) + # It's __main__ from gui, gdbbridge from test. Brush over it... + for modname in ['__main__', 'gdbbridge']: + dic = sys.modules[modname].__dict__ + for name in dic.keys(): + self.registerDumper(name, dic[name]) result = "dumpers=[" for key, value in self.qqFormats.items(): diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index a8dc104cb41..b0beedef7d6 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -4936,7 +4936,12 @@ 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"; + postCommand("python sys.path.insert(1, '" + dumperSourcePath + "')", ConsoleCommand); + postCommand("python sys.path.append('" + uninstalledData + "')", ConsoleCommand); postCommand("python from gdbbridge import *", ConsoleCommand, CB(handlePythonSetup)); } diff --git a/tests/auto/debugger/tst_dumpers.cpp b/tests/auto/debugger/tst_dumpers.cpp index fe35584485c..89e9e0a507a 100644 --- a/tests/auto/debugger/tst_dumpers.cpp +++ b/tests/auto/debugger/tst_dumpers.cpp @@ -893,6 +893,10 @@ void tst_Dumpers::dumper() if (m_debuggerEngine == DumpTestGdbEngine) { exe = m_debuggerBinary; + + const QFileInfo gdbBinaryFile(QString::fromLatin1(exe)); + const QByteArray uninstalledData = gdbBinaryFile.absolutePath().toLocal8Bit() + "/data-directory/python"; + args << QLatin1String("-i") << QLatin1String("mi") << QLatin1String("-quiet") @@ -907,6 +911,7 @@ void tst_Dumpers::dumper() if (m_usePython) { cmds += "python sys.path.insert(1, '" + dumperDir + "')\n" + "python sys.path.append('" + uninstalledData + "')\n" "python from gdbbridge import *\n" "run " + nograb + "\n" "up\n" -- GitLab