Debugger: Complete switch to Python for GDB stack generation

The iteration in Python was only used for the 'native mixed'
case before. Seems reasonably fast and robust now to always
enable it. Also, make the calling code use 'runCommand'.

Change-Id: I10565a725dfaa9bf46c28739c69e9f2546498929
Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
hjk
2015-02-11 16:05:55 +01:00
parent e76c4839bb
commit f65cb6ae4d
3 changed files with 25 additions and 47 deletions

View File

@@ -1620,14 +1620,19 @@ class Dumper(DumperBase):
self.typesToReport[typestring] = typeobj
return typeobj
def stackListFrames(self, n, options):
def stackListFrames(self, args):
limit = int(args['limit'])
if limit <= 0:
limit = 10000
options = args['options']
self.prepare("options:" + options + ",pe")
self.output = []
frame = gdb.newest_frame()
i = 0
self.currentCallContext = None
while i < n and frame:
while i < limit and frame:
with OutputSafer(self):
name = frame.name()
functionName = "??" if name is None else name
@@ -1675,8 +1680,7 @@ class Dumper(DumperBase):
frame = frame.older()
i += 1
return ''.join(self.output)
print(''.join(self.output))
def createResolvePendingBreakpointsHookBreakpoint(self, args):
class Resolver(gdb.Breakpoint):
@@ -1864,26 +1868,6 @@ def threadnames(arg):
registerCommand("threadnames", threadnames)
#######################################################################
#
# StackFrames Command
#
#######################################################################
def stackListFrames(arg):
try:
args = arg.split(' ')
limit = int(args[0]) if len(args) > 0 else 10000
if limit <= 0:
limit = 10000
options = args[1] if len(args) > 1 else ""
return theDumper.stackListFrames(limit, options)
except:
import traceback
traceback.print_exc()
registerCommand("stackListFrames", stackListFrames)
#######################################################################
#
# Native Mixed

View File

@@ -1227,9 +1227,10 @@ void GdbEngine::updateAll()
//PENDING_DEBUG("UPDATING ALL\n");
QTC_CHECK(state() == InferiorUnrunnable || state() == InferiorStopOk);
reloadModulesInternal();
int depth = action(MaximalStackDepth)->value().toInt();
postCommand(stackCommand(depth), NoFlags,
[this](const DebuggerResponse &r) { handleStackListFrames(r, false); });
DebuggerCommand cmd = stackCommand(action(MaximalStackDepth)->value().toInt());
cmd.flags = NoFlags;
cmd.callback = [this](const DebuggerResponse &r) { handleStackListFrames(r, false); };
runCommand(cmd);
stackHandler()->setCurrentIndex(0);
postCommand("-thread-info", NoFlags, CB(handleThreadInfo));
reloadRegisters();
@@ -3182,8 +3183,10 @@ void GdbEngine::reloadFullStack()
{
PENDING_DEBUG("RELOAD FULL STACK");
resetLocation();
postCommand(stackCommand(-1), Discardable,
[this](const DebuggerResponse &r) { handleStackListFrames(r, true); });
DebuggerCommand cmd = stackCommand(-1);
cmd.flags = Discardable;
cmd.callback = [this](const DebuggerResponse &r) { handleStackListFrames(r, true); };
runCommand(cmd);
}
void GdbEngine::loadAdditionalQmlStack()
@@ -3270,30 +3273,21 @@ void GdbEngine::handleQmlStackTrace(const DebuggerResponse &response)
stackHandler()->prependFrames(qmlFrames);
}
QByteArray GdbEngine::stackCommand(int depth)
DebuggerCommand GdbEngine::stackCommand(int depth)
{
QByteArray cmd;
if (isNativeMixedEnabled()) {
cmd = "stackListFrames " + QByteArray::number(depth) + ' ';
if (isNativeMixedActive())
cmd += "nativemixed";
else
cmd += "noopt";
} else {
if (depth == -1)
cmd = "-stack-list-frames";
else
cmd = "-stack-list-frames 0 " + QByteArray::number(depth);
}
DebuggerCommand cmd("stackListFrames");
cmd.arg("limit", depth);
cmd.arg("options", isNativeMixedActive() ? "nativemixed" : "");
return cmd;
}
void GdbEngine::reloadStack()
{
PENDING_DEBUG("RELOAD STACK");
int depth = action(MaximalStackDepth)->value().toInt();
postCommand(stackCommand(depth), Discardable,
[this](const DebuggerResponse &r) { handleStackListFrames(r, false); });
DebuggerCommand cmd = stackCommand(action(MaximalStackDepth)->value().toInt());
cmd.flags = Discardable;
cmd.callback = [this](const DebuggerResponse &r) { handleStackListFrames(r, false); };
runCommand(cmd);
}
StackFrame GdbEngine::parseStackFrame(const GdbMi &frameMi, int level)

View File

@@ -369,7 +369,7 @@ protected:
void handleThreadListIds(const DebuggerResponse &response);
void handleThreadInfo(const DebuggerResponse &response);
void handleThreadNames(const DebuggerResponse &response);
QByteArray stackCommand(int depth);
DebuggerCommand stackCommand(int depth);
Q_SLOT void reloadStack();
Q_SLOT virtual void reloadFullStack();
virtual void loadAdditionalQmlStack();