Commit 6d6e8de4 authored by hjk's avatar hjk

Debugger: Use Python instead of GDB/MI to retrieve stack

This will be useful to create artificial QML stack frames.

Change-Id: I41cb87f8dea69d88695fea46a1ae2b0270cbec1a
Reviewed-by: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
parent 50ad32a2
......@@ -1696,6 +1696,38 @@ class Dumper(DumperBase):
return type
def stackListFrames(self, n):
self.prepare("options:pe")
self.output = []
frame = gdb.newest_frame()
i = 0
t1 = 'frame={level="%s",addr="0x%x",func="%s",'
t1 += 'file="%s",fullname="%s",line="%s",from="%s"}'
while i < n and frame:
with OutputSafer(self):
name = frame.name()
functionName = "??" if name is None else name
fileName = ""
objfile = ""
fullName = ""
pc = frame.pc()
sal = frame.find_sal()
line = -1
if sal:
line = sal.line
symtab = sal.symtab
if not symtab is None:
objfile = symtab.objfile.filename
fileName = symtab.filename
fullName = symtab.fullname()
self.put(t1 % (i, pc, functionName, fileName, fullName, line, objfile))
frame = frame.older()
i += 1
return ''.join(self.output)
class CliDumper(Dumper):
def __init__(self):
Dumper.__init__(self)
......@@ -1871,6 +1903,19 @@ def reloadDumper(arg):
registerCommand("reload", reloadDumper)
#######################################################################
#
# StackFrames Command
#
#######################################################################
def stackListFrames(arg):
args = arg.split(' ')
limit = int(args[1]) if len(args) >= 2 else 1000
return theDumper.stackListFrames(limit)
registerCommand("stackListFrames", stackListFrames)
#######################################################################
#
# Mixed C++/Qml debugging
......
......@@ -1251,7 +1251,7 @@ void GdbEngine::updateAll()
//PENDING_DEBUG("UPDATING ALL\n");
QTC_CHECK(state() == InferiorUnrunnable || state() == InferiorStopOk);
reloadModulesInternal();
postCommand("-stack-list-frames", CB(handleStackListFrames),
postCommand("stackListFrames", CB(handleStackListFrames),
QVariant::fromValue<StackCookie>(StackCookie(false, true)));
stackHandler()->setCurrentIndex(0);
postCommand("-thread-info", CB(handleThreadInfo), 0);
......@@ -3240,7 +3240,7 @@ void GdbEngine::reloadFullStack()
{
PENDING_DEBUG("RELOAD FULL STACK");
resetLocation();
postCommand("-stack-list-frames", Discardable, CB(handleStackListFrames),
postCommand("stackListFrames", Discardable, CB(handleStackListFrames),
QVariant::fromValue<StackCookie>(StackCookie(true, true)));
}
......@@ -3331,7 +3331,7 @@ void GdbEngine::handleQmlStackTrace(const GdbResponse &response)
void GdbEngine::reloadStack(bool forceGotoLocation)
{
PENDING_DEBUG("RELOAD STACK");
QByteArray cmd = "-stack-list-frames";
QByteArray cmd = "stackListFrames";
int stackDepth = action(MaximalStackDepth)->value().toInt();
if (stackDepth)
cmd += " 0 " + QByteArray::number(stackDepth);
......@@ -3354,8 +3354,10 @@ StackFrame GdbEngine::parseStackFrame(const GdbMi &frameMi, int level)
frame.line = frameMi["line"].toInt();
frame.address = frameMi["addr"].toAddress();
frame.usable = QFileInfo(frame.file).isReadable();
if (frameMi["language"].data() == "js")
if (frameMi["language"].data() == "js") {
frame.language = QmlLanguage;
frame.fixQmlFrame(startParameters());
}
return frame;
}
......@@ -3373,7 +3375,11 @@ void GdbEngine::handleStackListFrames(const GdbResponse &response)
StackCookie cookie = response.cookie.value<StackCookie>();
QList<StackFrame> stackFrames;
GdbMi stack = response.data["stack"];
//GdbMi stack = response.data["stack"];
QByteArray out = response.consoleStreamOutput;
GdbMi stack;
stack.fromStringMultiple(out);
if (!stack.isValid()) {
qDebug() << "FIXME: stack:" << stack.toString();
return;
......
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