Commit 20396d78 authored by hjk's avatar hjk

Debugger: Use Python for GDB stack extraction in native mixed mode

Change-Id: I7ca4a080c9b5e5992f44e5f3d8aa5af7296abe99
Reviewed-by: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
parent bf9b6317
......@@ -1697,8 +1697,8 @@ class Dumper(DumperBase):
return typeobj
def stackListFrames(self, n):
self.prepare("options:pe")
def stackListFrames(self, n, options):
self.prepare("options:" + options + ",pe")
self.output = []
frame = gdb.newest_frame()
......@@ -1912,9 +1912,16 @@ registerCommand("reload", reloadDumper)
#######################################################################
def stackListFrames(arg):
args = arg.split(' ')
limit = int(args[1]) if len(args) >= 2 else 1000
return theDumper.stackListFrames(limit)
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)
......
......@@ -1241,7 +1241,8 @@ void GdbEngine::updateAll()
//PENDING_DEBUG("UPDATING ALL\n");
QTC_CHECK(state() == InferiorUnrunnable || state() == InferiorStopOk);
reloadModulesInternal();
postCommand("stackListFrames", CB(handleStackListFrames),
int depth = action(MaximalStackDepth)->value().toInt();
postCommand(stackCommand(depth), CB(handleStackListFrames),
QVariant::fromValue<StackCookie>(StackCookie(false, true)));
stackHandler()->setCurrentIndex(0);
postCommand("-thread-info", CB(handleThreadInfo), 0);
......@@ -3239,7 +3240,7 @@ void GdbEngine::reloadFullStack()
{
PENDING_DEBUG("RELOAD FULL STACK");
resetLocation();
postCommand("stackListFrames", Discardable, CB(handleStackListFrames),
postCommand(stackCommand(-1), Discardable, CB(handleStackListFrames),
QVariant::fromValue<StackCookie>(StackCookie(true, true)));
}
......@@ -3327,14 +3328,29 @@ void GdbEngine::handleQmlStackTrace(const GdbResponse &response)
stackHandler()->prependFrames(qmlFrames);
}
QByteArray GdbEngine::stackCommand(int depth)
{
QByteArray cmd;
if (isNativeMixedEnabled()) {
cmd = "stackListFrames " + QByteArray::number(depth) + ' ';
if (isNativeMixedActive())
cmd += "mixed";
else
cmd += "noopt";
} else {
if (depth == -1)
cmd = "-stack-list-frames";
else
cmd = "-stack-list-frames 0 " + QByteArray::number(depth);
}
return cmd;
}
void GdbEngine::reloadStack(bool forceGotoLocation)
{
PENDING_DEBUG("RELOAD STACK");
QByteArray cmd = "stackListFrames";
int stackDepth = action(MaximalStackDepth)->value().toInt();
if (stackDepth)
cmd += " 0 " + QByteArray::number(stackDepth);
postCommand(cmd, Discardable, CB(handleStackListFrames),
int depth = action(MaximalStackDepth)->value().toInt();
postCommand(stackCommand(depth), Discardable, CB(handleStackListFrames),
QVariant::fromValue<StackCookie>(StackCookie(false, forceGotoLocation)));
}
......@@ -3374,10 +3390,9 @@ void GdbEngine::handleStackListFrames(const GdbResponse &response)
StackCookie cookie = response.cookie.value<StackCookie>();
QList<StackFrame> stackFrames;
//GdbMi stack = response.data["stack"];
QByteArray out = response.consoleStreamOutput;
GdbMi stack;
stack.fromStringMultiple(out);
GdbMi stack = response.data["stack"]; // C++
if (!stack.isValid() || stack.childCount() == 0) // Mixed.
stack.fromStringMultiple(response.consoleStreamOutput);
if (!stack.isValid()) {
qDebug() << "FIXME: stack:" << stack.toString();
......@@ -3435,31 +3450,25 @@ void GdbEngine::activateFrame(int frameIndex)
}
QTC_ASSERT(frameIndex < handler->stackSize(), return);
if (handler->frameAt(frameIndex).language == QmlLanguage) {
gotoLocation(handler->frameAt(frameIndex));
return;
}
// Assuming the command always succeeds this saves a roundtrip.
// Otherwise the lines below would need to get triggered
// after a response to this -stack-select-frame here.
handler->setCurrentIndex(frameIndex);
QByteArray cmd = "-stack-select-frame";
//if (!m_currentThread.isEmpty())
// cmd += " --thread " + m_currentThread;
cmd += ' ';
cmd += QByteArray::number(frameIndex);
postCommand(cmd, Discardable, CB(handleStackSelectFrame));
gotoLocation(stackHandler()->currentFrame());
if (handler->frameAt(frameIndex).language != QmlLanguage) {
// Assuming the command always succeeds this saves a roundtrip.
// Otherwise the lines below would need to get triggered
// after a response to this -stack-select-frame here.
QByteArray cmd = "-stack-select-frame";
//if (!m_currentThread.isEmpty())
// cmd += " --thread " + m_currentThread;
cmd += ' ';
cmd += QByteArray::number(frameIndex);
postCommand(cmd, Discardable);
}
updateLocals();
reloadRegisters();
}
void GdbEngine::handleStackSelectFrame(const GdbResponse &response)
{
Q_UNUSED(response);
}
void GdbEngine::handleThreadInfo(const GdbResponse &response)
{
if (response.resultClass == GdbResultDone) {
......
......@@ -391,10 +391,10 @@ protected:
void updateAll();
void handleStackListFrames(const GdbResponse &response);
void handleStackSelectThread(const GdbResponse &response);
void handleStackSelectFrame(const GdbResponse &response);
void handleThreadListIds(const GdbResponse &response);
void handleThreadInfo(const GdbResponse &response);
void handleThreadNames(const GdbResponse &response);
QByteArray stackCommand(int depth);
Q_SLOT void reloadStack(bool forceGotoLocation);
Q_SLOT virtual void reloadFullStack();
virtual void loadAdditionalQmlStack();
......
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