2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-05-18 12:12:22 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2010-05-18 12:12:22 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2010-05-18 12:12:22 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2010-05-18 12:12:22 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2010-05-18 12:12:22 +02:00
|
|
|
|
|
|
|
|
#include "threadshandler.h"
|
|
|
|
|
|
2016-07-18 12:36:31 +02:00
|
|
|
#include "debuggeractions.h"
|
2011-09-01 16:36:27 +02:00
|
|
|
#include "debuggercore.h"
|
2016-07-18 12:36:31 +02:00
|
|
|
#include "debuggerengine.h"
|
2015-11-23 16:41:54 +01:00
|
|
|
#include "debuggericons.h"
|
2013-01-24 10:38:40 +01:00
|
|
|
#include "debuggerprotocol.h"
|
|
|
|
|
#include "watchutils.h"
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2014-06-16 18:25:52 +04:00
|
|
|
#include <utils/algorithm.h>
|
2016-07-18 12:36:31 +02:00
|
|
|
#include <utils/basetreeview.h>
|
2012-10-19 16:37:57 +02:00
|
|
|
#include <utils/qtcassert.h>
|
2016-07-18 12:36:31 +02:00
|
|
|
#include <utils/savedaction.h>
|
2012-10-19 16:37:57 +02:00
|
|
|
|
2015-06-12 11:55:57 +02:00
|
|
|
#include <QCoreApplication>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QDebug>
|
2015-06-12 11:55:57 +02:00
|
|
|
#include <QIcon>
|
2016-07-18 12:36:31 +02:00
|
|
|
#include <QMenu>
|
2015-06-12 11:55:57 +02:00
|
|
|
|
|
|
|
|
using namespace Utils;
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2010-05-18 12:12:22 +02:00
|
|
|
namespace Debugger {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2015-06-12 11:55:57 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// ThreadItem
|
|
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2018-08-15 17:28:00 +02:00
|
|
|
// ThreadItem
|
2015-06-12 11:55:57 +02:00
|
|
|
|
2018-08-30 09:56:51 +02:00
|
|
|
ThreadItem::ThreadItem(const ThreadData &data)
|
|
|
|
|
: threadData(data)
|
2018-08-15 17:28:00 +02:00
|
|
|
{}
|
2015-06-12 11:55:57 +02:00
|
|
|
|
2018-08-15 17:28:00 +02:00
|
|
|
QVariant ThreadItem::data(int column, int role) const
|
|
|
|
|
{
|
|
|
|
|
switch (role) {
|
|
|
|
|
case Qt::DisplayRole:
|
|
|
|
|
if (column == 0)
|
|
|
|
|
return QString("#%1 %2").arg(threadData.id).arg(threadData.name);
|
|
|
|
|
return threadPart(column);
|
|
|
|
|
case Qt::ToolTipRole:
|
|
|
|
|
return threadToolTip();
|
|
|
|
|
default:
|
|
|
|
|
break;
|
2015-06-12 11:55:57 +02:00
|
|
|
}
|
2018-08-15 17:28:00 +02:00
|
|
|
return QVariant();
|
|
|
|
|
}
|
2015-06-12 11:55:57 +02:00
|
|
|
|
2018-08-15 17:28:00 +02:00
|
|
|
Qt::ItemFlags ThreadItem::flags(int column) const
|
|
|
|
|
{
|
|
|
|
|
return threadData.stopped ? TreeItem::flags(column) : Qt::ItemFlags({});
|
|
|
|
|
}
|
2015-06-12 11:55:57 +02:00
|
|
|
|
2018-08-15 17:28:00 +02:00
|
|
|
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);
|
2015-06-12 11:55:57 +02:00
|
|
|
}
|
2018-08-15 17:28:00 +02:00
|
|
|
str << "</table></body></html>";
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
2015-06-12 11:55:57 +02:00
|
|
|
|
2018-08-15 17:28:00 +02:00
|
|
|
QVariant ThreadItem::threadPart(int column) const
|
|
|
|
|
{
|
|
|
|
|
switch (column) {
|
|
|
|
|
case ThreadData::IdColumn:
|
|
|
|
|
return threadData.id;
|
|
|
|
|
case ThreadData::FunctionColumn:
|
|
|
|
|
return threadData.function;
|
|
|
|
|
case ThreadData::FileColumn:
|
|
|
|
|
return threadData.fileName.isEmpty() ? threadData.module : threadData.fileName;
|
|
|
|
|
case ThreadData::LineColumn:
|
|
|
|
|
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).arg(threadData.name);
|
2015-06-12 11:55:57 +02:00
|
|
|
}
|
2018-08-15 17:28:00 +02:00
|
|
|
return QVariant();
|
|
|
|
|
}
|
2015-06-12 11:55:57 +02:00
|
|
|
|
2018-08-15 17:28:00 +02:00
|
|
|
void ThreadItem::notifyRunning() // Clear state information.
|
|
|
|
|
{
|
|
|
|
|
threadData.address = 0;
|
|
|
|
|
threadData.function.clear();
|
|
|
|
|
threadData.fileName.clear();
|
|
|
|
|
threadData.frameLevel = -1;
|
|
|
|
|
threadData.state.clear();
|
|
|
|
|
threadData.lineNumber = -1;
|
|
|
|
|
threadData.stopped = false;
|
|
|
|
|
update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ThreadItem::notifyStopped()
|
|
|
|
|
{
|
|
|
|
|
threadData.stopped = true;
|
|
|
|
|
update();
|
|
|
|
|
}
|
2015-06-12 11:55:57 +02:00
|
|
|
|
2018-08-15 17:28:00 +02:00
|
|
|
void ThreadItem::mergeThreadData(const ThreadData &other)
|
|
|
|
|
{
|
|
|
|
|
if (!other.core.isEmpty())
|
|
|
|
|
threadData.core = other.core;
|
|
|
|
|
if (!other.fileName.isEmpty())
|
|
|
|
|
threadData.fileName = other.fileName;
|
|
|
|
|
if (!other.targetId.isEmpty())
|
|
|
|
|
threadData.targetId = other.targetId;
|
|
|
|
|
if (!other.name.isEmpty())
|
|
|
|
|
threadData.name = other.name;
|
|
|
|
|
if (other.frameLevel != -1)
|
|
|
|
|
threadData.frameLevel = other.frameLevel;
|
|
|
|
|
if (!other.function.isEmpty())
|
|
|
|
|
threadData.function = other.function;
|
|
|
|
|
if (other.address)
|
|
|
|
|
threadData.address = other.address;
|
|
|
|
|
if (!other.module.isEmpty())
|
|
|
|
|
threadData.module = other.module;
|
|
|
|
|
if (!other.details.isEmpty())
|
|
|
|
|
threadData.details = other.details;
|
|
|
|
|
if (!other.state.isEmpty())
|
|
|
|
|
threadData.state = other.state;
|
|
|
|
|
if (other.lineNumber != -1)
|
|
|
|
|
threadData.lineNumber = other.lineNumber;
|
|
|
|
|
update();
|
|
|
|
|
}
|
2015-06-12 11:55:57 +02:00
|
|
|
|
2010-07-02 14:35:41 +02:00
|
|
|
|
2010-05-18 12:12:22 +02:00
|
|
|
// ThreadsHandler
|
|
|
|
|
|
2011-02-04 15:08:31 +01:00
|
|
|
/*!
|
2013-06-05 14:29:24 +02:00
|
|
|
\class Debugger::Internal::ThreadData
|
|
|
|
|
\internal
|
|
|
|
|
\brief The ThreadData class contains information
|
|
|
|
|
about a single thread.
|
2011-02-04 15:08:31 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\class Debugger::Internal::ThreadsHandler
|
2013-06-05 14:29:24 +02:00
|
|
|
\internal
|
|
|
|
|
\brief The ThreadsHandler class provides a model to
|
|
|
|
|
represent the running threads in a QTreeView or ComboBox.
|
2011-02-04 15:08:31 +01:00
|
|
|
*/
|
|
|
|
|
|
2016-07-18 12:36:31 +02:00
|
|
|
ThreadsHandler::ThreadsHandler(DebuggerEngine *engine)
|
|
|
|
|
: m_engine(engine)
|
2010-05-18 12:12:22 +02:00
|
|
|
{
|
2013-08-19 13:30:10 +02:00
|
|
|
setObjectName(QLatin1String("ThreadsModel"));
|
2015-06-12 11:55:57 +02:00
|
|
|
setHeader({
|
2018-08-15 17:28:00 +02:00
|
|
|
QLatin1String(" ") + tr("ID") + QLatin1String(" "),
|
|
|
|
|
tr("Address"), tr("Function"), tr("File"), tr("Line"), tr("State"),
|
|
|
|
|
tr("Name"), tr("Target ID"), tr("Details"), tr("Core"),
|
|
|
|
|
});
|
2010-05-18 12:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
2018-08-30 09:56:51 +02:00
|
|
|
QVariant ThreadsHandler::data(const QModelIndex &index, int role) const
|
|
|
|
|
{
|
|
|
|
|
if (role == Qt::DecorationRole && index.column() == 0) {
|
|
|
|
|
// Return icon that indicates whether this is the active thread.
|
|
|
|
|
TreeItem *item = itemForIndex(index);
|
|
|
|
|
if (item && item == m_currentThread)
|
|
|
|
|
return Icons::LOCATION.icon();
|
|
|
|
|
return Icons::EMPTY.icon();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ThreadsHandlerModel::data(index, role);
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-18 12:36:31 +02:00
|
|
|
bool ThreadsHandler::setData(const QModelIndex &idx, const QVariant &data, int role)
|
|
|
|
|
{
|
|
|
|
|
if (role == BaseTreeView::ItemActivatedRole) {
|
2018-08-15 17:28:00 +02:00
|
|
|
const Thread thread = itemForIndexAtLevel<1>(idx);
|
|
|
|
|
m_engine->selectThread(thread);
|
2016-07-18 12:36:31 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (role == BaseTreeView::ItemViewEventRole) {
|
2016-09-29 15:49:34 +03:00
|
|
|
ItemViewEvent ev = data.value<ItemViewEvent>();
|
|
|
|
|
|
|
|
|
|
if (ev.as<QContextMenuEvent>()) {
|
|
|
|
|
auto menu = new QMenu;
|
|
|
|
|
menu->addAction(action(SettingsDialog));
|
|
|
|
|
menu->popup(ev.globalPos());
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2016-07-18 12:36:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-12 11:55:57 +02:00
|
|
|
int ThreadsHandler::currentThreadIndex() const
|
2011-04-18 16:40:59 +02:00
|
|
|
{
|
2018-08-15 17:28:00 +02:00
|
|
|
return rootItem()->indexOf(m_currentThread);
|
2011-04-18 16:40:59 +02:00
|
|
|
}
|
|
|
|
|
|
2014-06-16 18:25:52 +04:00
|
|
|
void ThreadsHandler::sort(int column, Qt::SortOrder order)
|
2013-11-20 02:19:54 +01:00
|
|
|
{
|
2016-06-27 13:46:46 +02:00
|
|
|
rootItem()->sortChildren([order, column](const ThreadItem *item1, const ThreadItem *item2) -> bool {
|
|
|
|
|
const QVariant v1 = item1->threadPart(column);
|
|
|
|
|
const QVariant v2 = item2->threadPart(column);
|
2013-11-20 02:19:54 +01:00
|
|
|
if (v1 == v2)
|
|
|
|
|
return false;
|
2015-06-12 11:55:57 +02:00
|
|
|
if (column == 0)
|
|
|
|
|
return (v1.toInt() < v2.toInt()) ^ (order == Qt::DescendingOrder);
|
2013-11-20 14:47:31 +01:00
|
|
|
// FIXME: Use correct toXXX();
|
2014-06-16 18:25:52 +04:00
|
|
|
return (v1.toString() < v2.toString()) ^ (order == Qt::DescendingOrder);
|
2015-06-12 11:55:57 +02:00
|
|
|
});
|
2013-11-20 02:19:54 +01:00
|
|
|
}
|
|
|
|
|
|
2018-08-15 17:28:00 +02:00
|
|
|
Thread ThreadsHandler::currentThread() const
|
2010-05-18 12:12:22 +02:00
|
|
|
{
|
2018-08-15 17:28:00 +02:00
|
|
|
return m_currentThread;
|
2010-05-18 12:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
2018-08-15 17:28:00 +02:00
|
|
|
void ThreadsHandler::setCurrentThread(const Thread &thread)
|
2012-10-19 16:37:57 +02:00
|
|
|
{
|
2018-08-15 17:28:00 +02:00
|
|
|
if (thread == m_currentThread)
|
2010-05-18 12:12:22 +02:00
|
|
|
return;
|
|
|
|
|
|
2018-08-15 17:28:00 +02:00
|
|
|
if (!threadForId(thread->id())) {
|
|
|
|
|
qWarning("ThreadsHandler::setCurrentThreadId: No such thread %s.", qPrintable(thread->id()));
|
2012-10-19 16:37:57 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-15 17:28:00 +02:00
|
|
|
m_currentThread = thread;
|
|
|
|
|
thread->update();
|
2010-05-18 12:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
2016-06-07 17:04:53 +02:00
|
|
|
void ThreadsHandler::notifyGroupCreated(const QString &groupId, const QString &pid)
|
2015-06-12 15:17:14 +02:00
|
|
|
{
|
|
|
|
|
m_pidForGroupId[groupId] = pid;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-12 11:55:57 +02:00
|
|
|
void ThreadsHandler::updateThread(const ThreadData &threadData)
|
2010-07-02 10:58:47 +02:00
|
|
|
{
|
2018-08-15 17:28:00 +02:00
|
|
|
if (Thread thread = threadForId(threadData.id))
|
|
|
|
|
thread->mergeThreadData(threadData);
|
2015-06-12 11:55:57 +02:00
|
|
|
else
|
2018-08-30 09:56:51 +02:00
|
|
|
rootItem()->appendChild(new ThreadItem(threadData));
|
2012-10-19 16:37:57 +02:00
|
|
|
}
|
|
|
|
|
|
2018-08-15 17:28:00 +02:00
|
|
|
void ThreadsHandler::removeThread(const QString &id)
|
2012-10-19 16:37:57 +02:00
|
|
|
{
|
2018-08-15 17:28:00 +02:00
|
|
|
if (Thread thread = threadForId(id))
|
|
|
|
|
destroyItem(thread);
|
2012-10-19 16:37:57 +02:00
|
|
|
}
|
|
|
|
|
|
2010-05-18 12:12:22 +02:00
|
|
|
void ThreadsHandler::removeAll()
|
|
|
|
|
{
|
2015-06-12 11:55:57 +02:00
|
|
|
rootItem()->removeChildren();
|
2015-06-12 15:17:14 +02:00
|
|
|
}
|
|
|
|
|
|
2016-06-07 17:04:53 +02:00
|
|
|
bool ThreadsHandler::notifyGroupExited(const QString &groupId)
|
2015-06-12 15:17:14 +02:00
|
|
|
{
|
|
|
|
|
QList<ThreadItem *> list;
|
2016-06-24 09:36:42 +02:00
|
|
|
forItemsAtLevel<1>([&list, groupId](ThreadItem *item) {
|
2016-04-29 09:39:44 +02:00
|
|
|
if (item->threadData.groupId == groupId)
|
2015-06-12 15:17:14 +02:00
|
|
|
list.append(item);
|
2016-05-04 16:41:15 +02:00
|
|
|
});
|
2015-06-12 15:17:14 +02:00
|
|
|
foreach (ThreadItem *item, list)
|
2016-07-04 15:53:53 +02:00
|
|
|
destroyItem(item);
|
2015-06-12 15:17:14 +02:00
|
|
|
|
|
|
|
|
m_pidForGroupId.remove(groupId);
|
|
|
|
|
return m_pidForGroupId.isEmpty();
|
2010-05-18 12:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
2018-08-15 17:28:00 +02:00
|
|
|
Thread ThreadsHandler::threadForId(const QString &id) const
|
2012-10-19 16:37:57 +02:00
|
|
|
{
|
2018-08-15 17:28:00 +02:00
|
|
|
return findItemAtLevel<1>([id](const Thread &item) {
|
|
|
|
|
return item->threadData.id == id;
|
|
|
|
|
});
|
2012-10-19 16:37:57 +02:00
|
|
|
}
|
|
|
|
|
|
2018-08-15 17:28:00 +02:00
|
|
|
void ThreadsHandler::notifyRunning(const QString &id)
|
2012-10-19 16:37:57 +02:00
|
|
|
{
|
2018-08-15 17:28:00 +02:00
|
|
|
if (id.isEmpty() || id == "all")
|
|
|
|
|
forItemsAtLevel<1>([](const Thread &thread) { thread->notifyRunning(); });
|
|
|
|
|
else if (Thread thread = threadForId(id))
|
|
|
|
|
thread->notifyRunning();
|
2012-10-19 16:37:57 +02:00
|
|
|
}
|
|
|
|
|
|
2018-08-15 17:28:00 +02:00
|
|
|
void ThreadsHandler::notifyStopped(const QString &id)
|
2012-10-19 16:37:57 +02:00
|
|
|
{
|
2018-08-15 17:28:00 +02:00
|
|
|
if (id.isEmpty() || id == "all")
|
|
|
|
|
forItemsAtLevel<1>([](const Thread &thread) { thread->notifyStopped(); });
|
|
|
|
|
else if (Thread thread = threadForId(id))
|
|
|
|
|
thread->notifyStopped();
|
2012-10-19 16:37:57 +02:00
|
|
|
}
|
|
|
|
|
|
2018-08-30 11:52:37 +02:00
|
|
|
void ThreadsHandler::setThreads(const GdbMi &data)
|
2010-11-08 17:15:33 +01:00
|
|
|
{
|
2018-08-30 11:52:37 +02:00
|
|
|
rootItem()->removeChildren();
|
|
|
|
|
|
2010-11-08 17:15:33 +01:00
|
|
|
// ^done,threads=[{id="1",target-id="Thread 0xb7fdc710 (LWP 4264)",
|
|
|
|
|
// frame={level="0",addr="0x080530bf",func="testQString",args=[],
|
|
|
|
|
// file="/.../app.cpp",fullname="/../app.cpp",line="1175"},
|
|
|
|
|
// state="stopped",core="0"}],current-thread-id="1"
|
2012-10-24 16:48:09 +02:00
|
|
|
|
2018-08-15 17:28:00 +02:00
|
|
|
const QVector<GdbMi> &items = data["threads"].children();
|
|
|
|
|
for (const GdbMi &item : items) {
|
|
|
|
|
const GdbMi &frame = item["frame"];
|
2010-11-08 17:15:33 +01:00
|
|
|
ThreadData thread;
|
2018-08-15 17:28:00 +02:00
|
|
|
thread.id = item["id"].data();
|
2016-06-07 17:04:53 +02:00
|
|
|
thread.targetId = item["target-id"].data();
|
|
|
|
|
thread.details = item["details"].data();
|
|
|
|
|
thread.core = item["core"].data();
|
|
|
|
|
thread.state = item["state"].data();
|
2013-06-06 13:18:47 +02:00
|
|
|
thread.address = frame["addr"].toAddress();
|
2016-06-07 17:04:53 +02:00
|
|
|
thread.function = frame["func"].data();
|
|
|
|
|
thread.fileName = frame["fullname"].data();
|
2013-05-07 12:09:54 +02:00
|
|
|
thread.lineNumber = frame["line"].toInt();
|
2016-06-07 17:04:53 +02:00
|
|
|
thread.module = frame["from"].data();
|
|
|
|
|
thread.name = item["name"].data();
|
|
|
|
|
thread.stopped = thread.state != "running";
|
2012-10-19 16:37:57 +02:00
|
|
|
updateThread(thread);
|
2010-11-08 17:15:33 +01:00
|
|
|
}
|
2012-10-24 16:48:09 +02:00
|
|
|
|
2018-08-15 17:28:00 +02:00
|
|
|
const QString ¤tId = data["current-thread-id"].data();
|
|
|
|
|
m_currentThread = threadForId(currentId);
|
2018-08-30 11:52:37 +02:00
|
|
|
|
|
|
|
|
if (!m_currentThread && !items.isEmpty())
|
|
|
|
|
m_currentThread = rootItem()->childAt(0);
|
2010-11-08 17:15:33 +01:00
|
|
|
}
|
|
|
|
|
|
2011-10-13 10:17:06 +02:00
|
|
|
QAbstractItemModel *ThreadsHandler::model()
|
|
|
|
|
{
|
2013-11-20 02:19:54 +01:00
|
|
|
return this;
|
2011-10-13 10:17:06 +02:00
|
|
|
}
|
|
|
|
|
|
2010-05-18 12:12:22 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Debugger
|