| 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 | } |
| 145 | private: |
| 146 | MIFrameStackModel* model; |
| 147 | int m_thread; |
nothing calls this directly
no test coverage detected