MCPcopy Create free account
hub / github.com/KDE/kdevelop / handleThreadInfo

Method handleThreadInfo

plugins/lldb/controllers/framestackmodel.cpp:50–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48}
49
50void LldbFrameStackModel::handleThreadInfo(const ResultRecord& r)
51{
52 const Value& threads = r[QStringLiteral("threads")];
53
54 if (threads.kind == Value::StringLiteral && threads.literal() == QLatin1String{"[]"}) {
55 // LLDB-MI replies with `threads="[]"` if the session state is not paused.
56 // This occurs if the exec-continue command is queued and sent just before the thread-info command.
57 // The quotes around [] must be a LLDB-MI bug because the type
58 // of `threads` must be `list`, not `const` (aka string literal).
59 qCDebug(DEBUGGERLLDB)
60 << "debugger replied with `threads=\"[]\"`, setting zero threads and -1 as the current thread";
61 setThreads({});
62 setCurrentThread(-1);
63 return;
64 }
65
66 QVector<FrameStackModel::ThreadItem> threadsList;
67 threadsList.reserve(threads.size());
68 for (int gidx = 0; gidx != threads.size(); ++gidx) {
69 FrameStackModel::ThreadItem i;
70 const Value & threadMI = threads[gidx];
71 i.nr = threadMI[QStringLiteral("id")].toInt();
72 if (threadMI[QStringLiteral("state")].literal() == QLatin1String("stopped")) {
73 // lldb-mi returns multiple frame entry for each thread
74 // so can't directly use threadMI["frame"]
75 auto &th = static_cast<const TupleValue&>(threadMI);
76 Value *topFrame = nullptr;
77 for (auto res : th.results) {
78 if (res->variable == QLatin1String("frame")) {
79 if (!topFrame || (*res->value)[QStringLiteral("level")].toInt() < (*topFrame)[QStringLiteral("level")].toInt()) {
80 topFrame = res->value;
81 }
82 }
83 }
84 i.name = getFunctionOrAddress(*topFrame);
85 } else {
86 i.name = i18n("(running)");
87 }
88 threadsList << i;
89 }
90 setThreads(threadsList);
91 if (r.hasField(QStringLiteral("current-thread-id"))) {
92 int currentThreadId = r[QStringLiteral("current-thread-id")].toInt();
93
94 setCurrentThread(currentThreadId);
95
96 if (session()->hasCrashed()) {
97 setCrashedThreadIndex(currentThreadId);
98 }
99 }
100}
101
102#include "moc_framestackmodel.cpp"

Callers

nothing calls this directly

Calls 7

literalMethod · 0.80
toIntMethod · 0.80
hasFieldMethod · 0.80
hasCrashedMethod · 0.80
getFunctionOrAddressFunction · 0.70
reserveMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected