forked from qt-creator/qt-creator
Debugger: Streamline ThreadHandler
- Use the TreeItem/data pattern recently introduced with Breakpoints to remove the need of keeping track of id/object mapping. Opens possibility to have thread groups as intermediate level. - Use the ThreadHandler directly as model for the thread combobox to remove the need of manual combo box updates. - Move setting current thread from individual engines to central code. Change-Id: I030e21a4aa5ab30b0efbc84528d9cecf29cbbe30 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -1239,14 +1239,9 @@ void CdbEngine::updateAll()
|
|||||||
updateLocals();
|
updateLocals();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CdbEngine::selectThread(ThreadId threadId)
|
void CdbEngine::selectThread(const Thread &thread)
|
||||||
{
|
{
|
||||||
if (!threadId.isValid() || threadId == threadsHandler()->currentThread())
|
runCommand({'~' + thread->id() + " s", BuiltinCommand,
|
||||||
return;
|
|
||||||
|
|
||||||
threadsHandler()->setCurrentThread(threadId);
|
|
||||||
|
|
||||||
runCommand({'~' + QString::number(threadId.raw()) + " s", BuiltinCommand,
|
|
||||||
[this](const DebuggerResponse &) { reloadFullStack(); }});
|
[this](const DebuggerResponse &) { reloadFullStack(); }});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1809,7 +1804,7 @@ void CdbEngine::processStop(const GdbMi &stopReason, bool conditionalBreakPointT
|
|||||||
// Further examine stop and report to user
|
// Further examine stop and report to user
|
||||||
QString message;
|
QString message;
|
||||||
QString exceptionBoxMessage;
|
QString exceptionBoxMessage;
|
||||||
ThreadId forcedThreadId;
|
Thread forcedThread;
|
||||||
const unsigned stopFlags = examineStopReason(stopReason, &message, &exceptionBoxMessage,
|
const unsigned stopFlags = examineStopReason(stopReason, &message, &exceptionBoxMessage,
|
||||||
conditionalBreakPointTriggered);
|
conditionalBreakPointTriggered);
|
||||||
m_stopMode = NoStopRequested;
|
m_stopMode = NoStopRequested;
|
||||||
@@ -1847,7 +1842,7 @@ void CdbEngine::processStop(const GdbMi &stopReason, bool conditionalBreakPointT
|
|||||||
if (stopFlags & StopInArtificialThread) {
|
if (stopFlags & StopInArtificialThread) {
|
||||||
showMessage(tr("Switching to main thread..."), LogMisc);
|
showMessage(tr("Switching to main thread..."), LogMisc);
|
||||||
runCommand({"~0 s", NoFlags});
|
runCommand({"~0 s", NoFlags});
|
||||||
forcedThreadId = ThreadId(0);
|
forcedThread = Thread();
|
||||||
// Re-fetch stack again.
|
// Re-fetch stack again.
|
||||||
reloadFullStack();
|
reloadFullStack();
|
||||||
} else {
|
} else {
|
||||||
@@ -1872,8 +1867,8 @@ void CdbEngine::processStop(const GdbMi &stopReason, bool conditionalBreakPointT
|
|||||||
const GdbMi threads = stopReason["threads"];
|
const GdbMi threads = stopReason["threads"];
|
||||||
if (threads.isValid()) {
|
if (threads.isValid()) {
|
||||||
threadsHandler()->updateThreads(threads);
|
threadsHandler()->updateThreads(threads);
|
||||||
if (forcedThreadId.isValid())
|
if (forcedThread)
|
||||||
threadsHandler()->setCurrentThread(forcedThreadId);
|
threadsHandler()->setCurrentThread(forcedThread);
|
||||||
} else {
|
} else {
|
||||||
showMessage(stopReason["threaderror"].data(), LogError);
|
showMessage(stopReason["threaderror"].data(), LogError);
|
||||||
}
|
}
|
||||||
|
@@ -80,7 +80,7 @@ public:
|
|||||||
void executeDebuggerCommand(const QString &command) override;
|
void executeDebuggerCommand(const QString &command) override;
|
||||||
|
|
||||||
void activateFrame(int index) override;
|
void activateFrame(int index) override;
|
||||||
void selectThread(ThreadId threadId) override;
|
void selectThread(const Thread &thread) override;
|
||||||
|
|
||||||
bool stateAcceptsBreakpointChanges() const override;
|
bool stateAcceptsBreakpointChanges() const override;
|
||||||
bool acceptsBreakpoint(const BreakpointParameters ¶ms) const override;
|
bool acceptsBreakpoint(const BreakpointParameters ¶ms) const override;
|
||||||
|
@@ -397,8 +397,12 @@ public:
|
|||||||
|
|
||||||
void selectThread(int index)
|
void selectThread(int index)
|
||||||
{
|
{
|
||||||
ThreadId id = m_engine->threadsHandler()->threadAt(index);
|
const Thread thread = m_engine->threadsHandler()->rootItem()->childAt(index);
|
||||||
m_engine->selectThread(id);
|
QTC_ASSERT(thread, return);
|
||||||
|
// For immediate visual feedback.
|
||||||
|
m_engine->threadsHandler()->setCurrentThread(thread);
|
||||||
|
// Initiate the actual switching in the debugger backend.
|
||||||
|
m_engine->selectThread(thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleOperateByInstructionTriggered(bool on)
|
void handleOperateByInstructionTriggered(bool on)
|
||||||
@@ -745,6 +749,7 @@ void DebuggerEnginePrivate::setupViews()
|
|||||||
|
|
||||||
m_threadBox = new QComboBox;
|
m_threadBox = new QComboBox;
|
||||||
m_threadBox->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
m_threadBox->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
||||||
|
m_threadBox->setModel(m_threadsHandler.model());
|
||||||
connect(m_threadBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::activated),
|
connect(m_threadBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::activated),
|
||||||
this, &DebuggerEnginePrivate::selectThread);
|
this, &DebuggerEnginePrivate::selectThread);
|
||||||
|
|
||||||
@@ -857,15 +862,6 @@ bool DebuggerEngine::isModulesWindowVisible() const
|
|||||||
return d->m_modulesWindow->isVisible();
|
return d->m_modulesWindow->isVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerEngine::setThreadBoxContents(const QStringList &list, int index)
|
|
||||||
{
|
|
||||||
QSignalBlocker blocker(d->m_threadBox);
|
|
||||||
d->m_threadBox->clear();
|
|
||||||
for (const QString &item : list)
|
|
||||||
d->m_threadBox->addItem(item);
|
|
||||||
d->m_threadBox->setCurrentIndex(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DebuggerEngine::frameUp()
|
void DebuggerEngine::frameUp()
|
||||||
{
|
{
|
||||||
int currentIndex = stackHandler()->currentIndex();
|
int currentIndex = stackHandler()->currentIndex();
|
||||||
|
@@ -30,6 +30,7 @@
|
|||||||
#include "debuggeritem.h"
|
#include "debuggeritem.h"
|
||||||
#include "debuggerprotocol.h"
|
#include "debuggerprotocol.h"
|
||||||
#include "breakhandler.h"
|
#include "breakhandler.h"
|
||||||
|
#include "threadshandler.h"
|
||||||
|
|
||||||
#include <coreplugin/icontext.h>
|
#include <coreplugin/icontext.h>
|
||||||
#include <projectexplorer/devicesupport/idevice.h>
|
#include <projectexplorer/devicesupport/idevice.h>
|
||||||
@@ -37,7 +38,6 @@
|
|||||||
#include <texteditor/textmark.h>
|
#include <texteditor/textmark.h>
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
@@ -74,13 +74,11 @@ class RegisterHandler;
|
|||||||
class StackHandler;
|
class StackHandler;
|
||||||
class StackFrame;
|
class StackFrame;
|
||||||
class SourceFilesHandler;
|
class SourceFilesHandler;
|
||||||
class ThreadsHandler;
|
|
||||||
class WatchHandler;
|
class WatchHandler;
|
||||||
class WatchTreeView;
|
class WatchTreeView;
|
||||||
class DebuggerToolTipContext;
|
class DebuggerToolTipContext;
|
||||||
class MemoryViewSetupData;
|
class MemoryViewSetupData;
|
||||||
class TerminalRunner;
|
class TerminalRunner;
|
||||||
class ThreadId;
|
|
||||||
|
|
||||||
class DebuggerRunParameters
|
class DebuggerRunParameters
|
||||||
{
|
{
|
||||||
@@ -317,7 +315,7 @@ public:
|
|||||||
|
|
||||||
virtual void assignValueInDebugger(WatchItem *item,
|
virtual void assignValueInDebugger(WatchItem *item,
|
||||||
const QString &expr, const QVariant &value);
|
const QString &expr, const QVariant &value);
|
||||||
virtual void selectThread(Internal::ThreadId threadId) = 0;
|
virtual void selectThread(const Internal::Thread &thread) = 0;
|
||||||
|
|
||||||
virtual void executeRecordReverse(bool) {}
|
virtual void executeRecordReverse(bool) {}
|
||||||
virtual void executeReverse(bool) {}
|
virtual void executeReverse(bool) {}
|
||||||
@@ -417,8 +415,6 @@ public:
|
|||||||
bool isRegistersWindowVisible() const;
|
bool isRegistersWindowVisible() const;
|
||||||
bool isModulesWindowVisible() const;
|
bool isModulesWindowVisible() const;
|
||||||
|
|
||||||
void setThreadBoxContents(const QStringList &list, int index);
|
|
||||||
|
|
||||||
void openMemoryEditor();
|
void openMemoryEditor();
|
||||||
|
|
||||||
void handleExecDetach();
|
void handleExecDetach();
|
||||||
|
@@ -523,7 +523,7 @@ void GdbEngine::handleAsyncOutput(const QString &asyncClass, const GdbMi &result
|
|||||||
QString id = result["id"].data();
|
QString id = result["id"].data();
|
||||||
showStatusMessage(tr("Thread %1 created.").arg(id), 1000);
|
showStatusMessage(tr("Thread %1 created.").arg(id), 1000);
|
||||||
ThreadData thread;
|
ThreadData thread;
|
||||||
thread.id = ThreadId(id.toLong());
|
thread.id = id;
|
||||||
thread.groupId = result["group-id"].data();
|
thread.groupId = result["group-id"].data();
|
||||||
threadsHandler()->updateThread(thread);
|
threadsHandler()->updateThread(thread);
|
||||||
} else if (asyncClass == "thread-group-exited") {
|
} else if (asyncClass == "thread-group-exited") {
|
||||||
@@ -537,7 +537,7 @@ void GdbEngine::handleAsyncOutput(const QString &asyncClass, const GdbMi &result
|
|||||||
QString groupid = result["group-id"].data();
|
QString groupid = result["group-id"].data();
|
||||||
showStatusMessage(tr("Thread %1 in group %2 exited.")
|
showStatusMessage(tr("Thread %1 in group %2 exited.")
|
||||||
.arg(id).arg(groupid), 1000);
|
.arg(id).arg(groupid), 1000);
|
||||||
threadsHandler()->removeThread(ThreadId(id.toLong()));
|
threadsHandler()->removeThread(id);
|
||||||
} else if (asyncClass == "thread-selected") {
|
} else if (asyncClass == "thread-selected") {
|
||||||
QString id = result["id"].data();
|
QString id = result["id"].data();
|
||||||
showStatusMessage(tr("Thread %1 selected.").arg(id), 1000);
|
showStatusMessage(tr("Thread %1 selected.").arg(id), 1000);
|
||||||
@@ -2880,12 +2880,11 @@ void GdbEngine::reloadSourceFiles()
|
|||||||
//
|
//
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void GdbEngine::selectThread(ThreadId threadId)
|
void GdbEngine::selectThread(const Thread &thread)
|
||||||
{
|
{
|
||||||
threadsHandler()->setCurrentThread(threadId);
|
showStatusMessage(tr("Retrieving data for stack view thread %1...")
|
||||||
showStatusMessage(tr("Retrieving data for stack view thread 0x%1...")
|
.arg(thread->id()), 10000);
|
||||||
.arg(threadId.raw(), 0, 16), 10000);
|
DebuggerCommand cmd("-thread-select " + thread->id(), Discardable);
|
||||||
DebuggerCommand cmd("-thread-select " + QString::number(threadId.raw()), Discardable);
|
|
||||||
cmd.callback = [this](const DebuggerResponse &) {
|
cmd.callback = [this](const DebuggerResponse &) {
|
||||||
QTC_CHECK(state() == InferiorUnrunnable || state() == InferiorStopOk);
|
QTC_CHECK(state() == InferiorUnrunnable || state() == InferiorStopOk);
|
||||||
showStatusMessage(tr("Retrieving data for stack view..."), 3000);
|
showStatusMessage(tr("Retrieving data for stack view..."), 3000);
|
||||||
@@ -2987,9 +2986,8 @@ void GdbEngine::handleThreadInfo(const DebuggerResponse &response)
|
|||||||
ThreadsHandler *handler = threadsHandler();
|
ThreadsHandler *handler = threadsHandler();
|
||||||
handler->updateThreads(response.data);
|
handler->updateThreads(response.data);
|
||||||
// This is necessary as the current thread might not be in the list.
|
// This is necessary as the current thread might not be in the list.
|
||||||
if (!handler->currentThread().isValid()) {
|
if (!handler->currentThread()) {
|
||||||
ThreadId other = handler->threadAt(0);
|
if (Thread other = handler->threadAt(0))
|
||||||
if (other.isValid())
|
|
||||||
selectThread(other);
|
selectThread(other);
|
||||||
}
|
}
|
||||||
updateState(false); // Adjust Threads combobox.
|
updateState(false); // Adjust Threads combobox.
|
||||||
@@ -3011,9 +3009,9 @@ void GdbEngine::handleThreadListIds(const DebuggerResponse &response)
|
|||||||
// In gdb 7.1+ additionally: current-thread-id="1"
|
// In gdb 7.1+ additionally: current-thread-id="1"
|
||||||
ThreadsHandler *handler = threadsHandler();
|
ThreadsHandler *handler = threadsHandler();
|
||||||
const QVector<GdbMi> &items = response.data["thread-ids"].children();
|
const QVector<GdbMi> &items = response.data["thread-ids"].children();
|
||||||
for (int index = 0, n = items.size(); index != n; ++index) {
|
for (const GdbMi &item : items) {
|
||||||
ThreadData thread;
|
ThreadData thread;
|
||||||
thread.id = ThreadId(items.at(index).toInt());
|
thread.id = item.data();
|
||||||
handler->updateThread(thread);
|
handler->updateThread(thread);
|
||||||
}
|
}
|
||||||
reloadStack(); // Will trigger register reload.
|
reloadStack(); // Will trigger register reload.
|
||||||
@@ -3027,7 +3025,7 @@ void GdbEngine::handleThreadNames(const DebuggerResponse &response)
|
|||||||
names.fromString(response.consoleStreamOutput);
|
names.fromString(response.consoleStreamOutput);
|
||||||
for (const GdbMi &name : names.children()) {
|
for (const GdbMi &name : names.children()) {
|
||||||
ThreadData thread;
|
ThreadData thread;
|
||||||
thread.id = ThreadId(name["id"].toInt());
|
thread.id = name["id"].data();
|
||||||
thread.name = decodeData(name["value"].data(), name["valueencoded"].data());
|
thread.name = decodeData(name["value"].data(), name["valueencoded"].data());
|
||||||
handler->updateThread(thread);
|
handler->updateThread(thread);
|
||||||
}
|
}
|
||||||
|
@@ -219,7 +219,7 @@ private: ////////// General Interface //////////
|
|||||||
|
|
||||||
////////// View & Data Stuff //////////
|
////////// View & Data Stuff //////////
|
||||||
|
|
||||||
void selectThread(ThreadId threadId) final;
|
void selectThread(const Thread &thread) final;
|
||||||
void activateFrame(int index) final;
|
void activateFrame(int index) final;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@@ -444,17 +444,18 @@ void LldbEngine::activateFrame(int frameIndex)
|
|||||||
|
|
||||||
DebuggerCommand cmd("activateFrame");
|
DebuggerCommand cmd("activateFrame");
|
||||||
cmd.arg("index", frameIndex);
|
cmd.arg("index", frameIndex);
|
||||||
cmd.arg("thread", threadsHandler()->currentThread().raw());
|
cmd.arg("thread", threadsHandler()->currentThread()->id());
|
||||||
runCommand(cmd);
|
runCommand(cmd);
|
||||||
|
|
||||||
updateLocals();
|
updateLocals();
|
||||||
reloadRegisters();
|
reloadRegisters();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LldbEngine::selectThread(ThreadId threadId)
|
void LldbEngine::selectThread(const Thread &thread)
|
||||||
{
|
{
|
||||||
|
QTC_ASSERT(thread, return);
|
||||||
DebuggerCommand cmd("selectThread");
|
DebuggerCommand cmd("selectThread");
|
||||||
cmd.arg("id", threadId.raw());
|
cmd.arg("id", thread->id());
|
||||||
cmd.callback = [this](const DebuggerResponse &) {
|
cmd.callback = [this](const DebuggerResponse &) {
|
||||||
fetchStack(action(MaximalStackDepth)->value().toInt());
|
fetchStack(action(MaximalStackDepth)->value().toInt());
|
||||||
};
|
};
|
||||||
|
@@ -82,7 +82,7 @@ private:
|
|||||||
void executeJumpToLine(const ContextData &data) override;
|
void executeJumpToLine(const ContextData &data) override;
|
||||||
|
|
||||||
void activateFrame(int index) override;
|
void activateFrame(int index) override;
|
||||||
void selectThread(ThreadId threadId) override;
|
void selectThread(const Thread &thread) override;
|
||||||
void fetchFullBacktrace();
|
void fetchFullBacktrace();
|
||||||
|
|
||||||
// This should be always the last call in a function.
|
// This should be always the last call in a function.
|
||||||
|
@@ -240,9 +240,9 @@ void PdbEngine::activateFrame(int frameIndex)
|
|||||||
updateLocals();
|
updateLocals();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PdbEngine::selectThread(ThreadId threadId)
|
void PdbEngine::selectThread(const Thread &thread)
|
||||||
{
|
{
|
||||||
Q_UNUSED(threadId)
|
Q_UNUSED(thread)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PdbEngine::acceptsBreakpoint(const BreakpointParameters &bp) const
|
bool PdbEngine::acceptsBreakpoint(const BreakpointParameters &bp) const
|
||||||
|
@@ -69,7 +69,7 @@ private:
|
|||||||
void executeJumpToLine(const ContextData &data) override;
|
void executeJumpToLine(const ContextData &data) override;
|
||||||
|
|
||||||
void activateFrame(int index) override;
|
void activateFrame(int index) override;
|
||||||
void selectThread(ThreadId threadId) override;
|
void selectThread(const Thread &thread) override;
|
||||||
|
|
||||||
bool acceptsBreakpoint(const BreakpointParameters &bp) const override;
|
bool acceptsBreakpoint(const BreakpointParameters &bp) const override;
|
||||||
void insertBreakpoint(const Breakpoint &bp) override;
|
void insertBreakpoint(const Breakpoint &bp) override;
|
||||||
|
@@ -684,9 +684,9 @@ void QmlEngine::activateFrame(int index)
|
|||||||
d->updateLocals();
|
d->updateLocals();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlEngine::selectThread(ThreadId threadId)
|
void QmlEngine::selectThread(const Thread &thread)
|
||||||
{
|
{
|
||||||
Q_UNUSED(threadId)
|
Q_UNUSED(thread)
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlEngine::insertBreakpoint(const Breakpoint &bp)
|
void QmlEngine::insertBreakpoint(const Breakpoint &bp)
|
||||||
|
@@ -93,7 +93,7 @@ private:
|
|||||||
void executeJumpToLine(const ContextData &data) override;
|
void executeJumpToLine(const ContextData &data) override;
|
||||||
|
|
||||||
void activateFrame(int index) override;
|
void activateFrame(int index) override;
|
||||||
void selectThread(ThreadId threadId) override;
|
void selectThread(const Thread &thread) override;
|
||||||
|
|
||||||
bool acceptsBreakpoint(const BreakpointParameters &bp) const final;
|
bool acceptsBreakpoint(const BreakpointParameters &bp) const final;
|
||||||
void insertBreakpoint(const Breakpoint &bp) final;
|
void insertBreakpoint(const Breakpoint &bp) final;
|
||||||
|
@@ -31,28 +31,6 @@
|
|||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// ThreadId
|
|
||||||
//
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
/*! A typesafe identifier. */
|
|
||||||
class ThreadId
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ThreadId() = default;
|
|
||||||
explicit ThreadId(qint64 id) : m_id(id) {}
|
|
||||||
|
|
||||||
bool isValid() const { return m_id != -1; }
|
|
||||||
qint64 raw() const { return m_id; }
|
|
||||||
bool operator==(const ThreadId other) const { return m_id == other.m_id; }
|
|
||||||
bool operator!=(const ThreadId other) const { return m_id != other.m_id; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
qint64 m_id = -1;
|
|
||||||
};
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// ThreadData
|
// ThreadData
|
||||||
@@ -77,12 +55,10 @@ struct ThreadData
|
|||||||
CoreColumn,
|
CoreColumn,
|
||||||
ComboNameColumn,
|
ComboNameColumn,
|
||||||
ColumnCount = CoreColumn,
|
ColumnCount = CoreColumn,
|
||||||
|
|
||||||
IdRole = Qt::UserRole
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Permanent data.
|
// Permanent data.
|
||||||
ThreadId id;
|
QString id;
|
||||||
QString groupId;
|
QString groupId;
|
||||||
QString targetId;
|
QString targetId;
|
||||||
QString core;
|
QString core;
|
||||||
|
@@ -53,168 +53,156 @@ namespace Internal {
|
|||||||
//
|
//
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
class ThreadItem : public TreeItem
|
// ThreadItem
|
||||||
|
|
||||||
|
ThreadItem::ThreadItem(const ThreadsHandler *handler, const ThreadData &data)
|
||||||
|
: threadData(data), handler(handler)
|
||||||
|
{}
|
||||||
|
|
||||||
|
QVariant ThreadItem::data(int column, int role) const
|
||||||
{
|
{
|
||||||
Q_DECLARE_TR_FUNCTIONS(Debugger::Internal::ThreadsHandler)
|
switch (role) {
|
||||||
|
case Qt::DisplayRole:
|
||||||
public:
|
if (column == 0)
|
||||||
ThreadItem(const ThreadsHandler *handler, const ThreadData &data = ThreadData())
|
return QString("#%1 %2").arg(threadData.id).arg(threadData.name);
|
||||||
: threadData(data), handler(handler)
|
return threadPart(column);
|
||||||
{}
|
case Qt::ToolTipRole:
|
||||||
|
return threadToolTip();
|
||||||
QVariant data(int column, int role) const override
|
case Qt::DecorationRole:
|
||||||
{
|
// Return icon that indicates whether this is the active stack frame.
|
||||||
switch (role) {
|
if (column == 0)
|
||||||
case Qt::DisplayRole:
|
return this == handler->currentThread() ? Icons::LOCATION.icon()
|
||||||
return threadPart(column);
|
: Icons::EMPTY.icon();
|
||||||
case Qt::ToolTipRole:
|
break;
|
||||||
return threadToolTip();
|
default:
|
||||||
case Qt::DecorationRole:
|
break;
|
||||||
// Return icon that indicates whether this is the active stack frame.
|
|
||||||
if (column == 0)
|
|
||||||
return threadData.id == handler->currentThread() ? Icons::LOCATION.icon()
|
|
||||||
: Icons::EMPTY.icon();
|
|
||||||
break;
|
|
||||||
case ThreadData::IdRole:
|
|
||||||
return threadData.id.raw();
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return QVariant();
|
|
||||||
}
|
}
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
Qt::ItemFlags flags(int column) const override
|
Qt::ItemFlags ThreadItem::flags(int column) const
|
||||||
{
|
{
|
||||||
return threadData.stopped ? TreeItem::flags(column) : Qt::ItemFlags({});
|
return threadData.stopped ? TreeItem::flags(column) : Qt::ItemFlags({});
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ThreadItem::threadToolTip() const
|
||||||
|
{
|
||||||
|
const char start[] = "<tr><td>";
|
||||||
|
const char sep[] = "</td><td>";
|
||||||
|
const char end[] = "</td>";
|
||||||
|
QString rc;
|
||||||
|
QTextStream str(&rc);
|
||||||
|
str << "<html><head/><body><table>"
|
||||||
|
<< start << ThreadsHandler::tr("Thread id:")
|
||||||
|
<< sep << threadData.id << end;
|
||||||
|
if (!threadData.targetId.isEmpty())
|
||||||
|
str << start << ThreadsHandler::tr("Target id:")
|
||||||
|
<< sep << threadData.targetId << end;
|
||||||
|
if (!threadData.groupId.isEmpty())
|
||||||
|
str << start << ThreadsHandler::tr("Group id:")
|
||||||
|
<< sep << threadData.groupId << end;
|
||||||
|
if (!threadData.name.isEmpty())
|
||||||
|
str << start << ThreadsHandler::tr("Name:")
|
||||||
|
<< sep << threadData.name << end;
|
||||||
|
if (!threadData.state.isEmpty())
|
||||||
|
str << start << ThreadsHandler::tr("State:")
|
||||||
|
<< sep << threadData.state << end;
|
||||||
|
if (!threadData.core.isEmpty())
|
||||||
|
str << start << ThreadsHandler::tr("Core:")
|
||||||
|
<< sep << threadData.core << end;
|
||||||
|
if (threadData.address) {
|
||||||
|
str << start << ThreadsHandler::tr("Stopped at:") << sep;
|
||||||
|
if (!threadData.function.isEmpty())
|
||||||
|
str << threadData.function << "<br>";
|
||||||
|
if (!threadData.fileName.isEmpty())
|
||||||
|
str << threadData.fileName << ':' << threadData.lineNumber << "<br>";
|
||||||
|
str << formatToolTipAddress(threadData.address);
|
||||||
}
|
}
|
||||||
|
str << "</table></body></html>";
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
QString threadToolTip() const
|
QVariant ThreadItem::threadPart(int column) const
|
||||||
{
|
{
|
||||||
const char start[] = "<tr><td>";
|
switch (column) {
|
||||||
const char sep[] = "</td><td>";
|
case ThreadData::IdColumn:
|
||||||
const char end[] = "</td>";
|
return threadData.id;
|
||||||
QString rc;
|
case ThreadData::FunctionColumn:
|
||||||
QTextStream str(&rc);
|
return threadData.function;
|
||||||
str << "<html><head/><body><table>"
|
case ThreadData::FileColumn:
|
||||||
<< start << ThreadsHandler::tr("Thread id:")
|
return threadData.fileName.isEmpty() ? threadData.module : threadData.fileName;
|
||||||
<< sep << threadData.id.raw() << end;
|
case ThreadData::LineColumn:
|
||||||
if (!threadData.targetId.isEmpty())
|
return threadData.lineNumber >= 0
|
||||||
str << start << ThreadsHandler::tr("Target id:")
|
? QString::number(threadData.lineNumber) : QString();
|
||||||
<< sep << threadData.targetId << end;
|
case ThreadData::AddressColumn:
|
||||||
if (!threadData.groupId.isEmpty())
|
return threadData.address > 0
|
||||||
str << start << ThreadsHandler::tr("Group id:")
|
? QLatin1String("0x") + QString::number(threadData.address, 16)
|
||||||
<< sep << threadData.groupId << end;
|
: QString();
|
||||||
if (!threadData.name.isEmpty())
|
case ThreadData::CoreColumn:
|
||||||
str << start << ThreadsHandler::tr("Name:")
|
return threadData.core;
|
||||||
<< sep << threadData.name << end;
|
case ThreadData::StateColumn:
|
||||||
if (!threadData.state.isEmpty())
|
return threadData.state;
|
||||||
str << start << ThreadsHandler::tr("State:")
|
case ThreadData::TargetIdColumn:
|
||||||
<< sep << threadData.state << end;
|
if (threadData.targetId.startsWith(QLatin1String("Thread ")))
|
||||||
if (!threadData.core.isEmpty())
|
return threadData.targetId.mid(7);
|
||||||
str << start << ThreadsHandler::tr("Core:")
|
return threadData.targetId;
|
||||||
<< sep << threadData.core << end;
|
case ThreadData::NameColumn:
|
||||||
if (threadData.address) {
|
return threadData.name;
|
||||||
str << start << ThreadsHandler::tr("Stopped at:") << sep;
|
case ThreadData::DetailsColumn:
|
||||||
if (!threadData.function.isEmpty())
|
return threadData.details;
|
||||||
str << threadData.function << "<br>";
|
case ThreadData::ComboNameColumn:
|
||||||
if (!threadData.fileName.isEmpty())
|
return QString::fromLatin1("#%1 %2").arg(threadData.id).arg(threadData.name);
|
||||||
str << threadData.fileName << ':' << threadData.lineNumber << "<br>";
|
|
||||||
str << formatToolTipAddress(threadData.address);
|
|
||||||
}
|
|
||||||
str << "</table></body></html>";
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
QVariant threadPart(int column) const
|
void ThreadItem::notifyRunning() // Clear state information.
|
||||||
{
|
{
|
||||||
switch (column) {
|
threadData.address = 0;
|
||||||
case ThreadData::IdColumn:
|
threadData.function.clear();
|
||||||
return threadData.id.raw();
|
threadData.fileName.clear();
|
||||||
case ThreadData::FunctionColumn:
|
threadData.frameLevel = -1;
|
||||||
return threadData.function;
|
threadData.state.clear();
|
||||||
case ThreadData::FileColumn:
|
threadData.lineNumber = -1;
|
||||||
return threadData.fileName.isEmpty() ? threadData.module : threadData.fileName;
|
threadData.stopped = false;
|
||||||
case ThreadData::LineColumn:
|
update();
|
||||||
return threadData.lineNumber >= 0
|
}
|
||||||
? QString::number(threadData.lineNumber) : QString();
|
|
||||||
case ThreadData::AddressColumn:
|
|
||||||
return threadData.address > 0
|
|
||||||
? QLatin1String("0x") + QString::number(threadData.address, 16)
|
|
||||||
: QString();
|
|
||||||
case ThreadData::CoreColumn:
|
|
||||||
return threadData.core;
|
|
||||||
case ThreadData::StateColumn:
|
|
||||||
return threadData.state;
|
|
||||||
case ThreadData::TargetIdColumn:
|
|
||||||
if (threadData.targetId.startsWith(QLatin1String("Thread ")))
|
|
||||||
return threadData.targetId.mid(7);
|
|
||||||
return threadData.targetId;
|
|
||||||
case ThreadData::NameColumn:
|
|
||||||
return threadData.name;
|
|
||||||
case ThreadData::DetailsColumn:
|
|
||||||
return threadData.details;
|
|
||||||
case ThreadData::ComboNameColumn:
|
|
||||||
return QString::fromLatin1("#%1 %2").arg(threadData.id.raw()).arg(threadData.name);
|
|
||||||
}
|
|
||||||
return QVariant();
|
|
||||||
}
|
|
||||||
|
|
||||||
void notifyRunning() // Clear state information.
|
void ThreadItem::notifyStopped()
|
||||||
{
|
{
|
||||||
threadData.address = 0;
|
threadData.stopped = true;
|
||||||
threadData.function.clear();
|
update();
|
||||||
threadData.fileName.clear();
|
}
|
||||||
threadData.frameLevel = -1;
|
|
||||||
threadData.state.clear();
|
|
||||||
threadData.lineNumber = -1;
|
|
||||||
threadData.stopped = false;
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void notifyStopped()
|
void ThreadItem::mergeThreadData(const ThreadData &other)
|
||||||
{
|
{
|
||||||
threadData.stopped = true;
|
if (!other.core.isEmpty())
|
||||||
update();
|
threadData.core = other.core;
|
||||||
}
|
if (!other.fileName.isEmpty())
|
||||||
|
threadData.fileName = other.fileName;
|
||||||
void mergeThreadData(const ThreadData &other)
|
if (!other.targetId.isEmpty())
|
||||||
{
|
threadData.targetId = other.targetId;
|
||||||
if (!other.core.isEmpty())
|
if (!other.name.isEmpty())
|
||||||
threadData.core = other.core;
|
threadData.name = other.name;
|
||||||
if (!other.fileName.isEmpty())
|
if (other.frameLevel != -1)
|
||||||
threadData.fileName = other.fileName;
|
threadData.frameLevel = other.frameLevel;
|
||||||
if (!other.targetId.isEmpty())
|
if (!other.function.isEmpty())
|
||||||
threadData.targetId = other.targetId;
|
threadData.function = other.function;
|
||||||
if (!other.name.isEmpty())
|
if (other.address)
|
||||||
threadData.name = other.name;
|
threadData.address = other.address;
|
||||||
if (other.frameLevel != -1)
|
if (!other.module.isEmpty())
|
||||||
threadData.frameLevel = other.frameLevel;
|
threadData.module = other.module;
|
||||||
if (!other.function.isEmpty())
|
if (!other.details.isEmpty())
|
||||||
threadData.function = other.function;
|
threadData.details = other.details;
|
||||||
if (other.address)
|
if (!other.state.isEmpty())
|
||||||
threadData.address = other.address;
|
threadData.state = other.state;
|
||||||
if (!other.module.isEmpty())
|
if (other.lineNumber != -1)
|
||||||
threadData.module = other.module;
|
threadData.lineNumber = other.lineNumber;
|
||||||
if (!other.details.isEmpty())
|
update();
|
||||||
threadData.details = other.details;
|
}
|
||||||
if (!other.state.isEmpty())
|
|
||||||
threadData.state = other.state;
|
|
||||||
if (other.lineNumber != -1)
|
|
||||||
threadData.lineNumber = other.lineNumber;
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
ThreadData threadData;
|
|
||||||
const ThreadsHandler * const handler;
|
|
||||||
};
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// ThreadsHandler
|
// ThreadsHandler
|
||||||
//
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class Debugger::Internal::ThreadData
|
\class Debugger::Internal::ThreadData
|
||||||
@@ -235,17 +223,17 @@ ThreadsHandler::ThreadsHandler(DebuggerEngine *engine)
|
|||||||
{
|
{
|
||||||
setObjectName(QLatin1String("ThreadsModel"));
|
setObjectName(QLatin1String("ThreadsModel"));
|
||||||
setHeader({
|
setHeader({
|
||||||
QLatin1String(" ") + tr("ID") + QLatin1String(" "),
|
QLatin1String(" ") + tr("ID") + QLatin1String(" "),
|
||||||
tr("Address"), tr("Function"), tr("File"), tr("Line"), tr("State"),
|
tr("Address"), tr("Function"), tr("File"), tr("Line"), tr("State"),
|
||||||
tr("Name"), tr("Target ID"), tr("Details"), tr("Core"),
|
tr("Name"), tr("Target ID"), tr("Details"), tr("Core"),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ThreadsHandler::setData(const QModelIndex &idx, const QVariant &data, int role)
|
bool ThreadsHandler::setData(const QModelIndex &idx, const QVariant &data, int role)
|
||||||
{
|
{
|
||||||
if (role == BaseTreeView::ItemActivatedRole) {
|
if (role == BaseTreeView::ItemActivatedRole) {
|
||||||
ThreadId id = ThreadId(idx.data(ThreadData::IdRole).toLongLong());
|
const Thread thread = itemForIndexAtLevel<1>(idx);
|
||||||
m_engine->selectThread(id);
|
m_engine->selectThread(thread);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,21 +251,9 @@ bool ThreadsHandler::setData(const QModelIndex &idx, const QVariant &data, int r
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ThreadItem *itemForThreadId(const ThreadsHandler *handler, ThreadId threadId)
|
|
||||||
{
|
|
||||||
const auto matcher = [threadId](ThreadItem *item) { return item->threadData.id == threadId; };
|
|
||||||
return handler->findItemAtLevel<1>(matcher);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int indexForThreadId(const ThreadsHandler *handler, ThreadId threadId)
|
|
||||||
{
|
|
||||||
ThreadItem *item = itemForThreadId(handler, threadId);
|
|
||||||
return item ? handler->rootItem()->indexOf(item) : -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ThreadsHandler::currentThreadIndex() const
|
int ThreadsHandler::currentThreadIndex() const
|
||||||
{
|
{
|
||||||
return indexForThreadId(this, m_currentId);
|
return rootItem()->indexOf(m_currentThread);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadsHandler::sort(int column, Qt::SortOrder order)
|
void ThreadsHandler::sort(int column, Qt::SortOrder order)
|
||||||
@@ -294,36 +270,29 @@ void ThreadsHandler::sort(int column, Qt::SortOrder order)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ThreadId ThreadsHandler::currentThread() const
|
Thread ThreadsHandler::currentThread() const
|
||||||
{
|
{
|
||||||
return m_currentId;
|
return m_currentThread;
|
||||||
}
|
}
|
||||||
|
|
||||||
ThreadId ThreadsHandler::threadAt(int index) const
|
Thread ThreadsHandler::threadAt(int index) const
|
||||||
{
|
{
|
||||||
QTC_ASSERT(index >= 0 && index < rootItem()->childCount(), return ThreadId());
|
QTC_ASSERT(index >= 0 && index < rootItem()->childCount(), return Thread());
|
||||||
return rootItem()->childAt(index)->threadData.id;
|
return rootItem()->childAt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadsHandler::setCurrentThread(ThreadId id)
|
void ThreadsHandler::setCurrentThread(const Thread &thread)
|
||||||
{
|
{
|
||||||
if (id == m_currentId)
|
if (thread == m_currentThread)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ThreadItem *newItem = itemForThreadId(this, id);
|
if (!threadForId(thread->id())) {
|
||||||
if (!newItem) {
|
qWarning("ThreadsHandler::setCurrentThreadId: No such thread %s.", qPrintable(thread->id()));
|
||||||
qWarning("ThreadsHandler::setCurrentThreadId: No such thread %d.", int(id.raw()));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ThreadItem *oldItem = itemForThreadId(this, m_currentId);
|
m_currentThread = thread;
|
||||||
m_currentId = id;
|
thread->update();
|
||||||
if (oldItem)
|
|
||||||
oldItem->update();
|
|
||||||
|
|
||||||
newItem->update();
|
|
||||||
|
|
||||||
updateThreadBox();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ThreadsHandler::pidForGroupId(const QString &groupId) const
|
QString ThreadsHandler::pidForGroupId(const QString &groupId) const
|
||||||
@@ -338,43 +307,16 @@ void ThreadsHandler::notifyGroupCreated(const QString &groupId, const QString &p
|
|||||||
|
|
||||||
void ThreadsHandler::updateThread(const ThreadData &threadData)
|
void ThreadsHandler::updateThread(const ThreadData &threadData)
|
||||||
{
|
{
|
||||||
if (ThreadItem *item = itemForThreadId(this, threadData.id))
|
if (Thread thread = threadForId(threadData.id))
|
||||||
item->mergeThreadData(threadData);
|
thread->mergeThreadData(threadData);
|
||||||
else
|
else
|
||||||
rootItem()->appendChild(new ThreadItem(this, threadData));
|
rootItem()->appendChild(new ThreadItem(this, threadData));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadsHandler::removeThread(ThreadId threadId)
|
void ThreadsHandler::removeThread(const QString &id)
|
||||||
{
|
{
|
||||||
if (ThreadItem *item = itemForThreadId(this, threadId))
|
if (Thread thread = threadForId(id))
|
||||||
destroyItem(item);
|
destroyItem(thread);
|
||||||
}
|
|
||||||
|
|
||||||
void ThreadsHandler::setThreads(const Threads &threads)
|
|
||||||
{
|
|
||||||
auto root = new ThreadItem(this);
|
|
||||||
for (int i = 0, n = threads.size(); i < n; ++i)
|
|
||||||
root->appendChild(new ThreadItem(this, threads.at(i)));
|
|
||||||
rootItem()->removeChildren();
|
|
||||||
setRootItem(root);
|
|
||||||
m_resetLocationScheduled = false;
|
|
||||||
updateThreadBox();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ThreadsHandler::updateThreadBox()
|
|
||||||
{
|
|
||||||
QStringList list;
|
|
||||||
forItemsAtLevel<1>([&list](ThreadItem *item) {
|
|
||||||
list.append(QString::fromLatin1("#%1 %2").arg(item->threadData.id.raw()).arg(item->threadData.name));
|
|
||||||
});
|
|
||||||
m_engine->setThreadBoxContents(list, indexForThreadId(this, m_currentId));
|
|
||||||
}
|
|
||||||
|
|
||||||
ThreadData ThreadsHandler::thread(ThreadId id) const
|
|
||||||
{
|
|
||||||
if (ThreadItem *item = itemForThreadId(this, id))
|
|
||||||
return item->threadData;
|
|
||||||
return ThreadData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadsHandler::removeAll()
|
void ThreadsHandler::removeAll()
|
||||||
@@ -396,54 +338,27 @@ bool ThreadsHandler::notifyGroupExited(const QString &groupId)
|
|||||||
return m_pidForGroupId.isEmpty();
|
return m_pidForGroupId.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadsHandler::notifyRunning(const QString &data)
|
Thread ThreadsHandler::threadForId(const QString &id) const
|
||||||
{
|
{
|
||||||
if (data.isEmpty() || data == "all") {
|
return findItemAtLevel<1>([id](const Thread &item) {
|
||||||
notifyAllRunning();
|
return item->threadData.id == id;
|
||||||
} else {
|
});
|
||||||
bool ok;
|
|
||||||
qlonglong id = data.toLongLong(&ok);
|
|
||||||
if (ok)
|
|
||||||
notifyRunning(ThreadId(id));
|
|
||||||
else // FIXME
|
|
||||||
notifyAllRunning();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadsHandler::notifyAllRunning()
|
void ThreadsHandler::notifyRunning(const QString &id)
|
||||||
{
|
{
|
||||||
forItemsAtLevel<1>([](ThreadItem *item) { item->notifyRunning(); });
|
if (id.isEmpty() || id == "all")
|
||||||
|
forItemsAtLevel<1>([](const Thread &thread) { thread->notifyRunning(); });
|
||||||
|
else if (Thread thread = threadForId(id))
|
||||||
|
thread->notifyRunning();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadsHandler::notifyRunning(ThreadId threadId)
|
void ThreadsHandler::notifyStopped(const QString &id)
|
||||||
{
|
{
|
||||||
if (ThreadItem *item = itemForThreadId(this, threadId))
|
if (id.isEmpty() || id == "all")
|
||||||
item->notifyRunning();
|
forItemsAtLevel<1>([](const Thread &thread) { thread->notifyStopped(); });
|
||||||
}
|
else if (Thread thread = threadForId(id))
|
||||||
|
thread->notifyStopped();
|
||||||
void ThreadsHandler::notifyStopped(const QString &data)
|
|
||||||
{
|
|
||||||
if (data.isEmpty() || data == "all") {
|
|
||||||
notifyAllStopped();
|
|
||||||
} else {
|
|
||||||
bool ok;
|
|
||||||
qlonglong id = data.toLongLong(&ok);
|
|
||||||
if (ok)
|
|
||||||
notifyRunning(ThreadId(id));
|
|
||||||
else // FIXME
|
|
||||||
notifyAllStopped();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ThreadsHandler::notifyAllStopped()
|
|
||||||
{
|
|
||||||
forItemsAtLevel<1>([](ThreadItem *item) { item->notifyStopped(); });
|
|
||||||
}
|
|
||||||
|
|
||||||
void ThreadsHandler::notifyStopped(ThreadId threadId)
|
|
||||||
{
|
|
||||||
if (ThreadItem *item = itemForThreadId(this, threadId))
|
|
||||||
item->notifyStopped();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadsHandler::updateThreads(const GdbMi &data)
|
void ThreadsHandler::updateThreads(const GdbMi &data)
|
||||||
@@ -453,13 +368,11 @@ void ThreadsHandler::updateThreads(const GdbMi &data)
|
|||||||
// file="/.../app.cpp",fullname="/../app.cpp",line="1175"},
|
// file="/.../app.cpp",fullname="/../app.cpp",line="1175"},
|
||||||
// state="stopped",core="0"}],current-thread-id="1"
|
// state="stopped",core="0"}],current-thread-id="1"
|
||||||
|
|
||||||
const QVector<GdbMi> items = data["threads"].children();
|
const QVector<GdbMi> &items = data["threads"].children();
|
||||||
const int n = int(items.size());
|
for (const GdbMi &item : items) {
|
||||||
for (int index = 0; index != n; ++index) {
|
const GdbMi &frame = item["frame"];
|
||||||
const GdbMi item = items[index];
|
|
||||||
const GdbMi frame = item["frame"];
|
|
||||||
ThreadData thread;
|
ThreadData thread;
|
||||||
thread.id = ThreadId(item["id"].toInt());
|
thread.id = item["id"].data();
|
||||||
thread.targetId = item["target-id"].data();
|
thread.targetId = item["target-id"].data();
|
||||||
thread.details = item["details"].data();
|
thread.details = item["details"].data();
|
||||||
thread.core = item["core"].data();
|
thread.core = item["core"].data();
|
||||||
@@ -474,10 +387,8 @@ void ThreadsHandler::updateThreads(const GdbMi &data)
|
|||||||
updateThread(thread);
|
updateThread(thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
const GdbMi current = data["current-thread-id"];
|
const QString ¤tId = data["current-thread-id"].data();
|
||||||
m_currentId = current.isValid() ? ThreadId(current.data().toLongLong()) : ThreadId();
|
m_currentThread = threadForId(currentId);
|
||||||
|
|
||||||
updateThreadBox();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadsHandler::scheduleResetLocation()
|
void ThreadsHandler::scheduleResetLocation()
|
||||||
|
@@ -29,6 +29,8 @@
|
|||||||
|
|
||||||
#include <utils/treemodel.h>
|
#include <utils/treemodel.h>
|
||||||
|
|
||||||
|
#include <QPointer>
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// ThreadsHandler
|
// ThreadsHandler
|
||||||
@@ -40,7 +42,33 @@ namespace Internal {
|
|||||||
|
|
||||||
class DebuggerEngine;
|
class DebuggerEngine;
|
||||||
class GdbMi;
|
class GdbMi;
|
||||||
class ThreadItem;
|
class ThreadsHandler;
|
||||||
|
|
||||||
|
class ThreadItem : public QObject, public Utils::TreeItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
ThreadItem(const ThreadsHandler *handler, const ThreadData &data = ThreadData());
|
||||||
|
|
||||||
|
QVariant data(int column, int role) const override;
|
||||||
|
Qt::ItemFlags flags(int column) const override;
|
||||||
|
|
||||||
|
QString threadToolTip() const;
|
||||||
|
QVariant threadPart(int column) const;
|
||||||
|
|
||||||
|
void notifyRunning();
|
||||||
|
void notifyStopped();
|
||||||
|
|
||||||
|
void mergeThreadData(const ThreadData &other);
|
||||||
|
QString id() const { return threadData.id; }
|
||||||
|
|
||||||
|
public:
|
||||||
|
ThreadData threadData;
|
||||||
|
const ThreadsHandler * const handler;
|
||||||
|
};
|
||||||
|
|
||||||
|
using Thread = QPointer<ThreadItem>;
|
||||||
|
|
||||||
class ThreadsHandler : public Utils::TreeModel<Utils::TypedTreeItem<ThreadItem>, ThreadItem>
|
class ThreadsHandler : public Utils::TreeModel<Utils::TypedTreeItem<ThreadItem>, ThreadItem>
|
||||||
{
|
{
|
||||||
@@ -50,43 +78,34 @@ public:
|
|||||||
explicit ThreadsHandler(DebuggerEngine *engine);
|
explicit ThreadsHandler(DebuggerEngine *engine);
|
||||||
|
|
||||||
int currentThreadIndex() const;
|
int currentThreadIndex() const;
|
||||||
ThreadId currentThread() const;
|
Thread currentThread() const;
|
||||||
ThreadId threadAt(int index) const;
|
Thread threadAt(int index) const;
|
||||||
void setCurrentThread(ThreadId id);
|
Thread threadForId(const QString &id) const;
|
||||||
|
void setCurrentThread(const Thread &thread);
|
||||||
QString pidForGroupId(const QString &groupId) const;
|
QString pidForGroupId(const QString &groupId) const;
|
||||||
|
|
||||||
void updateThread(const ThreadData &threadData);
|
void updateThread(const ThreadData &threadData);
|
||||||
void updateThreads(const GdbMi &data);
|
void updateThreads(const GdbMi &data);
|
||||||
|
|
||||||
void removeThread(ThreadId threadId);
|
void removeThread(const QString &id);
|
||||||
void setThreads(const Threads &threads);
|
|
||||||
void removeAll();
|
void removeAll();
|
||||||
ThreadData thread(ThreadId id) const;
|
|
||||||
QAbstractItemModel *model();
|
QAbstractItemModel *model();
|
||||||
|
|
||||||
void notifyGroupCreated(const QString &groupId, const QString &pid);
|
void notifyGroupCreated(const QString &groupId, const QString &pid);
|
||||||
bool notifyGroupExited(const QString &groupId); // Returns true when empty.
|
bool notifyGroupExited(const QString &groupId); // Returns true when empty.
|
||||||
|
|
||||||
// Clear out all frame information
|
void notifyRunning(const QString &id);
|
||||||
void notifyRunning(const QString &data);
|
void notifyStopped(const QString &id);
|
||||||
void notifyRunning(ThreadId threadId);
|
|
||||||
void notifyAllRunning();
|
|
||||||
|
|
||||||
void notifyStopped(const QString &data);
|
|
||||||
void notifyStopped(ThreadId threadId);
|
|
||||||
void notifyAllStopped();
|
|
||||||
|
|
||||||
void resetLocation();
|
void resetLocation();
|
||||||
void scheduleResetLocation();
|
void scheduleResetLocation();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateThreadBox();
|
|
||||||
|
|
||||||
void sort(int column, Qt::SortOrder order) override;
|
void sort(int column, Qt::SortOrder order) override;
|
||||||
bool setData(const QModelIndex &idx, const QVariant &data, int role) override;
|
bool setData(const QModelIndex &idx, const QVariant &data, int role) override;
|
||||||
|
|
||||||
DebuggerEngine *m_engine;
|
DebuggerEngine *m_engine;
|
||||||
ThreadId m_currentId;
|
Thread m_currentThread;
|
||||||
bool m_resetLocationScheduled = false;
|
bool m_resetLocationScheduled = false;
|
||||||
QHash<QString, QString> m_pidForGroupId;
|
QHash<QString, QString> m_pidForGroupId;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user