| 56 | } |
| 57 | |
| 58 | void MIFrameStackModel::handleThreadInfo(const ResultRecord& r) |
| 59 | { |
| 60 | const Value& threads = r[QStringLiteral("threads")]; |
| 61 | |
| 62 | QVector<FrameStackModel::ThreadItem> threadsList; |
| 63 | threadsList.reserve(threads.size()); |
| 64 | for (int i = 0; i!= threads.size(); ++i) { |
| 65 | const auto &threadMI = threads[i]; |
| 66 | FrameStackModel::ThreadItem threadItem; |
| 67 | threadItem.nr = threadMI[QStringLiteral("id")].toInt(); |
| 68 | if (threadMI[QStringLiteral("state")].literal() == QLatin1String("stopped")) { |
| 69 | threadItem.name = getFunctionOrAddress(threadMI[QStringLiteral("frame")]); |
| 70 | } else { |
| 71 | threadItem.name = i18n("(running)"); |
| 72 | } |
| 73 | threadsList << threadItem; |
| 74 | } |
| 75 | // Sort the list by id, some old version of GDB |
| 76 | // reports them in backward order. We want UI to |
| 77 | // show thread IDs in the natural order. |
| 78 | std::sort(threadsList.begin(), threadsList.end(), |
| 79 | [](const FrameStackModel::ThreadItem &a, const FrameStackModel::ThreadItem &b){ |
| 80 | return a.nr < b.nr; |
| 81 | }); |
| 82 | |
| 83 | setThreads(threadsList); |
| 84 | if (r.hasField(QStringLiteral("current-thread-id"))) { |
| 85 | int currentThreadId = r[QStringLiteral("current-thread-id")].toInt(); |
| 86 | |
| 87 | setCurrentThread(currentThreadId); |
| 88 | |
| 89 | if (session()->hasCrashed()) { |
| 90 | setCrashedThreadIndex(currentThreadId); |
| 91 | } |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | struct FrameListHandler : public MICommandHandler |
| 96 | { |
nothing calls this directly
no test coverage detected