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

Method handle

plugins/debuggercommon/miframestackmodel.cpp:100–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98 : model(model), m_thread(thread) , m_to(to) {}
99
100 void handle(const ResultRecord &r) override
101 {
102 static const auto levelField = QStringLiteral("level");
103 const Value& stack = r[QStringLiteral("stack")];
104 const auto& firstFrame = stack[0];
105
106 if (stack.size() == 1
107 && !firstFrame.hasField(levelField)
108 // If the hasField() call above does not throw an exception, firstFrame is guaranteed to be a TupleValue.
109 && static_cast<const TupleValue&>(firstFrame).results_by_name.empty()) {
110 // LLDB-MI replies with `stack=[{}]` if the session state is not paused.
111 // This occurs if the exec-continue command is queued and sent just before the stack-list-frames command.
112 qCDebug(DEBUGGERCOMMON) << "debugger replied with `stack=[{}]`, setting zero frames and no more frames";
113 model->setFrames(m_thread, {});
114 model->setHasMoreFrames(m_thread, false);
115 return;
116 }
117
118 const auto first = firstFrame[levelField].toInt();
119 QVector<KDevelop::FrameStackModel::FrameItem> frames;
120 frames.reserve(stack.size());
121 for (int i = 0; i< stack.size(); ++i) {
122 const Value& frame = stack[i];
123 KDevelop::FrameStackModel::FrameItem f;
124 f.nr = frame[levelField].toInt();
125 f.name = getFunctionOrAddress(frame);
126 QPair<QString, int> loc = getSource(frame);
127 f.file = QUrl::fromLocalFile(loc.first).adjusted(QUrl::NormalizePathSegments);
128 f.line = loc.second;
129 frames << f;
130 }
131 bool hasMore = false;
132 if (!frames.isEmpty()) {
133 if (frames.last().nr == m_to+1) {
134 frames.removeLast();
135 hasMore = true;
136 }
137 }
138 if (first == 0) {
139 model->setFrames(m_thread, frames);
140 } else {
141 model->insertFrames(m_thread, frames);
142 }
143 model->setHasMoreFrames(m_thread, hasMore);
144 }
145private:
146 MIFrameStackModel* model;
147 int m_thread;

Callers

nothing calls this directly

Calls 12

getSourceFunction · 0.85
hasFieldMethod · 0.80
emptyMethod · 0.80
setFramesMethod · 0.80
setHasMoreFramesMethod · 0.80
toIntMethod · 0.80
insertFramesMethod · 0.80
getFunctionOrAddressFunction · 0.70
sizeMethod · 0.45
reserveMethod · 0.45
isEmptyMethod · 0.45
lastMethod · 0.45

Tested by

no test coverage detected