forked from qt-creator/qt-creator
Debugger: Rework thread data aquisition
Listen to gdb/MI notifications when possible. This is more granular, gives access to the thread group id and takes care of thread changes at any time. Change-Id: I8c67f6f19b204059deefdf7e07fe3b4ce13ed963 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
This commit is contained in:
@@ -1302,15 +1302,6 @@ void CdbEngine::assignValueInDebugger(const WatchData *w, const QString &expr, c
|
|||||||
updateLocals();
|
updateLocals();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CdbEngine::parseThreads(const GdbMi &data, int forceCurrentThreadId /* = -1 */)
|
|
||||||
{
|
|
||||||
int currentThreadId;
|
|
||||||
Threads threads = ThreadsHandler::parseGdbmiThreads(data, ¤tThreadId);
|
|
||||||
threadsHandler()->setThreads(threads);
|
|
||||||
threadsHandler()->setCurrentThreadId(forceCurrentThreadId >= 0 ?
|
|
||||||
forceCurrentThreadId : currentThreadId);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CdbEngine::handleThreads(const CdbExtensionCommandPtr &reply)
|
void CdbEngine::handleThreads(const CdbExtensionCommandPtr &reply)
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
@@ -1318,7 +1309,7 @@ void CdbEngine::handleThreads(const CdbExtensionCommandPtr &reply)
|
|||||||
if (reply->success) {
|
if (reply->success) {
|
||||||
GdbMi data;
|
GdbMi data;
|
||||||
data.fromString(reply->reply);
|
data.fromString(reply->reply);
|
||||||
parseThreads(data);
|
threadsHandler()->updateThreads(data);
|
||||||
// Continue sequence
|
// Continue sequence
|
||||||
postCommandSequence(reply->commandSequence);
|
postCommandSequence(reply->commandSequence);
|
||||||
} else {
|
} else {
|
||||||
@@ -1514,15 +1505,14 @@ void CdbEngine::updateLocals(bool forNewStackFrame)
|
|||||||
QVariant(flags));
|
QVariant(flags));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CdbEngine::selectThread(int index)
|
void CdbEngine::selectThread(ThreadId threadId)
|
||||||
{
|
{
|
||||||
if (index < 0 || index == threadsHandler()->currentThread())
|
if (!threadId.isValid() || threadId == threadsHandler()->currentThread())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const int newThreadId = threadsHandler()->threads().at(index).id;
|
threadsHandler()->setCurrentThread(threadId);
|
||||||
threadsHandler()->setCurrentThread(index);
|
|
||||||
|
|
||||||
const QByteArray cmd = '~' + QByteArray::number(newThreadId) + " s";
|
const QByteArray cmd = '~' + QByteArray::number(threadId.raw()) + " s";
|
||||||
postBuiltinCommand(cmd, 0, &CdbEngine::dummyHandler, CommandListStack);
|
postBuiltinCommand(cmd, 0, &CdbEngine::dummyHandler, CommandListStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2179,7 +2169,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;
|
||||||
int forcedThreadId = -1;
|
ThreadId forcedThreadId;
|
||||||
const unsigned stopFlags = examineStopReason(stopReason, &message, &exceptionBoxMessage,
|
const unsigned stopFlags = examineStopReason(stopReason, &message, &exceptionBoxMessage,
|
||||||
conditionalBreakPointTriggered);
|
conditionalBreakPointTriggered);
|
||||||
// Do the non-blocking log reporting
|
// Do the non-blocking log reporting
|
||||||
@@ -2216,7 +2206,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);
|
||||||
postCommand("~0 s", 0);
|
postCommand("~0 s", 0);
|
||||||
forcedThreadId = 0;
|
forcedThreadId = ThreadId(0);
|
||||||
// Re-fetch stack again.
|
// Re-fetch stack again.
|
||||||
postCommandSequence(CommandListStack);
|
postCommandSequence(CommandListStack);
|
||||||
} else {
|
} else {
|
||||||
@@ -2232,7 +2222,9 @@ void CdbEngine::processStop(const GdbMi &stopReason, bool conditionalBreakPointT
|
|||||||
}
|
}
|
||||||
const GdbMi threads = stopReason.findChild("threads");
|
const GdbMi threads = stopReason.findChild("threads");
|
||||||
if (threads.isValid()) {
|
if (threads.isValid()) {
|
||||||
parseThreads(threads, forcedThreadId);
|
threadsHandler()->updateThreads(threads);
|
||||||
|
if (forcedThreadId.isValid())
|
||||||
|
threadsHandler()->setCurrentThread(forcedThreadId);
|
||||||
} else {
|
} else {
|
||||||
showMessage(QString::fromLatin1(stopReason.findChild("threaderror").data()), LogError);
|
showMessage(QString::fromLatin1(stopReason.findChild("threaderror").data()), LogError);
|
||||||
}
|
}
|
||||||
@@ -2938,7 +2930,7 @@ void CdbEngine::postCommandSequence(unsigned mask)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mask & CommandListRegisters) {
|
if (mask & CommandListRegisters) {
|
||||||
QTC_ASSERT(threadsHandler()->currentThread() >= 0, return);
|
QTC_ASSERT(threadsHandler()->currentThreadIndex() >= 0, return);
|
||||||
postExtensionCommand("registers", QByteArray(), 0, &CdbEngine::handleRegisters, mask & ~CommandListRegisters);
|
postExtensionCommand("registers", QByteArray(), 0, &CdbEngine::handleRegisters, mask & ~CommandListRegisters);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include "debuggerengine.h"
|
#include "debuggerengine.h"
|
||||||
#include "breakpoint.h"
|
#include "breakpoint.h"
|
||||||
|
#include "threaddata.h"
|
||||||
|
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
@@ -113,7 +114,7 @@ public:
|
|||||||
virtual void executeDebuggerCommand(const QString &command, DebuggerLanguages languages);
|
virtual void executeDebuggerCommand(const QString &command, DebuggerLanguages languages);
|
||||||
|
|
||||||
virtual void activateFrame(int index);
|
virtual void activateFrame(int index);
|
||||||
virtual void selectThread(int index);
|
virtual void selectThread(ThreadId threadId);
|
||||||
|
|
||||||
virtual bool stateAcceptsBreakpointChanges() const;
|
virtual bool stateAcceptsBreakpointChanges() const;
|
||||||
virtual bool acceptsBreakpoint(BreakpointModelId id) const;
|
virtual bool acceptsBreakpoint(BreakpointModelId id) const;
|
||||||
@@ -242,7 +243,6 @@ private:
|
|||||||
int elapsedLogTime() const;
|
int elapsedLogTime() const;
|
||||||
void addLocalsOptions(ByteArrayInputStream &s) const;
|
void addLocalsOptions(ByteArrayInputStream &s) const;
|
||||||
unsigned parseStackTrace(const GdbMi &data, bool sourceStepInto);
|
unsigned parseStackTrace(const GdbMi &data, bool sourceStepInto);
|
||||||
void parseThreads(const GdbMi &, int forceCurrentThreadId = -1);
|
|
||||||
|
|
||||||
const QByteArray m_creatorExtPrefix;
|
const QByteArray m_creatorExtPrefix;
|
||||||
const QByteArray m_tokenPrefix;
|
const QByteArray m_tokenPrefix;
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ static inline bool parseThread(QByteArray line, ThreadData *thread, bool *curren
|
|||||||
thread->targetId = QLatin1String("0x") + QString::fromLatin1(pidTid.mid(dotPos + 1));
|
thread->targetId = QLatin1String("0x") + QString::fromLatin1(pidTid.mid(dotPos + 1));
|
||||||
}
|
}
|
||||||
case 1:
|
case 1:
|
||||||
thread->id = tokens.at(0).toInt();
|
thread->id = ThreadId(tokens.at(0).toInt());
|
||||||
break;
|
break;
|
||||||
} // switch size
|
} // switch size
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1233,10 +1233,6 @@ void DebuggerEngine::setState(DebuggerState state, bool forced)
|
|||||||
handler->notifyBreakpointReleased(id);
|
handler->notifyBreakpointReleased(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool running = d->m_state == InferiorRunOk;
|
|
||||||
if (running)
|
|
||||||
threadsHandler()->notifyRunning();
|
|
||||||
|
|
||||||
showMessage(msg, LogDebug);
|
showMessage(msg, LogDebug);
|
||||||
updateViews();
|
updateViews();
|
||||||
|
|
||||||
@@ -1586,10 +1582,6 @@ void DebuggerEngine::changeBreakpoint(BreakpointModelId id)
|
|||||||
QTC_CHECK(false);
|
QTC_CHECK(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerEngine::selectThread(int)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void DebuggerEngine::assignValueInDebugger(const WatchData *,
|
void DebuggerEngine::assignValueInDebugger(const WatchData *,
|
||||||
const QString &, const QVariant &)
|
const QString &, const QVariant &)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,7 +32,8 @@
|
|||||||
|
|
||||||
#include "debugger_global.h"
|
#include "debugger_global.h"
|
||||||
#include "debuggerconstants.h"
|
#include "debuggerconstants.h"
|
||||||
#include "breakpoint.h" // For 'BreakpointId'
|
#include "breakpoint.h" // For BreakpointModelId.
|
||||||
|
#include "threaddata.h" // For ThreadId.
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
@@ -205,7 +206,7 @@ public:
|
|||||||
virtual bool acceptsDebuggerCommands() const { return true; }
|
virtual bool acceptsDebuggerCommands() const { return true; }
|
||||||
virtual void assignValueInDebugger(const Internal::WatchData *data,
|
virtual void assignValueInDebugger(const Internal::WatchData *data,
|
||||||
const QString &expr, const QVariant &value);
|
const QString &expr, const QVariant &value);
|
||||||
virtual void selectThread(int index);
|
virtual void selectThread(Internal::ThreadId threadId) = 0;
|
||||||
|
|
||||||
virtual Internal::ModulesHandler *modulesHandler() const;
|
virtual Internal::ModulesHandler *modulesHandler() const;
|
||||||
virtual Internal::RegisterHandler *registerHandler() const;
|
virtual Internal::RegisterHandler *registerHandler() const;
|
||||||
|
|||||||
@@ -494,6 +494,7 @@ public:
|
|||||||
bool hasCapability(unsigned cap) const;
|
bool hasCapability(unsigned cap) const;
|
||||||
bool acceptsBreakpoint(BreakpointModelId) const { return false; }
|
bool acceptsBreakpoint(BreakpointModelId) const { return false; }
|
||||||
bool acceptsDebuggerCommands() const { return false; }
|
bool acceptsDebuggerCommands() const { return false; }
|
||||||
|
void selectThread(ThreadId) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
bool DummyEngine::hasCapability(unsigned cap) const
|
bool DummyEngine::hasCapability(unsigned cap) const
|
||||||
@@ -781,7 +782,8 @@ public slots:
|
|||||||
|
|
||||||
void selectThread(int index)
|
void selectThread(int index)
|
||||||
{
|
{
|
||||||
currentEngine()->selectThread(index);
|
ThreadId id = m_currentEngine->threadsHandler()->threadAt(index);
|
||||||
|
m_currentEngine->selectThread(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void breakpointSetMarginActionTriggered()
|
void breakpointSetMarginActionTriggered()
|
||||||
@@ -2205,7 +2207,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
|
|||||||
QTC_ASSERT(m_returnWindow->model(), return);
|
QTC_ASSERT(m_returnWindow->model(), return);
|
||||||
QTC_ASSERT(!engine->isSlaveEngine(), return);
|
QTC_ASSERT(!engine->isSlaveEngine(), return);
|
||||||
|
|
||||||
m_threadBox->setCurrentIndex(engine->threadsHandler()->currentThread());
|
m_threadBox->setCurrentIndex(engine->threadsHandler()->currentThreadIndex());
|
||||||
engine->watchHandler()->updateWatchersWindow();
|
engine->watchHandler()->updateWatchersWindow();
|
||||||
|
|
||||||
const DebuggerState state = engine->state();
|
const DebuggerState state = engine->state();
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ namespace Internal {
|
|||||||
|
|
||||||
QDataStream &operator<<(QDataStream &stream, const ThreadData &d)
|
QDataStream &operator<<(QDataStream &stream, const ThreadData &d)
|
||||||
{
|
{
|
||||||
stream << (qint64)d.id;
|
stream << d.id.raw();
|
||||||
stream << d.address;
|
stream << d.address;
|
||||||
stream << d.function;
|
stream << d.function;
|
||||||
stream << d.fileName;
|
stream << d.fileName;
|
||||||
@@ -54,7 +54,7 @@ QDataStream &operator>>(QDataStream &stream, ThreadData &d)
|
|||||||
{
|
{
|
||||||
qint64 id;
|
qint64 id;
|
||||||
stream >> id;
|
stream >> id;
|
||||||
d.id = id;
|
d.id = ThreadId(id);
|
||||||
stream >> d.address;
|
stream >> d.address;
|
||||||
stream >> d.function;
|
stream >> d.function;
|
||||||
stream >> d.fileName;
|
stream >> d.fileName;
|
||||||
|
|||||||
@@ -467,6 +467,8 @@ void GdbEngine::handleResponse(const QByteArray &buff)
|
|||||||
m_pendingLogStreamOutput.clear();
|
m_pendingLogStreamOutput.clear();
|
||||||
m_pendingConsoleStreamOutput.clear();
|
m_pendingConsoleStreamOutput.clear();
|
||||||
} else if (asyncClass == "running") {
|
} else if (asyncClass == "running") {
|
||||||
|
GdbMi threads = result.findChild("thread-id");
|
||||||
|
threadsHandler()->notifyRunning(threads.data());
|
||||||
if (state() == InferiorRunOk || state() == InferiorSetupRequested) {
|
if (state() == InferiorRunOk || state() == InferiorSetupRequested) {
|
||||||
// We get multiple *running after thread creation and in Windows terminals.
|
// We get multiple *running after thread creation and in Windows terminals.
|
||||||
showMessage(QString::fromLatin1("NOTE: INFERIOR STILL RUNNING IN STATE %1.").
|
showMessage(QString::fromLatin1("NOTE: INFERIOR STILL RUNNING IN STATE %1.").
|
||||||
@@ -527,6 +529,10 @@ void GdbEngine::handleResponse(const QByteArray &buff)
|
|||||||
//"{id="1",group-id="28902"}"
|
//"{id="1",group-id="28902"}"
|
||||||
QByteArray id = result.findChild("id").data();
|
QByteArray id = result.findChild("id").data();
|
||||||
showStatusMessage(tr("Thread %1 created").arg(_(id)), 1000);
|
showStatusMessage(tr("Thread %1 created").arg(_(id)), 1000);
|
||||||
|
ThreadData thread;
|
||||||
|
thread.id = ThreadId(id.toLong());
|
||||||
|
thread.groupId = result.findChild("group-id").data();
|
||||||
|
threadsHandler()->updateThread(thread);
|
||||||
} else if (asyncClass == "thread-group-exited") {
|
} else if (asyncClass == "thread-group-exited") {
|
||||||
// Archer has "{id="28902"}"
|
// Archer has "{id="28902"}"
|
||||||
QByteArray id = result.findChild("id").data();
|
QByteArray id = result.findChild("id").data();
|
||||||
@@ -538,6 +544,7 @@ void GdbEngine::handleResponse(const QByteArray &buff)
|
|||||||
QByteArray groupid = result.findChild("group-id").data();
|
QByteArray groupid = result.findChild("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()));
|
||||||
} else if (asyncClass == "thread-selected") {
|
} else if (asyncClass == "thread-selected") {
|
||||||
QByteArray id = result.findChild("id").data();
|
QByteArray id = result.findChild("id").data();
|
||||||
showStatusMessage(tr("Thread %1 selected").arg(_(id)), 1000);
|
showStatusMessage(tr("Thread %1 selected").arg(_(id)), 1000);
|
||||||
@@ -1397,6 +1404,9 @@ void GdbEngine::handleStopResponse(const GdbMi &data)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GdbMi threads = data.findChild("stopped-thread");
|
||||||
|
threadsHandler()->notifyStopped(threads.data());
|
||||||
|
|
||||||
const QByteArray reason = data.findChild("reason").data();
|
const QByteArray reason = data.findChild("reason").data();
|
||||||
|
|
||||||
if (isExitedReason(reason)) {
|
if (isExitedReason(reason)) {
|
||||||
@@ -1748,10 +1758,6 @@ void GdbEngine::handleStop2(const GdbMi &data)
|
|||||||
|
|
||||||
// Let the event loop run before deciding whether to update the stack.
|
// Let the event loop run before deciding whether to update the stack.
|
||||||
m_stackNeeded = true; // setTokenBarrier() might reset this.
|
m_stackNeeded = true; // setTokenBarrier() might reset this.
|
||||||
if (isStopperThread)
|
|
||||||
m_currentThreadId = 0;
|
|
||||||
else
|
|
||||||
m_currentThreadId = data.findChild("thread-id").data().toInt();
|
|
||||||
QTimer::singleShot(0, this, SLOT(handleStop2()));
|
QTimer::singleShot(0, this, SLOT(handleStop2()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3489,15 +3495,12 @@ void GdbEngine::reloadSourceFilesInternal()
|
|||||||
//
|
//
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void GdbEngine::selectThread(int index)
|
void GdbEngine::selectThread(ThreadId threadId)
|
||||||
{
|
{
|
||||||
threadsHandler()->setCurrentThread(index);
|
threadsHandler()->setCurrentThread(threadId);
|
||||||
Threads threads = threadsHandler()->threads();
|
|
||||||
QTC_ASSERT(index < threads.size(), return);
|
|
||||||
const int id = threads.at(index).id;
|
|
||||||
showStatusMessage(tr("Retrieving data for stack view thread 0x%1...")
|
showStatusMessage(tr("Retrieving data for stack view thread 0x%1...")
|
||||||
.arg(id, 0, 16), 10000);
|
.arg(threadId.raw(), 0, 16), 10000);
|
||||||
postCommand("-thread-select " + QByteArray::number(id), Discardable,
|
postCommand("-thread-select " + QByteArray::number(threadId.raw()), Discardable,
|
||||||
CB(handleStackSelectThread));
|
CB(handleStackSelectThread));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3641,11 +3644,7 @@ void GdbEngine::handleStackSelectFrame(const GdbResponse &response)
|
|||||||
void GdbEngine::handleThreadInfo(const GdbResponse &response)
|
void GdbEngine::handleThreadInfo(const GdbResponse &response)
|
||||||
{
|
{
|
||||||
if (response.resultClass == GdbResultDone) {
|
if (response.resultClass == GdbResultDone) {
|
||||||
int currentThreadId;
|
threadsHandler()->updateThreads(response.data);
|
||||||
const Threads threads =
|
|
||||||
ThreadsHandler::parseGdbmiThreads(response.data, ¤tThreadId);
|
|
||||||
threadsHandler()->setThreads(threads);
|
|
||||||
threadsHandler()->setCurrentThreadId(currentThreadId);
|
|
||||||
updateViews(); // Adjust Threads combobox.
|
updateViews(); // Adjust Threads combobox.
|
||||||
if (m_hasInferiorThreadList && debuggerCore()->boolSetting(ShowThreadNames)) {
|
if (m_hasInferiorThreadList && debuggerCore()->boolSetting(ShowThreadNames)) {
|
||||||
postCommand("threadnames " +
|
postCommand("threadnames " +
|
||||||
@@ -3663,37 +3662,28 @@ void GdbEngine::handleThreadListIds(const GdbResponse &response)
|
|||||||
{
|
{
|
||||||
// "72^done,{thread-ids={thread-id="2",thread-id="1"},number-of-threads="2"}
|
// "72^done,{thread-ids={thread-id="2",thread-id="1"},number-of-threads="2"}
|
||||||
// In gdb 7.1+ additionally: current-thread-id="1"
|
// In gdb 7.1+ additionally: current-thread-id="1"
|
||||||
|
ThreadsHandler *handler = threadsHandler();
|
||||||
const QList<GdbMi> items = response.data.findChild("thread-ids").children();
|
const QList<GdbMi> items = response.data.findChild("thread-ids").children();
|
||||||
Threads threads;
|
|
||||||
for (int index = 0, n = items.size(); index != n; ++index) {
|
for (int index = 0, n = items.size(); index != n; ++index) {
|
||||||
ThreadData thread;
|
ThreadData thread;
|
||||||
thread.id = items.at(index).data().toInt();
|
thread.id = ThreadId(items.at(index).data().toInt());
|
||||||
threads.append(thread);
|
handler->updateThread(thread);
|
||||||
}
|
}
|
||||||
threadsHandler()->setThreads(threads);
|
|
||||||
threadsHandler()->setCurrentThreadId(m_currentThreadId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbEngine::handleThreadNames(const GdbResponse &response)
|
void GdbEngine::handleThreadNames(const GdbResponse &response)
|
||||||
{
|
{
|
||||||
if (response.resultClass == GdbResultDone) {
|
if (response.resultClass == GdbResultDone) {
|
||||||
|
ThreadsHandler *handler = threadsHandler();
|
||||||
GdbMi names;
|
GdbMi names;
|
||||||
names.fromString(response.consoleStreamOutput);
|
names.fromString(response.consoleStreamOutput);
|
||||||
|
|
||||||
Threads threads = threadsHandler()->threads();
|
|
||||||
|
|
||||||
foreach (const GdbMi &name, names.children()) {
|
foreach (const GdbMi &name, names.children()) {
|
||||||
int id = name.findChild("id").data().toInt();
|
ThreadData thread;
|
||||||
for (int index = 0, n = threads.size(); index != n; ++index) {
|
thread.id = ThreadId(name.findChild("id").data().toInt());
|
||||||
ThreadData &thread = threads[index];
|
|
||||||
if (thread.id == quint64(id)) {
|
|
||||||
thread.name = decodeData(name.findChild("value").data(),
|
thread.name = decodeData(name.findChild("value").data(),
|
||||||
name.findChild("valueencoded").data().toInt());
|
name.findChild("valueencoded").data().toInt());
|
||||||
break;
|
handler->updateThread(thread);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
threadsHandler()->setThreads(threads);
|
|
||||||
updateViews();
|
updateViews();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
#include "stackframe.h"
|
#include "stackframe.h"
|
||||||
#include "watchhandler.h"
|
#include "watchhandler.h"
|
||||||
#include "watchutils.h"
|
#include "watchutils.h"
|
||||||
|
#include "threaddata.h"
|
||||||
|
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
@@ -437,7 +438,7 @@ private: ////////// Inferior Management //////////
|
|||||||
private: ////////// View & Data Stuff //////////
|
private: ////////// View & Data Stuff //////////
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void selectThread(int index);
|
void selectThread(ThreadId threadId);
|
||||||
void activateFrame(int index);
|
void activateFrame(int index);
|
||||||
void resetLocation();
|
void resetLocation();
|
||||||
|
|
||||||
@@ -664,7 +665,6 @@ protected:
|
|||||||
|
|
||||||
// For short-circuiting stack and thread list evaluation.
|
// For short-circuiting stack and thread list evaluation.
|
||||||
bool m_stackNeeded;
|
bool m_stackNeeded;
|
||||||
int m_currentThreadId;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Qml
|
// Qml
|
||||||
|
|||||||
@@ -208,7 +208,6 @@ void IPCEngineHost::executeJumpToLine(const ContextData &data)
|
|||||||
rpcCall(ExecuteJumpToLine, p);
|
rpcCall(ExecuteJumpToLine, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void IPCEngineHost::activateFrame(int index)
|
void IPCEngineHost::activateFrame(int index)
|
||||||
{
|
{
|
||||||
resetLocation();
|
resetLocation();
|
||||||
@@ -221,16 +220,15 @@ void IPCEngineHost::activateFrame(int index)
|
|||||||
rpcCall(ActivateFrame, p);
|
rpcCall(ActivateFrame, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IPCEngineHost::selectThread(int index)
|
void IPCEngineHost::selectThread(ThreadId id)
|
||||||
{
|
{
|
||||||
resetLocation();
|
resetLocation();
|
||||||
Threads threads = threadsHandler()->threads();
|
QTC_ASSERT(id.isValid(), return);
|
||||||
QTC_ASSERT(index < threads.size(), return);
|
|
||||||
QByteArray p;
|
QByteArray p;
|
||||||
{
|
{
|
||||||
QDataStream s(&p, QIODevice::WriteOnly);
|
QDataStream s(&p, QIODevice::WriteOnly);
|
||||||
SET_NATIVE_BYTE_ORDER(s);
|
SET_NATIVE_BYTE_ORDER(s);
|
||||||
s << quint64(threads.at(index).id);
|
s << id.raw();
|
||||||
}
|
}
|
||||||
rpcCall(SelectThread, p);
|
rpcCall(SelectThread, p);
|
||||||
}
|
}
|
||||||
@@ -442,7 +440,7 @@ void IPCEngineHost::rpcCallback(quint64 f, QByteArray payload)
|
|||||||
SET_NATIVE_BYTE_ORDER(s);
|
SET_NATIVE_BYTE_ORDER(s);
|
||||||
quint64 token;
|
quint64 token;
|
||||||
s >> token;
|
s >> token;
|
||||||
threadsHandler()->setCurrentThreadId(token);
|
threadsHandler()->setCurrentThread(ThreadId(token));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IPCEngineGuest::ListFrames:
|
case IPCEngineGuest::ListFrames:
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ public:
|
|||||||
void executeRunToFunction(const QString &functionName);
|
void executeRunToFunction(const QString &functionName);
|
||||||
void executeJumpToLine(const ContextData &data);
|
void executeJumpToLine(const ContextData &data);
|
||||||
void activateFrame(int index);
|
void activateFrame(int index);
|
||||||
void selectThread(int index);
|
void selectThread(ThreadId index);
|
||||||
void fetchDisassembler(DisassemblerAgent *);
|
void fetchDisassembler(DisassemblerAgent *);
|
||||||
bool acceptsBreakpoint(BreakpointModelId) const { return true; } // FIXME
|
bool acceptsBreakpoint(BreakpointModelId) const { return true; } // FIXME
|
||||||
void insertBreakpoint(BreakpointModelId id);
|
void insertBreakpoint(BreakpointModelId id);
|
||||||
|
|||||||
@@ -321,9 +321,9 @@ void PdbEngine::activateFrame(int frameIndex)
|
|||||||
gotoLocation(handler->currentFrame());
|
gotoLocation(handler->currentFrame());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PdbEngine::selectThread(int index)
|
void PdbEngine::selectThread(ThreadId threadId)
|
||||||
{
|
{
|
||||||
Q_UNUSED(index)
|
Q_UNUSED(threadId)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PdbEngine::acceptsBreakpoint(BreakpointModelId id) const
|
bool PdbEngine::acceptsBreakpoint(BreakpointModelId id) const
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ private:
|
|||||||
void executeJumpToLine(const ContextData &data);
|
void executeJumpToLine(const ContextData &data);
|
||||||
|
|
||||||
void activateFrame(int index);
|
void activateFrame(int index);
|
||||||
void selectThread(int index);
|
void selectThread(ThreadId threadId);
|
||||||
|
|
||||||
bool acceptsBreakpoint(BreakpointModelId id) const;
|
bool acceptsBreakpoint(BreakpointModelId id) const;
|
||||||
void insertBreakpoint(BreakpointModelId id);
|
void insertBreakpoint(BreakpointModelId id);
|
||||||
|
|||||||
@@ -267,9 +267,9 @@ bool QmlCppEngine::acceptsBreakpoint(BreakpointModelId id) const
|
|||||||
|| d->m_qmlEngine->acceptsBreakpoint(id);
|
|| d->m_qmlEngine->acceptsBreakpoint(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlCppEngine::selectThread(int index)
|
void QmlCppEngine::selectThread(ThreadId threadId)
|
||||||
{
|
{
|
||||||
d->m_activeEngine->selectThread(index);
|
d->m_activeEngine->selectThread(threadId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlCppEngine::assignValueInDebugger(const WatchData *data,
|
void QmlCppEngine::assignValueInDebugger(const WatchData *data,
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ public:
|
|||||||
|
|
||||||
void attemptBreakpointSynchronization();
|
void attemptBreakpointSynchronization();
|
||||||
bool acceptsBreakpoint(BreakpointModelId id) const;
|
bool acceptsBreakpoint(BreakpointModelId id) const;
|
||||||
void selectThread(int index);
|
void selectThread(ThreadId threadId);
|
||||||
|
|
||||||
void assignValueInDebugger(const WatchData *data,
|
void assignValueInDebugger(const WatchData *data,
|
||||||
const QString &expr, const QVariant &value);
|
const QString &expr, const QVariant &value);
|
||||||
|
|||||||
@@ -778,9 +778,9 @@ void QmlEngine::activateFrame(int index)
|
|||||||
gotoLocation(stackHandler()->frames().value(index));
|
gotoLocation(stackHandler()->frames().value(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlEngine::selectThread(int index)
|
void QmlEngine::selectThread(ThreadId threadId)
|
||||||
{
|
{
|
||||||
Q_UNUSED(index)
|
Q_UNUSED(threadId)
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlEngine::insertBreakpoint(BreakpointModelId id)
|
void QmlEngine::insertBreakpoint(BreakpointModelId id)
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ private:
|
|||||||
void executeJumpToLine(const ContextData &data);
|
void executeJumpToLine(const ContextData &data);
|
||||||
|
|
||||||
void activateFrame(int index);
|
void activateFrame(int index);
|
||||||
void selectThread(int index);
|
void selectThread(ThreadId threadId);
|
||||||
|
|
||||||
void attemptBreakpointSynchronization();
|
void attemptBreakpointSynchronization();
|
||||||
void removeBreakpoint(BreakpointModelId id);
|
void removeBreakpoint(BreakpointModelId id);
|
||||||
|
|||||||
@@ -438,9 +438,9 @@ void ScriptEngine::activateFrame(int index)
|
|||||||
Q_UNUSED(index)
|
Q_UNUSED(index)
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptEngine::selectThread(int index)
|
void ScriptEngine::selectThread(ThreadId threadId)
|
||||||
{
|
{
|
||||||
Q_UNUSED(index)
|
Q_UNUSED(threadId)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScriptEngine::acceptsBreakpoint(BreakpointModelId id) const
|
bool ScriptEngine::acceptsBreakpoint(BreakpointModelId id) const
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ private:
|
|||||||
void executeJumpToLine(const ContextData &data);
|
void executeJumpToLine(const ContextData &data);
|
||||||
|
|
||||||
void activateFrame(int index);
|
void activateFrame(int index);
|
||||||
void selectThread(int index);
|
void selectThread(ThreadId threadId);
|
||||||
|
|
||||||
bool acceptsBreakpoint(BreakpointModelId id) const;
|
bool acceptsBreakpoint(BreakpointModelId id) const;
|
||||||
void attemptBreakpointSynchronization();
|
void attemptBreakpointSynchronization();
|
||||||
|
|||||||
@@ -30,24 +30,49 @@
|
|||||||
#ifndef THREADDATA_H
|
#ifndef THREADDATA_H
|
||||||
#define THREADDATA_H
|
#define THREADDATA_H
|
||||||
|
|
||||||
#include <QVector>
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// ThreadId
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/*! A typesafe identifier. */
|
||||||
|
class ThreadId
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ThreadId() : m_id(-1) {}
|
||||||
|
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; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
qint64 m_id;
|
||||||
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// ThreadData
|
// ThreadData
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/*! A structure containing information about a single thread */
|
/*! A structure containing information about a single thread. */
|
||||||
struct ThreadData
|
struct ThreadData
|
||||||
{
|
{
|
||||||
ThreadData(quint64 threadid = 0)
|
ThreadData()
|
||||||
: id(threadid), frameLevel(-1), address (0), lineNumber(-1)
|
{
|
||||||
{}
|
frameLevel = -1;
|
||||||
|
lineNumber = -1;
|
||||||
|
address = 0;
|
||||||
|
stopped = true;
|
||||||
|
}
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
IdColumn,
|
IdColumn,
|
||||||
@@ -61,7 +86,9 @@ struct ThreadData
|
|||||||
DetailsColumn,
|
DetailsColumn,
|
||||||
CoreColumn,
|
CoreColumn,
|
||||||
ComboNameColumn,
|
ComboNameColumn,
|
||||||
ColumnCount = CoreColumn
|
ColumnCount = CoreColumn,
|
||||||
|
|
||||||
|
IdRole = Qt::UserRole
|
||||||
};
|
};
|
||||||
|
|
||||||
void notifyRunning() // Clear state information.
|
void notifyRunning() // Clear state information.
|
||||||
@@ -72,22 +99,25 @@ struct ThreadData
|
|||||||
frameLevel = -1;
|
frameLevel = -1;
|
||||||
state.clear();
|
state.clear();
|
||||||
lineNumber = -1;
|
lineNumber = -1;
|
||||||
|
stopped = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Permanent data.
|
// Permanent data.
|
||||||
quint64 id;
|
ThreadId id;
|
||||||
|
QByteArray groupId;
|
||||||
QString targetId;
|
QString targetId;
|
||||||
QString core;
|
QString core;
|
||||||
|
bool stopped;
|
||||||
|
|
||||||
// State information when stopped.
|
// State information when stopped.
|
||||||
qint32 frameLevel;
|
qint32 frameLevel;
|
||||||
|
qint32 lineNumber;
|
||||||
quint64 address;
|
quint64 address;
|
||||||
QString function;
|
QString function;
|
||||||
QString module;
|
QString module;
|
||||||
QString fileName;
|
QString fileName;
|
||||||
QString details;
|
QString details;
|
||||||
QString state;
|
QString state;
|
||||||
qint32 lineNumber;
|
|
||||||
QString name;
|
QString name;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,8 @@
|
|||||||
#include "debuggerconstants.h"
|
#include "debuggerconstants.h"
|
||||||
#include "debuggercore.h"
|
#include "debuggercore.h"
|
||||||
|
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
@@ -41,6 +43,32 @@
|
|||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
void mergeThreadData(ThreadData &data, const ThreadData &other)
|
||||||
|
{
|
||||||
|
if (!other.core.isEmpty())
|
||||||
|
data.core = other.core;
|
||||||
|
if (!other.fileName.isEmpty())
|
||||||
|
data.fileName = other.fileName;
|
||||||
|
if (!other.targetId.isEmpty())
|
||||||
|
data.targetId = other.targetId;
|
||||||
|
if (!other.name.isEmpty())
|
||||||
|
data.name = other.name;
|
||||||
|
if (other.frameLevel != -1)
|
||||||
|
data.frameLevel = other.frameLevel;
|
||||||
|
if (!other.function.isEmpty())
|
||||||
|
data.function = other.function;
|
||||||
|
if (!other.address)
|
||||||
|
data.address = other.address;
|
||||||
|
if (!other.module.isEmpty())
|
||||||
|
data.module = other.module;
|
||||||
|
if (!other.details.isEmpty())
|
||||||
|
data.details = other.details;
|
||||||
|
if (!other.state.isEmpty())
|
||||||
|
data.state = other.state;
|
||||||
|
if (other.lineNumber != -1)
|
||||||
|
data.lineNumber = other.lineNumber;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// ThreadsHandler
|
// ThreadsHandler
|
||||||
@@ -56,10 +84,13 @@ static QString threadToolTip(const ThreadData &thread)
|
|||||||
QTextStream str(&rc);
|
QTextStream str(&rc);
|
||||||
str << "<html><head/><body><table>"
|
str << "<html><head/><body><table>"
|
||||||
<< start << ThreadsHandler::tr("Thread id:")
|
<< start << ThreadsHandler::tr("Thread id:")
|
||||||
<< sep << thread.id << end;
|
<< sep << thread.id.raw() << end;
|
||||||
if (!thread.targetId.isEmpty())
|
if (!thread.targetId.isEmpty())
|
||||||
str << start << ThreadsHandler::tr("Target id:")
|
str << start << ThreadsHandler::tr("Target id:")
|
||||||
<< sep << thread.targetId << end;
|
<< sep << thread.targetId << end;
|
||||||
|
if (!thread.groupId.isEmpty())
|
||||||
|
str << start << ThreadsHandler::tr("Group id:")
|
||||||
|
<< sep << thread.groupId << end;
|
||||||
if (!thread.name.isEmpty())
|
if (!thread.name.isEmpty())
|
||||||
str << start << ThreadsHandler::tr("Name:")
|
str << start << ThreadsHandler::tr("Name:")
|
||||||
<< sep << thread.name << end;
|
<< sep << thread.name << end;
|
||||||
@@ -98,14 +129,13 @@ static QString threadToolTip(const ThreadData &thread)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
ThreadsHandler::ThreadsHandler()
|
ThreadsHandler::ThreadsHandler()
|
||||||
: m_currentIndex(0),
|
: m_currentIndex(-1),
|
||||||
m_positionIcon(QLatin1String(":/debugger/images/location_16.png")),
|
m_positionIcon(QLatin1String(":/debugger/images/location_16.png")),
|
||||||
m_emptyIcon(QLatin1String(":/debugger/images/debugger_empty_14.png"))
|
m_emptyIcon(QLatin1String(":/debugger/images/debugger_empty_14.png"))
|
||||||
{
|
{
|
||||||
m_resetLocationScheduled = false;
|
m_resetLocationScheduled = false;
|
||||||
m_contentsValid = false;
|
// m_proxyModel = new QSortFilterProxyModel(this);
|
||||||
m_proxyModel = new QSortFilterProxyModel(this);
|
// m_proxyModel->setSourceModel(this);
|
||||||
m_proxyModel->setSourceModel(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ThreadsHandler::rowCount(const QModelIndex &parent) const
|
int ThreadsHandler::rowCount(const QModelIndex &parent) const
|
||||||
@@ -132,7 +162,7 @@ QVariant ThreadsHandler::data(const QModelIndex &index, int role) const
|
|||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
switch (index.column()) {
|
switch (index.column()) {
|
||||||
case ThreadData::IdColumn:
|
case ThreadData::IdColumn:
|
||||||
return thread.id;
|
return thread.id.raw();
|
||||||
case ThreadData::FunctionColumn:
|
case ThreadData::FunctionColumn:
|
||||||
return thread.function;
|
return thread.function;
|
||||||
case ThreadData::FileColumn:
|
case ThreadData::FileColumn:
|
||||||
@@ -157,7 +187,7 @@ QVariant ThreadsHandler::data(const QModelIndex &index, int role) const
|
|||||||
case ThreadData::DetailsColumn:
|
case ThreadData::DetailsColumn:
|
||||||
return thread.details;
|
return thread.details;
|
||||||
case ThreadData::ComboNameColumn:
|
case ThreadData::ComboNameColumn:
|
||||||
return QString::fromLatin1("#%1 %2").arg(thread.id).arg(thread.name);
|
return QString::fromLatin1("#%1 %2").arg(thread.id.raw()).arg(thread.name);
|
||||||
}
|
}
|
||||||
case Qt::ToolTipRole:
|
case Qt::ToolTipRole:
|
||||||
return threadToolTip(thread);
|
return threadToolTip(thread);
|
||||||
@@ -166,6 +196,8 @@ QVariant ThreadsHandler::data(const QModelIndex &index, int role) const
|
|||||||
if (index.column() == 0)
|
if (index.column() == 0)
|
||||||
return (index.row() == m_currentIndex) ? m_positionIcon : m_emptyIcon;
|
return (index.row() == m_currentIndex) ? m_positionIcon : m_emptyIcon;
|
||||||
break;
|
break;
|
||||||
|
case ThreadData::IdRole:
|
||||||
|
return thread.id.raw();
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -204,52 +236,79 @@ QVariant ThreadsHandler::headerData
|
|||||||
|
|
||||||
Qt::ItemFlags ThreadsHandler::flags(const QModelIndex &index) const
|
Qt::ItemFlags ThreadsHandler::flags(const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
return m_contentsValid ? QAbstractTableModel::flags(index) : Qt::ItemFlags(0);
|
const int row = index.row();
|
||||||
|
const bool stopped = row >= 0 && row < m_threads.size()
|
||||||
|
&& m_threads.at(row).stopped;
|
||||||
|
return stopped ? QAbstractTableModel::flags(index) : Qt::ItemFlags(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ThreadsHandler::currentThreadId() const
|
ThreadId ThreadsHandler::currentThread() const
|
||||||
{
|
{
|
||||||
if (m_currentIndex < 0 || m_currentIndex >= m_threads.size())
|
if (m_currentIndex < 0 || m_currentIndex >= m_threads.size())
|
||||||
return -1;
|
return ThreadId();
|
||||||
return m_threads[m_currentIndex].id;
|
return m_threads[m_currentIndex].id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadsHandler::setCurrentThread(int index)
|
ThreadId ThreadsHandler::threadAt(int index) const
|
||||||
{
|
{
|
||||||
|
QTC_ASSERT(index >= 0 && index < m_threads.size(), return ThreadId());
|
||||||
|
return m_threads[index].id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ThreadsHandler::setCurrentThread(ThreadId id)
|
||||||
|
{
|
||||||
|
const int index = indexOf(id);
|
||||||
if (index == m_currentIndex)
|
if (index == m_currentIndex)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (index == -1) {
|
||||||
|
qWarning("ThreadsHandler::setCurrentThreadId: No such thread %d.", int(id.raw()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Emit changed for previous frame.
|
// Emit changed for previous frame.
|
||||||
QModelIndex i = ThreadsHandler::index(m_currentIndex, 0);
|
if (m_currentIndex != -1)
|
||||||
emit dataChanged(i, i);
|
dataChanged(m_currentIndex);
|
||||||
|
|
||||||
m_currentIndex = index;
|
m_currentIndex = index;
|
||||||
|
|
||||||
// Emit changed for new frame.
|
// Emit changed for new frame.
|
||||||
i = ThreadsHandler::index(m_currentIndex, 0);
|
dataChanged(m_currentIndex);
|
||||||
emit dataChanged(i, i);
|
|
||||||
|
|
||||||
updateThreadBox();
|
updateThreadBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadsHandler::setCurrentThreadId(int id)
|
int ThreadsHandler::indexOf(ThreadId threadId) const
|
||||||
{
|
{
|
||||||
const int index = indexOf(id);
|
for (int i = m_threads.size(); --i >= 0; )
|
||||||
if (index != -1)
|
|
||||||
setCurrentThread(index);
|
|
||||||
else
|
|
||||||
qWarning("ThreadsHandler::setCurrentThreadId: No such thread %d.", id);
|
|
||||||
}
|
|
||||||
|
|
||||||
int ThreadsHandler::indexOf(quint64 threadId) const
|
|
||||||
{
|
|
||||||
const int count = m_threads.size();
|
|
||||||
for (int i = 0; i < count; ++i)
|
|
||||||
if (m_threads.at(i).id == threadId)
|
if (m_threads.at(i).id == threadId)
|
||||||
return i;
|
return i;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ThreadsHandler::updateThread(const ThreadData &thread)
|
||||||
|
{
|
||||||
|
const int i = indexOf(thread.id);
|
||||||
|
if (i == -1) {
|
||||||
|
beginInsertRows(QModelIndex(), m_threads.size(), m_threads.size());
|
||||||
|
m_threads.append(thread);
|
||||||
|
endInsertRows();
|
||||||
|
} else {
|
||||||
|
mergeThreadData(m_threads[i], thread);
|
||||||
|
dataChanged(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ThreadsHandler::removeThread(ThreadId threadId)
|
||||||
|
{
|
||||||
|
const int i = indexOf(threadId);
|
||||||
|
if (i == -1)
|
||||||
|
return;
|
||||||
|
beginRemoveRows(QModelIndex(), i, i);
|
||||||
|
m_threads.remove(i);
|
||||||
|
endRemoveRows();
|
||||||
|
}
|
||||||
|
|
||||||
void ThreadsHandler::setThreads(const Threads &threads)
|
void ThreadsHandler::setThreads(const Threads &threads)
|
||||||
{
|
{
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
@@ -257,7 +316,6 @@ void ThreadsHandler::setThreads(const Threads &threads)
|
|||||||
if (m_currentIndex >= m_threads.size())
|
if (m_currentIndex >= m_threads.size())
|
||||||
m_currentIndex = -1;
|
m_currentIndex = -1;
|
||||||
m_resetLocationScheduled = false;
|
m_resetLocationScheduled = false;
|
||||||
m_contentsValid = true;
|
|
||||||
endResetModel();
|
endResetModel();
|
||||||
updateThreadBox();
|
updateThreadBox();
|
||||||
}
|
}
|
||||||
@@ -266,38 +324,96 @@ void ThreadsHandler::updateThreadBox()
|
|||||||
{
|
{
|
||||||
QStringList list;
|
QStringList list;
|
||||||
foreach (const ThreadData &thread, m_threads)
|
foreach (const ThreadData &thread, m_threads)
|
||||||
list.append(QString::fromLatin1("#%1 %2").arg(thread.id).arg(thread.name));
|
list.append(QString::fromLatin1("#%1 %2").arg(thread.id.raw()).arg(thread.name));
|
||||||
debuggerCore()->setThreads(list, m_currentIndex);
|
debuggerCore()->setThreads(list, m_currentIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ThreadsHandler::dataChanged(int index)
|
||||||
|
{
|
||||||
|
Q_UNUSED(index);
|
||||||
|
layoutChanged();
|
||||||
|
}
|
||||||
|
|
||||||
Threads ThreadsHandler::threads() const
|
Threads ThreadsHandler::threads() const
|
||||||
{
|
{
|
||||||
return m_threads;
|
return m_threads;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ThreadData ThreadsHandler::thread(ThreadId id) const
|
||||||
|
{
|
||||||
|
const int i = indexOf(id);
|
||||||
|
return i == -1 ? ThreadData() : m_threads.at(i);
|
||||||
|
}
|
||||||
|
|
||||||
void ThreadsHandler::removeAll()
|
void ThreadsHandler::removeAll()
|
||||||
{
|
{
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
m_threads.clear();
|
m_threads.clear();
|
||||||
m_currentIndex = 0;
|
m_currentIndex = -1;
|
||||||
endResetModel();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadsHandler::notifyRunning()
|
void ThreadsHandler::notifyRunning(const QByteArray &data)
|
||||||
{
|
{
|
||||||
// Threads stopped (that is, address != 0 showing)?
|
if (data.isEmpty() || data == "all") {
|
||||||
if (m_threads.empty())
|
notifyAllRunning();
|
||||||
return;
|
} else {
|
||||||
if (m_threads.front().address == 0)
|
bool ok;
|
||||||
return;
|
qlonglong id = data.toLongLong(&ok);
|
||||||
const Threads::iterator end = m_threads.end();
|
if (ok)
|
||||||
for (Threads::iterator it = m_threads.begin(); it != end; ++it)
|
notifyRunning(ThreadId(id));
|
||||||
it->notifyRunning();
|
else // FIXME
|
||||||
emit dataChanged(index(0, 1),
|
notifyAllRunning();
|
||||||
index(m_threads.size() - 1, ThreadData::ColumnCount - 1));
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Threads ThreadsHandler::parseGdbmiThreads(const GdbMi &data, int *currentThread)
|
void ThreadsHandler::notifyAllRunning()
|
||||||
|
{
|
||||||
|
for (int i = m_threads.size(); --i >= 0; )
|
||||||
|
m_threads[i].notifyRunning();
|
||||||
|
layoutChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ThreadsHandler::notifyRunning(ThreadId id)
|
||||||
|
{
|
||||||
|
int i = indexOf(id);
|
||||||
|
if (i >= 0) {
|
||||||
|
m_threads[i].notifyRunning();
|
||||||
|
dataChanged(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ThreadsHandler::notifyStopped(const QByteArray &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()
|
||||||
|
{
|
||||||
|
for (int i = m_threads.size(); --i >= 0; )
|
||||||
|
m_threads[i].stopped = true;
|
||||||
|
layoutChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ThreadsHandler::notifyStopped(ThreadId id)
|
||||||
|
{
|
||||||
|
int i = indexOf(id);
|
||||||
|
if (i >= 0) {
|
||||||
|
m_threads[i].stopped = true;
|
||||||
|
dataChanged(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ThreadsHandler::updateThreads(const GdbMi &data)
|
||||||
{
|
{
|
||||||
// ^done,threads=[{id="1",target-id="Thread 0xb7fdc710 (LWP 4264)",
|
// ^done,threads=[{id="1",target-id="Thread 0xb7fdc710 (LWP 4264)",
|
||||||
// frame={level="0",addr="0x080530bf",func="testQString",args=[],
|
// frame={level="0",addr="0x080530bf",func="testQString",args=[],
|
||||||
@@ -305,14 +421,12 @@ Threads ThreadsHandler::parseGdbmiThreads(const GdbMi &data, int *currentThread)
|
|||||||
// state="stopped",core="0"}],current-thread-id="1"
|
// state="stopped",core="0"}],current-thread-id="1"
|
||||||
const QList<GdbMi> items = data.findChild("threads").children();
|
const QList<GdbMi> items = data.findChild("threads").children();
|
||||||
const int n = items.size();
|
const int n = items.size();
|
||||||
Threads threads;
|
|
||||||
threads.reserve(n);
|
|
||||||
for (int index = 0; index != n; ++index) {
|
for (int index = 0; index != n; ++index) {
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
const GdbMi item = items.at(index);
|
const GdbMi item = items.at(index);
|
||||||
const GdbMi frame = item.findChild("frame");
|
const GdbMi frame = item.findChild("frame");
|
||||||
ThreadData thread;
|
ThreadData thread;
|
||||||
thread.id = item.findChild("id").data().toInt();
|
thread.id = ThreadId(item.findChild("id").data().toInt());
|
||||||
thread.targetId = QString::fromLatin1(item.findChild("target-id").data());
|
thread.targetId = QString::fromLatin1(item.findChild("target-id").data());
|
||||||
thread.details = QString::fromLatin1(item.findChild("details").data());
|
thread.details = QString::fromLatin1(item.findChild("details").data());
|
||||||
thread.core = QString::fromLatin1(item.findChild("core").data());
|
thread.core = QString::fromLatin1(item.findChild("core").data());
|
||||||
@@ -322,33 +436,36 @@ Threads ThreadsHandler::parseGdbmiThreads(const GdbMi &data, int *currentThread)
|
|||||||
thread.fileName = QString::fromLatin1(frame.findChild("fullname").data());
|
thread.fileName = QString::fromLatin1(frame.findChild("fullname").data());
|
||||||
thread.lineNumber = frame.findChild("line").data().toInt();
|
thread.lineNumber = frame.findChild("line").data().toInt();
|
||||||
thread.module = QString::fromLocal8Bit(frame.findChild("from").data());
|
thread.module = QString::fromLocal8Bit(frame.findChild("from").data());
|
||||||
|
thread.stopped = true;
|
||||||
// Non-GDB (Cdb2) output name here.
|
// Non-GDB (Cdb2) output name here.
|
||||||
thread.name = QString::fromLatin1(frame.findChild("name").data());
|
thread.name = QString::fromLatin1(frame.findChild("name").data());
|
||||||
threads.append(thread);
|
if (thread.state == QLatin1String("running"))
|
||||||
|
thread.stopped = false;
|
||||||
|
updateThread(thread);
|
||||||
}
|
}
|
||||||
if (currentThread)
|
const GdbMi current = data.findChild("current-thread-id");
|
||||||
*currentThread = data.findChild("current-thread-id").data().toInt();
|
if (current.isValid())
|
||||||
return threads;
|
setCurrentThread(ThreadId(current.data().toLongLong()));
|
||||||
|
updateThreadBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadsHandler::scheduleResetLocation()
|
void ThreadsHandler::scheduleResetLocation()
|
||||||
{
|
{
|
||||||
m_resetLocationScheduled = true;
|
m_resetLocationScheduled = true;
|
||||||
m_contentsValid = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadsHandler::resetLocation()
|
void ThreadsHandler::resetLocation()
|
||||||
{
|
{
|
||||||
if (m_resetLocationScheduled) {
|
if (m_resetLocationScheduled) {
|
||||||
beginResetModel();
|
|
||||||
m_resetLocationScheduled = false;
|
m_resetLocationScheduled = false;
|
||||||
endResetModel();
|
layoutChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QAbstractItemModel *ThreadsHandler::model()
|
QAbstractItemModel *ThreadsHandler::model()
|
||||||
{
|
{
|
||||||
return m_proxyModel;
|
return this;
|
||||||
|
//return m_proxyModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -57,26 +57,35 @@ class ThreadsHandler : public QAbstractTableModel
|
|||||||
public:
|
public:
|
||||||
ThreadsHandler();
|
ThreadsHandler();
|
||||||
|
|
||||||
int currentThread() const { return m_currentIndex; }
|
int currentThreadIndex() const { return m_currentIndex; }
|
||||||
void setCurrentThread(int index);
|
ThreadId currentThread() const;
|
||||||
int currentThreadId() const;
|
ThreadId threadAt(int index) const;
|
||||||
void setCurrentThreadId(int id);
|
void setCurrentThread(ThreadId id);
|
||||||
int indexOf(quint64 threadId) const;
|
|
||||||
|
|
||||||
|
void updateThread(const ThreadData &thread);
|
||||||
|
void updateThreads(const GdbMi &data);
|
||||||
|
|
||||||
|
void removeThread(ThreadId threadId);
|
||||||
void setThreads(const Threads &threads);
|
void setThreads(const Threads &threads);
|
||||||
void removeAll();
|
void removeAll();
|
||||||
Threads threads() const;
|
Threads threads() const;
|
||||||
|
ThreadData thread(ThreadId id) const;
|
||||||
QAbstractItemModel *model();
|
QAbstractItemModel *model();
|
||||||
|
|
||||||
// Clear out all frame information
|
// Clear out all frame information
|
||||||
void notifyRunning();
|
void notifyRunning(const QByteArray &data);
|
||||||
|
void notifyRunning(ThreadId id);
|
||||||
|
void notifyAllRunning();
|
||||||
|
|
||||||
static Threads parseGdbmiThreads(const GdbMi &data, int *currentThread = 0);
|
void notifyStopped(const QByteArray &data);
|
||||||
|
void notifyStopped(ThreadId id);
|
||||||
|
void notifyAllStopped();
|
||||||
|
|
||||||
void resetLocation();
|
void resetLocation();
|
||||||
void scheduleResetLocation();
|
void scheduleResetLocation();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
int indexOf(ThreadId threadId) const;
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||||
@@ -84,6 +93,7 @@ private:
|
|||||||
int role = Qt::DisplayRole) const;
|
int role = Qt::DisplayRole) const;
|
||||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||||
void updateThreadBox();
|
void updateThreadBox();
|
||||||
|
void dataChanged(int index);
|
||||||
|
|
||||||
Threads m_threads;
|
Threads m_threads;
|
||||||
int m_currentIndex;
|
int m_currentIndex;
|
||||||
@@ -91,9 +101,8 @@ private:
|
|||||||
const QIcon m_emptyIcon;
|
const QIcon m_emptyIcon;
|
||||||
|
|
||||||
bool m_resetLocationScheduled;
|
bool m_resetLocationScheduled;
|
||||||
bool m_contentsValid;
|
|
||||||
|
|
||||||
QSortFilterProxyModel *m_proxyModel;
|
//QSortFilterProxyModel *m_proxyModel;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -53,7 +53,8 @@ ThreadsTreeView::ThreadsTreeView()
|
|||||||
|
|
||||||
void ThreadsTreeView::rowActivated(const QModelIndex &index)
|
void ThreadsTreeView::rowActivated(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
debuggerCore()->currentEngine()->selectThread(index.row());
|
ThreadId id = ThreadId(index.data(ThreadData::IdRole).toLongLong());
|
||||||
|
debuggerCore()->currentEngine()->selectThread(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadsTreeView::setModel(QAbstractItemModel *model)
|
void ThreadsTreeView::setModel(QAbstractItemModel *model)
|
||||||
|
|||||||
Reference in New Issue
Block a user