2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-05-18 12:12:22 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
|
** Contact: http://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
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2010-05-18 12:12:22 +02:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2010-05-18 12:12:22 +02:00
|
|
|
|
|
|
|
|
#include "threadshandler.h"
|
|
|
|
|
|
2011-09-01 16:36:27 +02:00
|
|
|
#include "debuggercore.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>
|
2012-10-19 16:37:57 +02:00
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
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>
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
static const QIcon &positionIcon()
|
2012-10-19 16:37:57 +02:00
|
|
|
{
|
2015-06-12 11:55:57 +02:00
|
|
|
static QIcon icon(QLatin1String(":/debugger/images/location_16.png"));
|
|
|
|
|
return icon;
|
2012-10-19 16:37:57 +02:00
|
|
|
}
|
|
|
|
|
|
2015-06-12 11:55:57 +02:00
|
|
|
static const QIcon &emptyIcon()
|
2013-11-20 02:19:54 +01:00
|
|
|
{
|
2015-06-12 11:55:57 +02:00
|
|
|
static QIcon icon(QLatin1String(":/debugger/images/debugger_empty_14.png"));
|
|
|
|
|
return icon;
|
2013-11-20 02:19:54 +01:00
|
|
|
}
|
|
|
|
|
|
2015-06-12 11:55:57 +02:00
|
|
|
class ThreadItem : public TreeItem, public ThreadData
|
2010-07-02 14:35:41 +02:00
|
|
|
{
|
2015-06-12 11:55:57 +02:00
|
|
|
Q_DECLARE_TR_FUNCTIONS(Debugger::Internal::ThreadsHandler)
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
ThreadItem(const ThreadsHandler *handler, const ThreadData &data = ThreadData())
|
|
|
|
|
: ThreadData(data), handler(handler)
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
QVariant data(int column, int role) const
|
|
|
|
|
{
|
|
|
|
|
switch (role) {
|
|
|
|
|
case Qt::DisplayRole:
|
|
|
|
|
return threadPart(column);
|
|
|
|
|
case Qt::ToolTipRole:
|
|
|
|
|
return threadToolTip();
|
|
|
|
|
case Qt::DecorationRole:
|
|
|
|
|
// Return icon that indicates whether this is the active stack frame.
|
|
|
|
|
if (column == 0)
|
|
|
|
|
return id == handler->currentThread() ? positionIcon() : emptyIcon();
|
|
|
|
|
break;
|
|
|
|
|
case ThreadData::IdRole:
|
|
|
|
|
return id.raw();
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return QVariant();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Qt::ItemFlags flags(int column) const
|
|
|
|
|
{
|
|
|
|
|
return stopped ? TreeItem::flags(column) : Qt::ItemFlags(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString 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 << id.raw() << end;
|
|
|
|
|
if (!targetId.isEmpty())
|
|
|
|
|
str << start << ThreadsHandler::tr("Target id:")
|
|
|
|
|
<< sep << targetId << end;
|
|
|
|
|
if (!groupId.isEmpty())
|
|
|
|
|
str << start << ThreadsHandler::tr("Group id:")
|
|
|
|
|
<< sep << groupId << end;
|
|
|
|
|
if (!name.isEmpty())
|
|
|
|
|
str << start << ThreadsHandler::tr("Name:")
|
|
|
|
|
<< sep << name << end;
|
|
|
|
|
if (!state.isEmpty())
|
|
|
|
|
str << start << ThreadsHandler::tr("State:")
|
|
|
|
|
<< sep << state << end;
|
|
|
|
|
if (!core.isEmpty())
|
|
|
|
|
str << start << ThreadsHandler::tr("Core:")
|
|
|
|
|
<< sep << core << end;
|
|
|
|
|
if (address) {
|
|
|
|
|
str << start << ThreadsHandler::tr("Stopped at:") << sep;
|
|
|
|
|
if (!function.isEmpty())
|
|
|
|
|
str << function << "<br>";
|
|
|
|
|
if (!fileName.isEmpty())
|
|
|
|
|
str << fileName << ':' << lineNumber << "<br>";
|
|
|
|
|
str << formatToolTipAddress(address);
|
|
|
|
|
}
|
|
|
|
|
str << "</table></body></html>";
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariant threadPart(int column) const
|
|
|
|
|
{
|
|
|
|
|
switch (column) {
|
|
|
|
|
case ThreadData::IdColumn:
|
|
|
|
|
return id.raw();
|
|
|
|
|
case ThreadData::FunctionColumn:
|
|
|
|
|
return function;
|
|
|
|
|
case ThreadData::FileColumn:
|
|
|
|
|
return fileName.isEmpty() ? module : fileName;
|
|
|
|
|
case ThreadData::LineColumn:
|
|
|
|
|
return lineNumber >= 0
|
|
|
|
|
? QString::number(lineNumber) : QString();
|
|
|
|
|
case ThreadData::AddressColumn:
|
|
|
|
|
return address > 0
|
|
|
|
|
? QLatin1String("0x") + QString::number(address, 16)
|
|
|
|
|
: QString();
|
|
|
|
|
case ThreadData::CoreColumn:
|
|
|
|
|
return core;
|
|
|
|
|
case ThreadData::StateColumn:
|
|
|
|
|
return state;
|
|
|
|
|
case ThreadData::TargetIdColumn:
|
|
|
|
|
if (targetId.startsWith(QLatin1String("Thread ")))
|
|
|
|
|
return targetId.mid(7);
|
|
|
|
|
return targetId;
|
|
|
|
|
case ThreadData::NameColumn:
|
|
|
|
|
return name;
|
|
|
|
|
case ThreadData::DetailsColumn:
|
|
|
|
|
return details;
|
|
|
|
|
case ThreadData::ComboNameColumn:
|
|
|
|
|
return QString::fromLatin1("#%1 %2").arg(id.raw()).arg(name);
|
|
|
|
|
}
|
|
|
|
|
return QVariant();
|
2010-07-02 14:35:41 +02:00
|
|
|
}
|
2015-06-12 11:55:57 +02:00
|
|
|
|
|
|
|
|
void notifyRunning() // Clear state information.
|
|
|
|
|
{
|
|
|
|
|
address = 0;
|
|
|
|
|
function.clear();
|
|
|
|
|
fileName.clear();
|
|
|
|
|
frameLevel = -1;
|
|
|
|
|
state.clear();
|
|
|
|
|
lineNumber = -1;
|
|
|
|
|
stopped = false;
|
|
|
|
|
update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void notifyStopped()
|
|
|
|
|
{
|
|
|
|
|
stopped = true;
|
|
|
|
|
update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void mergeThreadData(const ThreadData &other)
|
|
|
|
|
{
|
|
|
|
|
if (!other.core.isEmpty())
|
|
|
|
|
core = other.core;
|
|
|
|
|
if (!other.fileName.isEmpty())
|
|
|
|
|
fileName = other.fileName;
|
|
|
|
|
if (!other.targetId.isEmpty())
|
|
|
|
|
targetId = other.targetId;
|
|
|
|
|
if (!other.name.isEmpty())
|
|
|
|
|
name = other.name;
|
|
|
|
|
if (other.frameLevel != -1)
|
|
|
|
|
frameLevel = other.frameLevel;
|
|
|
|
|
if (!other.function.isEmpty())
|
|
|
|
|
function = other.function;
|
|
|
|
|
if (other.address)
|
|
|
|
|
address = other.address;
|
|
|
|
|
if (!other.module.isEmpty())
|
|
|
|
|
module = other.module;
|
|
|
|
|
if (!other.details.isEmpty())
|
|
|
|
|
details = other.details;
|
|
|
|
|
if (!other.state.isEmpty())
|
|
|
|
|
state = other.state;
|
|
|
|
|
if (other.lineNumber != -1)
|
|
|
|
|
lineNumber = other.lineNumber;
|
|
|
|
|
update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
const ThreadsHandler * const handler;
|
|
|
|
|
};
|
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
|
|
|
*/
|
|
|
|
|
|
2010-11-05 17:02:27 +01:00
|
|
|
ThreadsHandler::ThreadsHandler()
|
2010-05-18 12:12:22 +02:00
|
|
|
{
|
2011-04-18 16:40:59 +02:00
|
|
|
m_resetLocationScheduled = false;
|
2013-08-19 13:30:10 +02:00
|
|
|
setObjectName(QLatin1String("ThreadsModel"));
|
2015-06-12 11:55:57 +02:00
|
|
|
setRootItem(new ThreadItem(this));
|
|
|
|
|
setHeader({
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2015-06-12 11:55:57 +02:00
|
|
|
static ThreadItem *itemForThreadId(const ThreadsHandler *handler, ThreadId threadId)
|
2013-11-14 13:24:02 +01:00
|
|
|
{
|
2015-06-12 11:55:57 +02:00
|
|
|
const auto matcher = [threadId](ThreadItem *item) { return item->id == threadId; };
|
|
|
|
|
return handler->findItemAtLevel<ThreadItem *>(1, matcher);
|
2013-11-14 13:24:02 +01:00
|
|
|
}
|
|
|
|
|
|
2015-06-12 11:55:57 +02:00
|
|
|
static int indexForThreadId(const ThreadsHandler *handler, ThreadId threadId)
|
2010-05-18 12:12:22 +02:00
|
|
|
{
|
2015-06-12 11:55:57 +02:00
|
|
|
ThreadItem *item = itemForThreadId(handler, threadId);
|
|
|
|
|
return item ? handler->rootItem()->children().indexOf(item) : -1;
|
2010-05-18 12:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
2015-06-12 11:55:57 +02:00
|
|
|
int ThreadsHandler::currentThreadIndex() const
|
2011-04-18 16:40:59 +02:00
|
|
|
{
|
2015-06-12 11:55:57 +02:00
|
|
|
return indexForThreadId(this, m_currentId);
|
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
|
|
|
{
|
2015-06-12 11:55:57 +02:00
|
|
|
rootItem()->sortChildren([order, column](const TreeItem *item1, const TreeItem *item2) -> bool {
|
|
|
|
|
const QVariant v1 = static_cast<const ThreadItem *>(item1)->threadPart(column);
|
|
|
|
|
const QVariant v2 = static_cast<const ThreadItem *>(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
|
|
|
}
|
|
|
|
|
|
2012-10-19 16:37:57 +02:00
|
|
|
ThreadId ThreadsHandler::currentThread() const
|
2010-05-18 12:12:22 +02:00
|
|
|
{
|
2013-11-14 13:24:02 +01:00
|
|
|
return m_currentId;
|
2010-05-18 12:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
2012-10-19 16:37:57 +02:00
|
|
|
ThreadId ThreadsHandler::threadAt(int index) const
|
2010-05-18 12:12:22 +02:00
|
|
|
{
|
2015-06-12 11:55:57 +02:00
|
|
|
QTC_ASSERT(index >= 0 && index < rootItem()->childCount(), return ThreadId());
|
|
|
|
|
return static_cast<ThreadItem *>(rootItem()->childAt(index))->id;
|
2012-10-19 16:37:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ThreadsHandler::setCurrentThread(ThreadId id)
|
|
|
|
|
{
|
2013-11-14 13:24:02 +01:00
|
|
|
if (id == m_currentId)
|
2010-05-18 12:12:22 +02:00
|
|
|
return;
|
|
|
|
|
|
2015-06-12 11:55:57 +02:00
|
|
|
ThreadItem *newItem = itemForThreadId(this, id);
|
|
|
|
|
if (!newItem) {
|
2012-10-19 16:37:57 +02:00
|
|
|
qWarning("ThreadsHandler::setCurrentThreadId: No such thread %d.", int(id.raw()));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-12 11:55:57 +02:00
|
|
|
ThreadItem *oldItem = itemForThreadId(this, m_currentId);
|
2013-11-14 13:24:02 +01:00
|
|
|
m_currentId = id;
|
2015-06-12 11:55:57 +02:00
|
|
|
if (oldItem)
|
|
|
|
|
oldItem->update();
|
2010-05-18 12:12:22 +02:00
|
|
|
|
2015-06-12 11:55:57 +02:00
|
|
|
newItem->update();
|
2011-09-01 16:36:27 +02:00
|
|
|
|
|
|
|
|
updateThreadBox();
|
2010-05-18 12:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
2015-06-12 11:55:57 +02:00
|
|
|
void ThreadsHandler::updateThread(const ThreadData &threadData)
|
2010-07-02 10:58:47 +02:00
|
|
|
{
|
2015-06-12 11:55:57 +02:00
|
|
|
if (ThreadItem *item = itemForThreadId(this, threadData.id))
|
|
|
|
|
item->mergeThreadData(threadData);
|
|
|
|
|
else
|
|
|
|
|
rootItem()->appendChild(new ThreadItem(this, threadData));
|
2012-10-19 16:37:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ThreadsHandler::removeThread(ThreadId threadId)
|
|
|
|
|
{
|
2015-06-12 11:55:57 +02:00
|
|
|
if (ThreadItem *item = itemForThreadId(this, threadId))
|
|
|
|
|
delete takeItem(item);
|
2012-10-19 16:37:57 +02:00
|
|
|
}
|
|
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
void ThreadsHandler::setThreads(const Threads &threads)
|
2010-05-18 12:12:22 +02:00
|
|
|
{
|
2015-06-12 11:55:57 +02:00
|
|
|
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);
|
2011-04-18 16:40:59 +02:00
|
|
|
m_resetLocationScheduled = false;
|
2011-09-01 16:36:27 +02:00
|
|
|
updateThreadBox();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ThreadsHandler::updateThreadBox()
|
|
|
|
|
{
|
|
|
|
|
QStringList list;
|
2015-06-12 11:55:57 +02:00
|
|
|
auto items = itemsAtLevel<ThreadItem *>(1);
|
|
|
|
|
foreach (ThreadItem *item, items)
|
|
|
|
|
list.append(QString::fromLatin1("#%1 %2").arg(item->id.raw()).arg(item->name));
|
|
|
|
|
Internal::setThreadBoxContents(list, indexForThreadId(this, m_currentId));
|
2010-05-18 12:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
2012-10-19 16:37:57 +02:00
|
|
|
ThreadData ThreadsHandler::thread(ThreadId id) const
|
|
|
|
|
{
|
2015-06-12 11:55:57 +02:00
|
|
|
if (ThreadItem *item = itemForThreadId(this, id))
|
|
|
|
|
return *item;
|
|
|
|
|
return ThreadData();
|
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();
|
2010-05-18 12:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
2012-10-19 16:37:57 +02:00
|
|
|
void ThreadsHandler::notifyRunning(const QByteArray &data)
|
2010-05-18 12:12:22 +02:00
|
|
|
{
|
2012-10-19 16:37:57 +02:00
|
|
|
if (data.isEmpty() || data == "all") {
|
|
|
|
|
notifyAllRunning();
|
|
|
|
|
} else {
|
|
|
|
|
bool ok;
|
|
|
|
|
qlonglong id = data.toLongLong(&ok);
|
|
|
|
|
if (ok)
|
|
|
|
|
notifyRunning(ThreadId(id));
|
|
|
|
|
else // FIXME
|
|
|
|
|
notifyAllRunning();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ThreadsHandler::notifyAllRunning()
|
|
|
|
|
{
|
2015-06-12 11:55:57 +02:00
|
|
|
auto items = itemsAtLevel<ThreadItem *>(1);
|
|
|
|
|
foreach (ThreadItem *item, items)
|
|
|
|
|
item->notifyRunning();
|
2012-10-19 16:37:57 +02:00
|
|
|
}
|
|
|
|
|
|
2015-06-12 11:55:57 +02:00
|
|
|
void ThreadsHandler::notifyRunning(ThreadId threadId)
|
2012-10-19 16:37:57 +02:00
|
|
|
{
|
2015-06-12 11:55:57 +02:00
|
|
|
if (ThreadItem *item = itemForThreadId(this, threadId))
|
|
|
|
|
item->notifyRunning();
|
2010-05-18 12:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
2012-10-19 16:37:57 +02:00
|
|
|
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()
|
|
|
|
|
{
|
2015-06-12 11:55:57 +02:00
|
|
|
auto items = itemsAtLevel<ThreadItem *>(1);
|
|
|
|
|
foreach (ThreadItem *item, items)
|
|
|
|
|
item->notifyStopped();
|
2012-10-19 16:37:57 +02:00
|
|
|
}
|
|
|
|
|
|
2015-06-12 11:55:57 +02:00
|
|
|
void ThreadsHandler::notifyStopped(ThreadId threadId)
|
2012-10-19 16:37:57 +02:00
|
|
|
{
|
2015-06-12 11:55:57 +02:00
|
|
|
if (ThreadItem *item = itemForThreadId(this, threadId))
|
|
|
|
|
item->notifyStopped();
|
2012-10-19 16:37:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ThreadsHandler::updateThreads(const GdbMi &data)
|
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
|
|
|
|
2015-02-18 12:50:12 +01:00
|
|
|
const std::vector<GdbMi> items = data["threads"].children();
|
2015-02-19 16:44:58 +01:00
|
|
|
const int n = int(items.size());
|
2010-11-08 17:15:33 +01:00
|
|
|
for (int index = 0; index != n; ++index) {
|
2015-02-17 17:44:54 +01:00
|
|
|
const GdbMi item = items[index];
|
2013-05-03 18:26:10 +02:00
|
|
|
const GdbMi frame = item["frame"];
|
2010-11-08 17:15:33 +01:00
|
|
|
ThreadData thread;
|
2013-05-07 12:09:54 +02:00
|
|
|
thread.id = ThreadId(item["id"].toInt());
|
2013-06-06 13:18:47 +02:00
|
|
|
thread.targetId = item["target-id"].toLatin1();
|
|
|
|
|
thread.details = item["details"].toLatin1();
|
|
|
|
|
thread.core = item["core"].toLatin1();
|
|
|
|
|
thread.state = item["state"].toLatin1();
|
|
|
|
|
thread.address = frame["addr"].toAddress();
|
|
|
|
|
thread.function = frame["func"].toLatin1();
|
|
|
|
|
thread.fileName = frame["fullname"].toLatin1();
|
2013-05-07 12:09:54 +02:00
|
|
|
thread.lineNumber = frame["line"].toInt();
|
2013-05-03 18:26:10 +02:00
|
|
|
thread.module = QString::fromLocal8Bit(frame["from"].data());
|
2013-06-06 13:18:47 +02:00
|
|
|
thread.name = item["name"].toLatin1();
|
2013-11-14 13:24:02 +01:00
|
|
|
thread.stopped = thread.state != QLatin1String("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
|
|
|
|
2013-11-14 13:24:02 +01:00
|
|
|
const GdbMi current = data["current-thread-id"];
|
2015-06-12 11:55:57 +02:00
|
|
|
m_currentId = current.isValid() ? ThreadId(current.data().toLongLong()) : ThreadId();
|
2012-10-24 16:48:09 +02:00
|
|
|
|
2012-10-19 16:37:57 +02:00
|
|
|
updateThreadBox();
|
2010-11-08 17:15:33 +01:00
|
|
|
}
|
|
|
|
|
|
2011-04-18 16:40:59 +02:00
|
|
|
void ThreadsHandler::scheduleResetLocation()
|
|
|
|
|
{
|
|
|
|
|
m_resetLocationScheduled = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ThreadsHandler::resetLocation()
|
|
|
|
|
{
|
|
|
|
|
if (m_resetLocationScheduled) {
|
|
|
|
|
m_resetLocationScheduled = false;
|
2012-10-19 16:37:57 +02:00
|
|
|
layoutChanged();
|
2011-04-18 16:40:59 +02: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
|