Commit e8f8aaa2 authored by hjk's avatar hjk

Debugger: Fix dumper format choosing with GDB

... and further unify GDB and LLDB code paths.

Change-Id: Id89f3804c53190c4888082891fd3c3c55eceac84
Reviewed-by: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
parent 13d425b9
......@@ -1706,7 +1706,7 @@ class DumperBase:
except:
pass
def setupDumper(self, _ = {}):
def setupDumpers(self, _ = {}):
self.qqDumpers = {}
self.qqFormats = {}
self.qqEditable = {}
......@@ -1719,27 +1719,26 @@ class DumperBase:
item = dic[name]
self.registerDumper(name, item)
return self.reportDumpers()
def reportDumpers(self, _ = {}):
result = "dumpers=["
msg = "dumpers=["
for key, value in self.qqFormats.items():
if key in self.qqEditable:
result += '{type="%s",formats="%s",editable="true"},' % (key, value)
msg += '{type="%s",formats="%s",editable="true"},' % (key, value)
else:
result += '{type="%s",formats="%s"},' % (key, value)
result += ']'
return result
msg += '{type="%s",formats="%s"},' % (key, value)
msg += ']'
self.reportDumpers(msg)
def reloadDumper(self, args):
def reportDumpers(self, msg):
raise NotImplementedError # Pure
def reloadDumpers(self, args):
for mod in self.dumpermodules:
m = sys.modules[mod]
if sys.version_info[0] >= 3:
importlib.reload(m)
else:
reload(m)
self.setupDumper(args)
self.setupDumpers(args)
def addDumperModule(self, args):
path = args['path']
......
......@@ -1660,6 +1660,12 @@ class Dumper(DumperBase):
matplotQuit()
gdb.execute("quit")
def loadDumpers(self, args):
self.setupDumpers()
def reportDumpers(self, msg):
print(msg)
def profile1(self, args):
"""Internal profiling"""
import tempfile
......
......@@ -1670,10 +1670,12 @@ class Dumper(DumperBase):
result += ',offset="%s"},' % (addr - base)
self.report(result + ']')
def loadDumperFiles(self, args):
def loadDumpers(self, args):
self.reportToken(args)
result = self.setupDumper()
self.report(result)
self.setupDumpers()
def reportDumpers(self, msg):
self.report(msg)
def fetchMemory(self, args):
address = args['address']
......@@ -1721,7 +1723,7 @@ class Tester(Dumper):
self.expandedINames = set(expandedINames)
self.passExceptions = True
self.loadDumperFiles({})
self.loadDumpers({})
error = lldb.SBError()
self.target = self.debugger.CreateTarget(binary, None, None, True, error)
......
......@@ -4273,7 +4273,7 @@ void GdbEngine::startGdb(const QStringList &args)
if (!commands.isEmpty())
postCommand(commands.toLocal8Bit(), flags);
runCommand(DebuggerCommand("setupDumper", flags, CB(handlePythonSetup)));
runCommand(DebuggerCommand("loadDumpers", flags, CB(handlePythonSetup)));
}
void GdbEngine::handleGdbStartFailed()
......@@ -4303,7 +4303,7 @@ void GdbEngine::loadInitScript()
void GdbEngine::reloadDebuggingHelpers()
{
runCommand("reloadDumper");
runCommand("reloadDumpers");
reloadLocals();
}
......
......@@ -303,7 +303,7 @@ void LldbEngine::setupInferior()
runCommand(cmd);
}
DebuggerCommand cmd1("loadDumperFiles");
DebuggerCommand cmd1("loadDumpers");
runCommand(cmd1);
}
......@@ -1160,6 +1160,12 @@ void LldbEngine::reloadRegisters()
runCommand("reportRegisters");
}
void LldbEngine::reloadDebuggingHelpers()
{
runCommand("reloadDumpers");
updateAll();
}
void LldbEngine::fetchDisassembler(DisassemblerAgent *agent)
{
QPointer<DisassemblerAgent> p(agent);
......
......@@ -116,6 +116,7 @@ private:
void reloadRegisters();
void reloadSourceFiles() {}
void reloadFullStack();
void reloadDebuggingHelpers();
void fetchDisassembler(Internal::DisassemblerAgent *);
void refreshDisassembly(const GdbMi &data);
......
......@@ -1240,7 +1240,7 @@ void tst_Dumpers::dumper()
cmds += "python sys.path.insert(1, '" + dumperDir + "')\n"
"python sys.path.append('" + uninstalledData + "')\n"
"python from gdbbridge import *\n"
"python theDumper.setupDumper()\n"
"python theDumper.setupDumpers()\n"
"run " + nograb + "\n"
"python theDumper.showData({'fancy':1,'forcens':1,'autoderef':1,"
"'dyntype':1,'passExceptions':1,'expanded':[" + expandedq + "]})\n";
......
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