Debugger: Make threads tooltip more verbose

CDB: Add more information and state to Thread.
Refactor thread information in CdbCore classes to prepare for more
information.
This commit is contained in:
Friedemann Kleint
2010-07-02 14:35:41 +02:00
parent dd0978796e
commit ab6f124e57
8 changed files with 197 additions and 86 deletions

View File

@@ -32,6 +32,7 @@
#include "debuggerconstants.h"
#include "debuggerengine.h"
#include <QtCore/QTextStream>
namespace Debugger {
namespace Internal {
@@ -58,6 +59,56 @@ void ThreadData::notifyRunning()
lineNumber = -1;
}
int id;
QString targetId;
QString core;
// State information when stopped
void notifyRunning(); // Clear state information
int frameLevel;
quint64 address;
QString function;
QString fileName;
QString state;
int lineNumber;
static inline QString threadToolTip(const ThreadData &thread)
{
const char tableRowStartC[] = "<tr><td>";
const char tableRowSeparatorC[] = "</td><td>";
const char tableRowEndC[] = "</td>";
QString rc;
QTextStream str(&rc);
str << "<html><head/><body><table>"
<< tableRowStartC << ThreadsHandler::tr("Thread&nbsp;id:")
<< tableRowSeparatorC << thread.id << tableRowEndC;
if (!thread.targetId.isEmpty())
str << tableRowStartC << ThreadsHandler::tr("Target&nbsp;id:")
<< tableRowSeparatorC << thread.targetId << tableRowEndC;
if (!thread.state.isEmpty())
str << tableRowStartC << ThreadsHandler::tr("State:")
<< tableRowSeparatorC << thread.state << tableRowEndC;
if (!thread.core.isEmpty())
str << tableRowStartC << ThreadsHandler::tr("Core:")
<< tableRowSeparatorC << thread.core << tableRowEndC;
if (thread.address) {
str << tableRowStartC << ThreadsHandler::tr("Stopped&nbsp;at:")
<< tableRowSeparatorC;
if (!thread.function.isEmpty())
str << thread.function << "<br>";
if (!thread.fileName.isEmpty())
str << thread.fileName << ':' << thread.lineNumber << "<br>";
str.setIntegerBase(16);
str << "0x" << thread.address;
str.setIntegerBase(10);
}
str << "</table></body></html>";
return rc;
}
////////////////////////////////////////////////////////////////////////
//
// ThreadsHandler
@@ -92,7 +143,8 @@ QVariant ThreadsHandler::data(const QModelIndex &index, int role) const
return QVariant();
const ThreadData &thread = m_threads.at(row);
if (role == Qt::DisplayRole) {
switch (role) {
case Qt::DisplayRole:
switch (index.column()) {
case ThreadData::IdColumn:
return thread.id;
@@ -112,21 +164,15 @@ QVariant ThreadsHandler::data(const QModelIndex &index, int role) const
case ThreadData::StateColumn:
return thread.state;
}
} else if (role == Qt::ToolTipRole) {
if (thread.address == 0)
return tr("Thread: %1").arg(thread.id);
// Stopped
if (thread.fileName.isEmpty())
return tr("Thread: %1 at %2 (0x%3)").arg(thread.id)
.arg(thread.function).arg(thread.address, 0, 16);
return tr("Thread: %1 at %2, %3:%4 (0x%5)").
arg(thread.id).arg(thread.function, thread.fileName)
.arg(thread.lineNumber).arg(thread.address, 0, 16);
} else if (role == Qt::DecorationRole && index.column() == 0) {
// Return icon that indicates whether this is the active stack frame
return (index.row() == m_currentIndex) ? m_positionIcon : m_emptyIcon;
case Qt::ToolTipRole:
return threadToolTip(thread);
case Qt::DecorationRole: // Return icon that indicates whether this is the active stack frame
if (index.column() == 0)
return (index.row() == m_currentIndex) ? m_positionIcon : m_emptyIcon;
break;
default:
break;
}
return QVariant();
}