forked from qt-creator/qt-creator
debugger: slightly saner behaviour for the threads combobox
Change-Id: I20400b037f00a5dbaf11cbbfb184a5bf526883cc Reviewed-on: http://codereview.qt.nokia.com/4095 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -114,7 +114,7 @@ public:
|
|||||||
int ignoreCount(BreakpointModelId id) const;
|
int ignoreCount(BreakpointModelId id) const;
|
||||||
void setIgnoreCount(BreakpointModelId, const int &count);
|
void setIgnoreCount(BreakpointModelId, const int &count);
|
||||||
int threadSpec(BreakpointModelId id) const;
|
int threadSpec(BreakpointModelId id) const;
|
||||||
void setThreadSpec(BreakpointModelId, const int&spec);
|
void setThreadSpec(BreakpointModelId, const int &spec);
|
||||||
QString fileName(BreakpointModelId id) const;
|
QString fileName(BreakpointModelId id) const;
|
||||||
void setFileName(BreakpointModelId, const QString &fileName);
|
void setFileName(BreakpointModelId, const QString &fileName);
|
||||||
QString functionName(BreakpointModelId id) const;
|
QString functionName(BreakpointModelId id) const;
|
||||||
|
|||||||
@@ -105,7 +105,8 @@ public:
|
|||||||
virtual bool initialize(const QStringList &arguments, QString *errorMessage) = 0;
|
virtual bool initialize(const QStringList &arguments, QString *errorMessage) = 0;
|
||||||
virtual QWidget *mainWindow() const = 0;
|
virtual QWidget *mainWindow() const = 0;
|
||||||
virtual bool isDockVisible(const QString &objectName) const = 0;
|
virtual bool isDockVisible(const QString &objectName) const = 0;
|
||||||
virtual QString debuggerForAbi(const ProjectExplorer::Abi &abi, DebuggerEngineType et = NoEngineType) const = 0;
|
virtual QString debuggerForAbi(const ProjectExplorer::Abi &abi,
|
||||||
|
DebuggerEngineType et = NoEngineType) const = 0;
|
||||||
virtual void showModuleSymbols(const QString &moduleName,
|
virtual void showModuleSymbols(const QString &moduleName,
|
||||||
const QVector<Symbol> &symbols) = 0;
|
const QVector<Symbol> &symbols) = 0;
|
||||||
virtual void openMemoryEditor() = 0;
|
virtual void openMemoryEditor() = 0;
|
||||||
@@ -115,6 +116,7 @@ public:
|
|||||||
virtual Utils::SavedAction *action(int code) const = 0;
|
virtual Utils::SavedAction *action(int code) const = 0;
|
||||||
virtual bool boolSetting(int code) const = 0;
|
virtual bool boolSetting(int code) const = 0;
|
||||||
virtual QString stringSetting(int code) const = 0;
|
virtual QString stringSetting(int code) const = 0;
|
||||||
|
virtual void setThreads(const QStringList &list, int index) = 0;
|
||||||
|
|
||||||
virtual DebuggerToolTipManager *toolTipManager() const = 0;
|
virtual DebuggerToolTipManager *toolTipManager() const = 0;
|
||||||
virtual QSharedPointer<GlobalDebuggerOptions> globalDebuggerOptions() const = 0;
|
virtual QSharedPointer<GlobalDebuggerOptions> globalDebuggerOptions() const = 0;
|
||||||
|
|||||||
@@ -580,6 +580,16 @@ public:
|
|||||||
DebuggerEngine *currentEngine() const { return m_currentEngine; }
|
DebuggerEngine *currentEngine() const { return m_currentEngine; }
|
||||||
DebuggerEngine *dummyEngine();
|
DebuggerEngine *dummyEngine();
|
||||||
|
|
||||||
|
void setThreads(const QStringList &list, int index)
|
||||||
|
{
|
||||||
|
const bool state = m_threadBox->blockSignals(true);
|
||||||
|
m_threadBox->clear();
|
||||||
|
foreach (const QString &item, list)
|
||||||
|
m_threadBox->addItem(item);
|
||||||
|
m_threadBox->setCurrentIndex(index);
|
||||||
|
m_threadBox->blockSignals(state);
|
||||||
|
}
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void writeSettings()
|
void writeSettings()
|
||||||
{
|
{
|
||||||
@@ -1869,8 +1879,8 @@ void DebuggerPluginPrivate::connectEngine(DebuggerEngine *engine)
|
|||||||
m_sourceFilesWindow->setModel(engine->sourceFilesModel());
|
m_sourceFilesWindow->setModel(engine->sourceFilesModel());
|
||||||
m_stackWindow->setModel(engine->stackModel());
|
m_stackWindow->setModel(engine->stackModel());
|
||||||
m_threadsWindow->setModel(engine->threadsModel());
|
m_threadsWindow->setModel(engine->threadsModel());
|
||||||
m_threadBox->setModel(engine->threadsModel());
|
//m_threadBox->setModel(engine->threadsModel());
|
||||||
m_threadBox->setModelColumn(ThreadData::NameColumn);
|
//m_threadBox->setModelColumn(ThreadData::ComboNameColumn);
|
||||||
m_watchersWindow->setModel(engine->watchersModel());
|
m_watchersWindow->setModel(engine->watchersModel());
|
||||||
engine->watchHandler()->rebuildModel();
|
engine->watchHandler()->rebuildModel();
|
||||||
}
|
}
|
||||||
@@ -3120,6 +3130,7 @@ void DebuggerPluginPrivate::extensionsInitialized()
|
|||||||
hbox->addWidget(new QLabel(tr("Threads:")));
|
hbox->addWidget(new QLabel(tr("Threads:")));
|
||||||
|
|
||||||
m_threadBox = new QComboBox;
|
m_threadBox = new QComboBox;
|
||||||
|
m_threadBox->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
||||||
connect(m_threadBox, SIGNAL(activated(int)), SLOT(selectThread(int)));
|
connect(m_threadBox, SIGNAL(activated(int)), SLOT(selectThread(int)));
|
||||||
|
|
||||||
hbox->addWidget(m_threadBox);
|
hbox->addWidget(m_threadBox);
|
||||||
|
|||||||
@@ -60,7 +60,9 @@ struct ThreadData
|
|||||||
LineColumn,
|
LineColumn,
|
||||||
StateColumn,
|
StateColumn,
|
||||||
NameColumn,
|
NameColumn,
|
||||||
|
TargetIdColumn,
|
||||||
CoreColumn,
|
CoreColumn,
|
||||||
|
ComboNameColumn,
|
||||||
ColumnCount = CoreColumn
|
ColumnCount = CoreColumn
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
#include "gdb/gdbmi.h"
|
#include "gdb/gdbmi.h"
|
||||||
|
|
||||||
#include "debuggerconstants.h"
|
#include "debuggerconstants.h"
|
||||||
|
#include "debuggercore.h"
|
||||||
|
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
#include <QtCore/QTextStream>
|
#include <QtCore/QTextStream>
|
||||||
@@ -124,7 +125,7 @@ QVariant ThreadsHandler::data(const QModelIndex &index, int role) const
|
|||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
const int row = index.row();
|
const int row = index.row();
|
||||||
if (row >= m_threads.size())
|
if (row >= m_threads.size())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
const ThreadData &thread = m_threads.at(row);
|
const ThreadData &thread = m_threads.at(row);
|
||||||
|
|
||||||
@@ -148,14 +149,14 @@ QVariant ThreadsHandler::data(const QModelIndex &index, int role) const
|
|||||||
return thread.core;
|
return thread.core;
|
||||||
case ThreadData::StateColumn:
|
case ThreadData::StateColumn:
|
||||||
return thread.state;
|
return thread.state;
|
||||||
case ThreadData::NameColumn: {
|
case ThreadData::TargetIdColumn:
|
||||||
QString s;
|
if (thread.targetId.startsWith(QLatin1String("Thread ")))
|
||||||
if (!thread.name.isEmpty())
|
return thread.targetId.mid(7);
|
||||||
s += ' ' + thread.name;
|
return thread.targetId;
|
||||||
if (!thread.targetId.isEmpty())
|
case ThreadData::NameColumn:
|
||||||
s += ' ' + thread.targetId;
|
return thread.name;
|
||||||
return s;
|
case ThreadData::ComboNameColumn:
|
||||||
}
|
return QString("#%1 %2").arg(thread.id).arg(thread.name);
|
||||||
}
|
}
|
||||||
case Qt::ToolTipRole:
|
case Qt::ToolTipRole:
|
||||||
return threadToolTip(thread);
|
return threadToolTip(thread);
|
||||||
@@ -177,7 +178,7 @@ QVariant ThreadsHandler::headerData
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
switch (section) {
|
switch (section) {
|
||||||
case ThreadData::IdColumn:
|
case ThreadData::IdColumn:
|
||||||
return tr("Thread ID");
|
return QString(QLatin1String(" ") + tr("Id"));
|
||||||
case ThreadData::FunctionColumn:
|
case ThreadData::FunctionColumn:
|
||||||
return tr("Function");
|
return tr("Function");
|
||||||
case ThreadData::FileColumn:
|
case ThreadData::FileColumn:
|
||||||
@@ -190,6 +191,8 @@ QVariant ThreadsHandler::headerData
|
|||||||
return tr("Core");
|
return tr("Core");
|
||||||
case ThreadData::StateColumn:
|
case ThreadData::StateColumn:
|
||||||
return tr("State");
|
return tr("State");
|
||||||
|
case ThreadData::TargetIdColumn:
|
||||||
|
return tr("Target Id");
|
||||||
case ThreadData::NameColumn:
|
case ThreadData::NameColumn:
|
||||||
return tr("Name");
|
return tr("Name");
|
||||||
}
|
}
|
||||||
@@ -219,19 +222,20 @@ void ThreadsHandler::setCurrentThread(int index)
|
|||||||
|
|
||||||
m_currentIndex = index;
|
m_currentIndex = index;
|
||||||
|
|
||||||
// Emit changed for new frame
|
// Emit changed for new frame.
|
||||||
i = ThreadsHandler::index(m_currentIndex, 0);
|
i = ThreadsHandler::index(m_currentIndex, 0);
|
||||||
emit dataChanged(i, i);
|
emit dataChanged(i, i);
|
||||||
|
|
||||||
|
updateThreadBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadsHandler::setCurrentThreadId(int id)
|
void ThreadsHandler::setCurrentThreadId(int id)
|
||||||
{
|
{
|
||||||
const int index = indexOf(id);
|
const int index = indexOf(id);
|
||||||
if (index != -1) {
|
if (index != -1)
|
||||||
setCurrentThread(index);
|
setCurrentThread(index);
|
||||||
} else {
|
else
|
||||||
qWarning("ThreadsHandler::setCurrentThreadId: No such thread %d.", id);
|
qWarning("ThreadsHandler::setCurrentThreadId: No such thread %d.", id);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ThreadsHandler::indexOf(quint64 threadId) const
|
int ThreadsHandler::indexOf(quint64 threadId) const
|
||||||
@@ -251,6 +255,15 @@ void ThreadsHandler::setThreads(const Threads &threads)
|
|||||||
m_resetLocationScheduled = false;
|
m_resetLocationScheduled = false;
|
||||||
m_contentsValid = true;
|
m_contentsValid = true;
|
||||||
reset();
|
reset();
|
||||||
|
updateThreadBox();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ThreadsHandler::updateThreadBox()
|
||||||
|
{
|
||||||
|
QStringList list;
|
||||||
|
foreach (const ThreadData &thread, m_threads)
|
||||||
|
list.append(QString("#%1 %2").arg(thread.id).arg(thread.name));
|
||||||
|
debuggerCore()->setThreads(list, m_currentIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
Threads ThreadsHandler::threads() const
|
Threads ThreadsHandler::threads() const
|
||||||
|
|||||||
@@ -38,15 +38,17 @@
|
|||||||
|
|
||||||
#include "threaddata.h"
|
#include "threaddata.h"
|
||||||
|
|
||||||
namespace Debugger {
|
|
||||||
namespace Internal {
|
|
||||||
class GdbMi;
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// ThreadsHandler
|
// ThreadsHandler
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
namespace Debugger {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
class GdbMi;
|
||||||
|
|
||||||
class ThreadsHandler : public QAbstractTableModel
|
class ThreadsHandler : public QAbstractTableModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -80,6 +82,7 @@ private:
|
|||||||
QVariant headerData(int section, Qt::Orientation orientation,
|
QVariant headerData(int section, Qt::Orientation orientation,
|
||||||
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();
|
||||||
|
|
||||||
Threads m_threads;
|
Threads m_threads;
|
||||||
int m_currentIndex;
|
int m_currentIndex;
|
||||||
|
|||||||
@@ -79,9 +79,11 @@ void ThreadsWindow::rowActivated(const QModelIndex &index)
|
|||||||
void ThreadsWindow::setModel(QAbstractItemModel *model)
|
void ThreadsWindow::setModel(QAbstractItemModel *model)
|
||||||
{
|
{
|
||||||
QTreeView::setModel(model);
|
QTreeView::setModel(model);
|
||||||
resizeColumnToContents(0); // Id
|
resizeColumnToContents(ThreadData::IdColumn);
|
||||||
resizeColumnToContents(4); // Line
|
resizeColumnToContents(ThreadData::LineColumn);
|
||||||
resizeColumnToContents(6); // Name
|
resizeColumnToContents(ThreadData::NameColumn);
|
||||||
|
resizeColumnToContents(ThreadData::StateColumn);
|
||||||
|
resizeColumnToContents(ThreadData::TargetIdColumn);
|
||||||
if (header()) {
|
if (header()) {
|
||||||
bool adjust = debuggerCore()->boolSetting(AlwaysAdjustThreadsColumnWidths);
|
bool adjust = debuggerCore()->boolSetting(AlwaysAdjustThreadsColumnWidths);
|
||||||
setAlwaysResizeColumnsToContents(adjust);
|
setAlwaysResizeColumnsToContents(adjust);
|
||||||
@@ -109,7 +111,7 @@ void ThreadsWindow::contextMenuEvent(QContextMenuEvent *ev)
|
|||||||
void ThreadsWindow::resizeColumnsToContents()
|
void ThreadsWindow::resizeColumnsToContents()
|
||||||
{
|
{
|
||||||
const int columnCount = model()->columnCount();
|
const int columnCount = model()->columnCount();
|
||||||
for (int c = 0 ; c < columnCount; c++)
|
for (int c = 0 ; c != columnCount; ++c)
|
||||||
resizeColumnToContents(c);
|
resizeColumnToContents(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user