forked from qt-creator/qt-creator
Debugger: Consolidate some GDB-through-Python interaction
Instead of calling a GDB extension command invoking a function on the well-known Dumper instance, call the Dumper function directly. This also makes the code more similar to the LLDB side. Change-Id: I4b23177eb72a904721b63c578ce7fbfe204f02a2 Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
@@ -1707,7 +1707,8 @@ class DumperBase:
|
|||||||
|
|
||||||
findDumperFunctions()
|
findDumperFunctions()
|
||||||
|
|
||||||
def addDumperModule(self, path):
|
def addDumperModule(self, args):
|
||||||
|
path = args['path']
|
||||||
(head, tail) = os.path.split(path)
|
(head, tail) = os.path.split(path)
|
||||||
sys.path.insert(1, head)
|
sys.path.insert(1, head)
|
||||||
self.dumpermodules.append(os.path.splitext(tail)[0])
|
self.dumpermodules.append(os.path.splitext(tail)[0])
|
||||||
|
@@ -1696,6 +1696,10 @@ class Dumper(DumperBase):
|
|||||||
|
|
||||||
self.qmlBreakpoints.append(Resolver(self, args))
|
self.qmlBreakpoints.append(Resolver(self, args))
|
||||||
|
|
||||||
|
def exitGdb(self, _):
|
||||||
|
if hasPlot:
|
||||||
|
matplotQuit()
|
||||||
|
gdb.execute("quit")
|
||||||
|
|
||||||
|
|
||||||
class CliDumper(Dumper):
|
class CliDumper(Dumper):
|
||||||
@@ -1860,17 +1864,6 @@ def threadnames(arg):
|
|||||||
|
|
||||||
registerCommand("threadnames", threadnames)
|
registerCommand("threadnames", threadnames)
|
||||||
|
|
||||||
#######################################################################
|
|
||||||
#
|
|
||||||
# Reload Command
|
|
||||||
#
|
|
||||||
#######################################################################
|
|
||||||
|
|
||||||
def reloadDumper(_):
|
|
||||||
theDumper.reloadDumper();
|
|
||||||
|
|
||||||
registerCommand("reload", reloadDumper)
|
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
#
|
#
|
||||||
# StackFrames Command
|
# StackFrames Command
|
||||||
@@ -1891,25 +1884,6 @@ def stackListFrames(arg):
|
|||||||
|
|
||||||
registerCommand("stackListFrames", stackListFrames)
|
registerCommand("stackListFrames", stackListFrames)
|
||||||
|
|
||||||
#######################################################################
|
|
||||||
#
|
|
||||||
# AddExtraDumpers Command
|
|
||||||
#
|
|
||||||
#######################################################################
|
|
||||||
|
|
||||||
def addExtraDumper(args):
|
|
||||||
theDumper.addDumperModule(args)
|
|
||||||
|
|
||||||
registerCommand("addExtraDumper", addExtraDumper)
|
|
||||||
|
|
||||||
def exitGdb(arg):
|
|
||||||
if hasPlot:
|
|
||||||
matplotQuit()
|
|
||||||
gdb.execute("quit")
|
|
||||||
return ""
|
|
||||||
|
|
||||||
registerCommand("exitGdb", exitGdb)
|
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
#
|
#
|
||||||
# Native Mixed
|
# Native Mixed
|
||||||
|
@@ -1633,10 +1633,6 @@ class Dumper(DumperBase):
|
|||||||
error = str(result.GetError())
|
error = str(result.GetError())
|
||||||
self.report('success="%d",output="%s",error="%s"' % (success, output, error))
|
self.report('success="%d",output="%s",error="%s"' % (success, output, error))
|
||||||
|
|
||||||
def addExtraDumper(self, args):
|
|
||||||
self.addDumperModule(args['path'])
|
|
||||||
self.report('ok')
|
|
||||||
|
|
||||||
def updateData(self, args):
|
def updateData(self, args):
|
||||||
if 'expanded' in args:
|
if 'expanded' in args:
|
||||||
self.expandedINames = set(args['expanded'].split(','))
|
self.expandedINames = set(args['expanded'].split(','))
|
||||||
|
@@ -1884,11 +1884,15 @@ void GdbEngine::notifyAdapterShutdownOk()
|
|||||||
.arg(lastGoodState()).arg(m_gdbProc->state()));
|
.arg(lastGoodState()).arg(m_gdbProc->state()));
|
||||||
m_commandsDoneCallback = 0;
|
m_commandsDoneCallback = 0;
|
||||||
switch (m_gdbProc->state()) {
|
switch (m_gdbProc->state()) {
|
||||||
case QProcess::Running:
|
case QProcess::Running: {
|
||||||
if (startParameters().closeMode == KillAndExitMonitorAtClose)
|
if (startParameters().closeMode == KillAndExitMonitorAtClose)
|
||||||
postCommand("monitor exit");
|
postCommand("monitor exit");
|
||||||
postCommand("exitGdb", GdbEngine::ExitRequest, CB(handleGdbExit));
|
DebuggerCommand cmd("exitGdb");
|
||||||
|
cmd.flags = GdbEngine::ExitRequest;
|
||||||
|
cmd.callback = CB(handleGdbExit);
|
||||||
|
runCommand(cmd);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case QProcess::NotRunning:
|
case QProcess::NotRunning:
|
||||||
// Cannot find executable.
|
// Cannot find executable.
|
||||||
notifyEngineShutdownOk();
|
notifyEngineShutdownOk();
|
||||||
@@ -4287,8 +4291,11 @@ void GdbEngine::startGdb(const QStringList &args)
|
|||||||
postCommand("python from gdbbridge import *", flags);
|
postCommand("python from gdbbridge import *", flags);
|
||||||
|
|
||||||
const QString path = stringSetting(ExtraDumperFile);
|
const QString path = stringSetting(ExtraDumperFile);
|
||||||
if (!path.isEmpty())
|
if (!path.isEmpty()) {
|
||||||
postCommand("python addExtraDumper('" + path.toUtf8() + "')", flags);
|
DebuggerCommand cmd("addDumperModule");
|
||||||
|
cmd.arg("path", path.toUtf8());
|
||||||
|
runCommand(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
const QString commands = stringSetting(ExtraDumperCommands);
|
const QString commands = stringSetting(ExtraDumperCommands);
|
||||||
if (!commands.isEmpty())
|
if (!commands.isEmpty())
|
||||||
@@ -4324,7 +4331,7 @@ void GdbEngine::loadInitScript()
|
|||||||
|
|
||||||
void GdbEngine::reloadDebuggingHelpers()
|
void GdbEngine::reloadDebuggingHelpers()
|
||||||
{
|
{
|
||||||
postCommand("reload");
|
runCommand("reloadDumper");
|
||||||
reloadLocals();
|
reloadLocals();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -285,7 +285,7 @@ void LldbEngine::setupInferior()
|
|||||||
|
|
||||||
const QString path = stringSetting(ExtraDumperFile);
|
const QString path = stringSetting(ExtraDumperFile);
|
||||||
if (!path.isEmpty()) {
|
if (!path.isEmpty()) {
|
||||||
DebuggerCommand cmd("addExtraDumper");
|
DebuggerCommand cmd("addDumperModule");
|
||||||
cmd.arg("path", path.toUtf8());
|
cmd.arg("path", path.toUtf8());
|
||||||
runCommand(cmd);
|
runCommand(cmd);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user