void ThreadsHandler::updateThreads(const GdbMi &data) { // ^done,threads=[{id="1",target-id="Thread 0xb7fdc710 (LWP 4264)", // frame={level="0",addr="0x080530bf",func="testQString",args=[], // file="/.../app.cpp",fullname="/../app.cpp",line="1175"}, // state="stopped",core="0"}],current-thread-id="1" // Emit changed for previous frame. if (m_currentIndex != -1) { dataChanged(m_currentIndex); m_currentIndex = -1; } ThreadId currentId; const GdbMi current = data["current-thread-id"]; if (current.isValid()) currentId = ThreadId(current.data().toLongLong()); const QList<GdbMi> items = data["threads"].children(); const int n = items.size(); for (int index = 0; index != n; ++index) { const GdbMi item = items.at(index); const GdbMi frame = item["frame"]; ThreadData thread; thread.id = ThreadId(item["id"].toInt()); thread.targetId = item["target-id"].toLatin1(); thread.details = item["details"].toLatin1(); thread.core = item["core"].toLatin1(); thread.state = item["state"].toLatin1(); thread.address = frame["addr"].toAddress(); thread.function = frame["func"].toLatin1(); thread.fileName = frame["fullname"].toLatin1(); thread.lineNumber = frame["line"].toInt(); thread.module = QString::fromLocal8Bit(frame["from"].data()); thread.stopped = true; thread.name = item["name"].toLatin1(); if (thread.state == QLatin1String("running")) thread.stopped = false; if (thread.id == currentId) m_currentIndex = index; updateThread(thread); } if (m_currentIndex != -1) dataChanged(m_currentIndex); updateThreadBox(); }
void ThreadsHandler::setThreads(const Threads &threads) { beginResetModel(); m_threads = threads; bool found = false; for (int i = 0, n = m_threads.size(); i < n; ++i) if (threads.at(i).id == m_currentId) { found = true; break; } if (!found) m_currentId = ThreadId(); m_resetLocationScheduled = false; endResetModel(); updateThreadBox(); }
void ThreadsHandler::setCurrentThread(ThreadId id) { if (id == m_currentId) return; const int index = indexOf(id); if (index == -1) { qWarning("ThreadsHandler::setCurrentThreadId: No such thread %d.", int(id.raw())); return; } // Emit changed for previous frame. threadDataChanged(m_currentId); m_currentId = id; // Emit changed for new frame. threadDataChanged(m_currentId); updateThreadBox(); }