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 self.typesToReport[typestring] = typeobj
return 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.prepare("options:" + options + ",pe")
self.output = [] self.output = []
frame = gdb.newest_frame() frame = gdb.newest_frame()
i = 0 i = 0
self.currentCallContext = None self.currentCallContext = None
while i < n and frame: while i < limit and frame:
with OutputSafer(self): with OutputSafer(self):
name = frame.name() name = frame.name()
functionName = "??" if name is None else name functionName = "??" if name is None else name
@@ -1675,8 +1680,7 @@ class Dumper(DumperBase):
frame = frame.older() frame = frame.older()
i += 1 i += 1
print(''.join(self.output))
return ''.join(self.output)
def createResolvePendingBreakpointsHookBreakpoint(self, args): def createResolvePendingBreakpointsHookBreakpoint(self, args):
class Resolver(gdb.Breakpoint): class Resolver(gdb.Breakpoint):
@@ -1864,26 +1868,6 @@ def threadnames(arg):
registerCommand("threadnames", threadnames) 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 # Native Mixed

View File

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

View File

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