Debugger: Fix stack display on interrupt with LLDB

Recent regression, stack data was only pulled when hitting
a breakpoint, not on interrupt.

Change-Id: I3de29fceadd4c5492f4edaffca7577dae7ae3d11
Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
hjk
2015-03-25 16:34:03 +01:00
parent db9558cb88
commit 939e5e3b19
3 changed files with 35 additions and 14 deletions

View File

@@ -782,7 +782,8 @@ class Dumper(DumperBase):
return thread return thread
return None return None
def reportThreads(self): def reportThreads(self, args):
self.reportToken(args)
result = 'threads={threads=[' result = 'threads={threads=['
for i in xrange(0, self.process.GetNumThreads()): for i in xrange(0, self.process.GetNumThreads()):
thread = self.process.GetThreadAtIndex(i) thread = self.process.GetThreadAtIndex(i)
@@ -810,9 +811,13 @@ class Dumper(DumperBase):
result += ',file="%s"' % fileName(frame.line_entry.file) result += ',file="%s"' % fileName(frame.line_entry.file)
result += '}},' result += '}},'
result += '],current-thread-id="%s"},' % self.currentThread().id result += ']},'
self.report(result) self.report(result)
def reportCurrentThread(self, args):
self.reportToken(args)
self.report('current-thread={id="%s"}' % self.currentThread().id)
def firstUsableFrame(self, thread): def firstUsableFrame(self, thread):
for i in xrange(10): for i in xrange(10):
frame = thread.GetFrameAtIndex(i) frame = thread.GetFrameAtIndex(i)
@@ -1210,7 +1215,6 @@ class Dumper(DumperBase):
else: else:
state = self.process.GetState() state = self.process.GetState()
if state == lldb.eStateStopped: if state == lldb.eStateStopped:
self.reportThreads()
self.reportVariables() self.reportVariables()
def reportRegisters(self, _ = None): def reportRegisters(self, _ = None):
@@ -1329,7 +1333,6 @@ class Dumper(DumperBase):
stoppedThread = self.firstStoppedThread() stoppedThread = self.firstStoppedThread()
if stoppedThread: if stoppedThread:
self.process.SetSelectedThread(stoppedThread) self.process.SetSelectedThread(stoppedThread)
self.reportThreads()
elif eventType == lldb.SBProcess.eBroadcastBitInterrupt: # 2 elif eventType == lldb.SBProcess.eBroadcastBitInterrupt: # 2
pass pass
elif eventType == lldb.SBProcess.eBroadcastBitSTDOUT: elif eventType == lldb.SBProcess.eBroadcastBitSTDOUT:

View File

@@ -456,6 +456,8 @@ void LldbEngine::handleResponse(const QByteArray &response)
refreshRegisters(item); refreshRegisters(item);
else if (name == "threads") else if (name == "threads")
refreshThreads(item); refreshThreads(item);
else if (name == "current-thread")
refreshCurrentThread(item);
else if (name == "typeinfo") else if (name == "typeinfo")
refreshTypeInfo(item); refreshTypeInfo(item);
else if (name == "state") else if (name == "state")
@@ -567,10 +569,15 @@ void LldbEngine::activateFrame(int frameIndex)
void LldbEngine::selectThread(ThreadId threadId) void LldbEngine::selectThread(ThreadId threadId)
{ {
DebuggerCommand cmd("selectThread"); DebuggerCommand cmd1("selectThread");
cmd.arg("id", threadId.raw()); cmd1.arg("id", threadId.raw());
runCommand(cmd1);
DebuggerCommand cmd("reportStack");
cmd.arg("nativeMixed", isNativeMixedActive());
cmd.arg("stacklimit", action(MaximalStackDepth)->value().toInt());
cmd.arg("continuation", "updateLocals");
runCommand(cmd); runCommand(cmd);
updateAll();
} }
bool LldbEngine::stateAcceptsBreakpointChanges() const bool LldbEngine::stateAcceptsBreakpointChanges() const
@@ -823,6 +830,12 @@ bool LldbEngine::setToolTipExpression(const DebuggerToolTipContext &context)
void LldbEngine::updateAll() void LldbEngine::updateAll()
{ {
DebuggerCommand cmd1("reportThreads");
runCommand(cmd1);
DebuggerCommand cmd2("reportCurrentThread");
runCommand(cmd2);
DebuggerCommand cmd("reportStack"); DebuggerCommand cmd("reportStack");
cmd.arg("nativeMixed", isNativeMixedActive()); cmd.arg("nativeMixed", isNativeMixedActive());
cmd.arg("stacklimit", action(MaximalStackDepth)->value().toInt()); cmd.arg("stacklimit", action(MaximalStackDepth)->value().toInt());
@@ -1061,11 +1074,14 @@ void LldbEngine::refreshThreads(const GdbMi &threads)
{ {
ThreadsHandler *handler = threadsHandler(); ThreadsHandler *handler = threadsHandler();
handler->updateThreads(threads); handler->updateThreads(threads);
if (!handler->currentThread().isValid()) { updateViews(); // Adjust Threads combobox.
ThreadId other = handler->threadAt(0);
if (other.isValid())
selectThread(other);
} }
void LldbEngine::refreshCurrentThread(const GdbMi &data)
{
ThreadsHandler *handler = threadsHandler();
ThreadId id(data["id"].toInt());
handler->setCurrentThread(id);
updateViews(); // Adjust Threads combobox. updateViews(); // Adjust Threads combobox.
} }
@@ -1102,9 +1118,10 @@ void LldbEngine::refreshState(const GdbMi &reportedState)
} else { } else {
updateAll(); updateAll();
} }
} else if (newState == "inferiorstopok") } else if (newState == "inferiorstopok") {
notifyInferiorStopOk(); notifyInferiorStopOk();
else if (newState == "inferiorstopfailed") updateAll();
} else if (newState == "inferiorstopfailed")
notifyInferiorStopFailed(); notifyInferiorStopFailed();
else if (newState == "inferiorill") else if (newState == "inferiorill")
notifyInferiorIll(); notifyInferiorIll();

View File

@@ -148,6 +148,7 @@ private:
void refreshAll(const GdbMi &all); void refreshAll(const GdbMi &all);
void refreshThreads(const GdbMi &threads); void refreshThreads(const GdbMi &threads);
void refreshCurrentThread(const GdbMi &data);
void refreshStack(const GdbMi &stack); void refreshStack(const GdbMi &stack);
void refreshRegisters(const GdbMi &registers); void refreshRegisters(const GdbMi &registers);
void refreshLocals(const GdbMi &vars); void refreshLocals(const GdbMi &vars);