forked from qt-creator/qt-creator
debugger: code/ui cosmetics
Change-Id: Iafd3388bc04d5ffb6d080a1a2b28b55bb8c98a05 Reviewed-on: http://codereview.qt.nokia.com/2564 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -170,7 +170,7 @@ static inline uint sizeOf(const QModelIndex &m)
|
|||||||
return m.data(LocalsSizeRole).toUInt();
|
return m.data(LocalsSizeRole).toUInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a map of value->name for register markup
|
// Create a map of value->name for register markup.
|
||||||
typedef QMap<quint64, QString> RegisterMap;
|
typedef QMap<quint64, QString> RegisterMap;
|
||||||
typedef RegisterMap::const_iterator RegisterMapConstIt;
|
typedef RegisterMap::const_iterator RegisterMapConstIt;
|
||||||
|
|
||||||
@@ -190,11 +190,10 @@ RegisterMap registerMap(const DebuggerEngine *engine)
|
|||||||
// number and tooltip. Parts of it will be overwritten when recursing
|
// number and tooltip. Parts of it will be overwritten when recursing
|
||||||
// over the children.
|
// over the children.
|
||||||
|
|
||||||
typedef QPair<int, QString> ColorNumberToolTipPair;
|
typedef QPair<int, QString> ColorNumberToolTip;
|
||||||
typedef QVector<ColorNumberToolTipPair> ColorNumberToolTipVector;
|
typedef QVector<ColorNumberToolTip> ColorNumberToolTips;
|
||||||
|
|
||||||
static inline QString variableToolTip(const QString &name,
|
static QString variableToolTip(const QString &name, const QString &type,
|
||||||
const QString &type,
|
|
||||||
quint64 offset)
|
quint64 offset)
|
||||||
{
|
{
|
||||||
return offset ?
|
return offset ?
|
||||||
@@ -210,17 +209,19 @@ static int memberVariableRecursion(const QAbstractItemModel *model,
|
|||||||
const QString &name,
|
const QString &name,
|
||||||
quint64 start, quint64 end,
|
quint64 start, quint64 end,
|
||||||
int *colorNumberIn,
|
int *colorNumberIn,
|
||||||
ColorNumberToolTipVector *cnmv)
|
ColorNumberToolTips *cnmv)
|
||||||
{
|
{
|
||||||
int childCount = 0;
|
int childCount = 0;
|
||||||
// Recurse over top level items if modelIndex is invalid.
|
// Recurse over top level items if modelIndex is invalid.
|
||||||
const bool isRoot = !modelIndex.isValid();
|
const bool isRoot = !modelIndex.isValid();
|
||||||
const int rowCount = isRoot ? model->rowCount() : modelIndex.model()->rowCount(modelIndex);
|
const int rowCount = isRoot
|
||||||
|
? model->rowCount() : modelIndex.model()->rowCount(modelIndex);
|
||||||
if (!rowCount)
|
if (!rowCount)
|
||||||
return childCount;
|
return childCount;
|
||||||
const QString nameRoot = name.isEmpty() ? name : name + QLatin1Char('.');
|
const QString nameRoot = name.isEmpty() ? name : name + QLatin1Char('.');
|
||||||
for (int r = 0; r < rowCount; r++) {
|
for (int r = 0; r < rowCount; r++) {
|
||||||
const QModelIndex childIndex = isRoot ? model->index(r, 0) : modelIndex.child(r, 0);
|
const QModelIndex childIndex = isRoot
|
||||||
|
? model->index(r, 0) : modelIndex.child(r, 0);
|
||||||
const quint64 childAddress = addressOf(childIndex);
|
const quint64 childAddress = addressOf(childIndex);
|
||||||
const uint childSize = sizeOf(childIndex);
|
const uint childSize = sizeOf(childIndex);
|
||||||
if (childAddress && childAddress >= start
|
if (childAddress && childAddress >= start
|
||||||
@@ -229,11 +230,12 @@ static int memberVariableRecursion(const QAbstractItemModel *model,
|
|||||||
const quint64 childOffset = childAddress - start;
|
const quint64 childOffset = childAddress - start;
|
||||||
const QString toolTip
|
const QString toolTip
|
||||||
= variableToolTip(childName, typeOf(childIndex), childOffset);
|
= variableToolTip(childName, typeOf(childIndex), childOffset);
|
||||||
const ColorNumberToolTipPair colorNumberNamePair((*colorNumberIn)++, toolTip);
|
const ColorNumberToolTip colorNumberNamePair((*colorNumberIn)++, toolTip);
|
||||||
const ColorNumberToolTipVector::iterator begin = cnmv->begin() + childOffset;
|
const ColorNumberToolTips::iterator begin = cnmv->begin() + childOffset;
|
||||||
qFill(begin, begin + childSize, colorNumberNamePair);
|
qFill(begin, begin + childSize, colorNumberNamePair);
|
||||||
childCount++;
|
childCount++;
|
||||||
childCount += memberVariableRecursion(model, childIndex, childName, start, end, colorNumberIn, cnmv);
|
childCount += memberVariableRecursion(model, childIndex,
|
||||||
|
childName, start, end, colorNumberIn, cnmv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return childCount;
|
return childCount;
|
||||||
@@ -282,7 +284,7 @@ static int memberVariableRecursion(const QAbstractItemModel *model,
|
|||||||
|
|
||||||
typedef QList<MemoryMarkup> MemoryMarkupList;
|
typedef QList<MemoryMarkup> MemoryMarkupList;
|
||||||
|
|
||||||
static inline MemoryMarkupList
|
static MemoryMarkupList
|
||||||
variableMemoryMarkup(const QAbstractItemModel *model,
|
variableMemoryMarkup(const QAbstractItemModel *model,
|
||||||
const QModelIndex &modelIndex,
|
const QModelIndex &modelIndex,
|
||||||
const QString &rootName,
|
const QString &rootName,
|
||||||
@@ -302,7 +304,7 @@ static inline MemoryMarkupList
|
|||||||
// leaving the padding areas of the parent colored with the base color.
|
// leaving the padding areas of the parent colored with the base color.
|
||||||
MemoryMarkupList result;
|
MemoryMarkupList result;
|
||||||
int colorNumber = 0;
|
int colorNumber = 0;
|
||||||
ColorNumberToolTipVector ranges(size, ColorNumberToolTipPair(colorNumber, rootToolTip));
|
ColorNumberToolTips ranges(size, ColorNumberToolTip(colorNumber, rootToolTip));
|
||||||
const int childCount = memberVariableRecursion(model, modelIndex,
|
const int childCount = memberVariableRecursion(model, modelIndex,
|
||||||
rootName, address, address + size,
|
rootName, address, address + size,
|
||||||
&colorNumber, &ranges);
|
&colorNumber, &ranges);
|
||||||
@@ -314,8 +316,7 @@ static inline MemoryMarkupList
|
|||||||
if (it.key() >= address) {
|
if (it.key() >= address) {
|
||||||
const quint64 offset = it.key() - address;
|
const quint64 offset = it.key() - address;
|
||||||
if (offset < size) {
|
if (offset < size) {
|
||||||
ranges[offset] =
|
ranges[offset] = ColorNumberToolTip(registerColorNumber,
|
||||||
ColorNumberToolTipPair(registerColorNumber,
|
|
||||||
WatchWindow::tr("Register <i>%1</i>").arg(it.value()));
|
WatchWindow::tr("Register <i>%1</i>").arg(it.value()));
|
||||||
} else {
|
} else {
|
||||||
break; // Sorted.
|
break; // Sorted.
|
||||||
@@ -328,7 +329,8 @@ static inline MemoryMarkupList
|
|||||||
QString name;
|
QString name;
|
||||||
for (unsigned i = 0; i < size; ++i)
|
for (unsigned i = 0; i < size; ++i)
|
||||||
if (name != ranges.at(i).second) {
|
if (name != ranges.at(i).second) {
|
||||||
dbg << ",[" << i << ' ' << ranges.at(i).first << ' ' << ranges.at(i).second << ']';
|
dbg << ",[" << i << ' ' << ranges.at(i).first << ' '
|
||||||
|
<< ranges.at(i).second << ']';
|
||||||
name = ranges.at(i).second;
|
name = ranges.at(i).second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -343,7 +345,7 @@ static inline MemoryMarkupList
|
|||||||
int lastColorNumber = 0;
|
int lastColorNumber = 0;
|
||||||
int childNumber = 0;
|
int childNumber = 0;
|
||||||
for (unsigned i = 0; i < size; ++i) {
|
for (unsigned i = 0; i < size; ++i) {
|
||||||
const ColorNumberToolTipPair &range = ranges.at(i);
|
const ColorNumberToolTip &range = ranges.at(i);
|
||||||
if (result.isEmpty() || lastColorNumber != range.first) {
|
if (result.isEmpty() || lastColorNumber != range.first) {
|
||||||
lastColorNumber = range.first;
|
lastColorNumber = range.first;
|
||||||
// Base colors: Parent/register
|
// Base colors: Parent/register
|
||||||
@@ -369,7 +371,8 @@ static inline MemoryMarkupList
|
|||||||
QString name;
|
QString name;
|
||||||
for (unsigned i = 0; i < size; ++i)
|
for (unsigned i = 0; i < size; ++i)
|
||||||
if (name != ranges.at(i).second) {
|
if (name != ranges.at(i).second) {
|
||||||
dbg << ',' << i << ' ' << ranges.at(i).first << ' ' << ranges.at(i).second;
|
dbg << ',' << i << ' ' << ranges.at(i).first << ' '
|
||||||
|
<< ranges.at(i).second;
|
||||||
name = ranges.at(i).second;
|
name = ranges.at(i).second;
|
||||||
}
|
}
|
||||||
dbg << '\n';
|
dbg << '\n';
|
||||||
@@ -381,11 +384,9 @@ static inline MemoryMarkupList
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Convenience to create a memory view of a variable.
|
// Convenience to create a memory view of a variable.
|
||||||
static void addVariableMemoryView(DebuggerEngine *engine,
|
static void addVariableMemoryView(DebuggerEngine *engine, bool separateView,
|
||||||
bool separateView,
|
|
||||||
const QModelIndex &m, bool deferencePointer,
|
const QModelIndex &m, bool deferencePointer,
|
||||||
const QPoint &p,
|
const QPoint &p, QWidget *parent)
|
||||||
QWidget *parent)
|
|
||||||
{
|
{
|
||||||
const QColor background = parent->palette().color(QPalette::Normal, QPalette::Base);
|
const QColor background = parent->palette().color(QPalette::Normal, QPalette::Base);
|
||||||
const quint64 address = deferencePointer ? pointerValueOf(m) : addressOf(m);
|
const quint64 address = deferencePointer ? pointerValueOf(m) : addressOf(m);
|
||||||
@@ -401,24 +402,25 @@ static void addVariableMemoryView(DebuggerEngine *engine,
|
|||||||
address, size,
|
address, size,
|
||||||
registerMap(engine),
|
registerMap(engine),
|
||||||
sizeIsEstimate, background);
|
sizeIsEstimate, background);
|
||||||
const unsigned flags = separateView ? (DebuggerEngine::MemoryView|DebuggerEngine::MemoryReadOnly) : 0;
|
const unsigned flags = separateView
|
||||||
const QString title = deferencePointer ?
|
? DebuggerEngine::MemoryView|DebuggerEngine::MemoryReadOnly : 0;
|
||||||
WatchWindow::tr("Memory Referenced by Pointer '%1' (0x%2)").arg(nameOf(m)).arg(address, 0, 16) :
|
const QString title = deferencePointer
|
||||||
WatchWindow::tr("Memory at Variable '%1' (0x%2)").arg(nameOf(m)).arg(address, 0, 16);
|
? WatchWindow::tr("Memory Referenced by Pointer \"%1\" (0x%2)")
|
||||||
|
.arg(nameOf(m)).arg(address, 0, 16)
|
||||||
|
: WatchWindow::tr("Memory at Variable \"%1\" (0x%2)")
|
||||||
|
.arg(nameOf(m)).arg(address, 0, 16);
|
||||||
engine->openMemoryView(address, flags, markup, p, title, parent);
|
engine->openMemoryView(address, flags, markup, p, title, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a memory view of the stack layout showing local variables
|
// Add a memory view of the stack layout showing local variables
|
||||||
// and registers.
|
// and registers.
|
||||||
static inline void addStackLayoutMemoryView(DebuggerEngine *engine,
|
static void addStackLayoutMemoryView(DebuggerEngine *engine, bool separateView,
|
||||||
bool separateView,
|
const QAbstractItemModel *m, const QPoint &p, QWidget *parent)
|
||||||
const QAbstractItemModel *m, const QPoint &p,
|
|
||||||
QWidget *parent)
|
|
||||||
{
|
{
|
||||||
typedef QPair<quint64, QString> RegisterValueNamePair;
|
typedef QPair<quint64, QString> RegisterValueNamePair;
|
||||||
QTC_ASSERT(engine && m, return ;)
|
QTC_ASSERT(engine && m, return ;)
|
||||||
|
|
||||||
// Determine suitable address range from locals
|
// Determine suitable address range from locals.
|
||||||
quint64 start = Q_UINT64_C(0xFFFFFFFFFFFFFFFF);
|
quint64 start = Q_UINT64_C(0xFFFFFFFFFFFFFFFF);
|
||||||
quint64 end = 0;
|
quint64 end = 0;
|
||||||
const int rootItemCount = m->rowCount();
|
const int rootItemCount = m->rowCount();
|
||||||
@@ -439,7 +441,8 @@ static inline void addStackLayoutMemoryView(DebuggerEngine *engine,
|
|||||||
}
|
}
|
||||||
// Anything found and everything in a sensible range (static data in-between)?
|
// Anything found and everything in a sensible range (static data in-between)?
|
||||||
if (end <= start || end - start > 100 * 1024) {
|
if (end <= start || end - start > 100 * 1024) {
|
||||||
QMessageBox::information(parent, WatchWindow::tr("Cannot Display Stack Layout"),
|
QMessageBox::information(parent,
|
||||||
|
WatchWindow::tr("Cannot Display Stack Layout"),
|
||||||
WatchWindow::tr("Could not determine a suitable address range."));
|
WatchWindow::tr("Could not determine a suitable address range."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -461,7 +464,8 @@ static inline void addStackLayoutMemoryView(DebuggerEngine *engine,
|
|||||||
variableMemoryMarkup(m, QModelIndex(), QString(),
|
variableMemoryMarkup(m, QModelIndex(), QString(),
|
||||||
QString(), start, end - start,
|
QString(), start, end - start,
|
||||||
regMap, true, background);
|
regMap, true, background);
|
||||||
const unsigned flags = separateView ? (DebuggerEngine::MemoryView|DebuggerEngine::MemoryReadOnly) : 0;
|
const unsigned flags = separateView
|
||||||
|
? (DebuggerEngine::MemoryView|DebuggerEngine::MemoryReadOnly) : 0;
|
||||||
const QString title =
|
const QString title =
|
||||||
WatchWindow::tr("Memory Layout of Local Variables at 0x%1").arg(start, 0, 16);
|
WatchWindow::tr("Memory Layout of Local Variables at 0x%1").arg(start, 0, 16);
|
||||||
engine->openMemoryView(start, flags, markup, p, title, parent);
|
engine->openMemoryView(start, flags, markup, p, title, parent);
|
||||||
@@ -573,8 +577,8 @@ void WatchWindow::mouseDoubleClickEvent(QMouseEvent *ev)
|
|||||||
QTreeView::mouseDoubleClickEvent(ev);
|
QTreeView::mouseDoubleClickEvent(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Text for add watch action with truncated expression
|
// Text for add watch action with truncated expression.
|
||||||
static inline QString addWatchActionText(QString exp)
|
static QString addWatchActionText(QString exp)
|
||||||
{
|
{
|
||||||
if (exp.isEmpty())
|
if (exp.isEmpty())
|
||||||
return WatchWindow::tr("Evaluate Expression");
|
return WatchWindow::tr("Evaluate Expression");
|
||||||
@@ -585,8 +589,8 @@ static inline QString addWatchActionText(QString exp)
|
|||||||
return WatchWindow::tr("Evaluate Expression \"%1\"").arg(exp);
|
return WatchWindow::tr("Evaluate Expression \"%1\"").arg(exp);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Text for add watch action with truncated expression
|
// Text for add watch action with truncated expression.
|
||||||
static inline QString removeWatchActionText(QString exp)
|
static QString removeWatchActionText(QString exp)
|
||||||
{
|
{
|
||||||
if (exp.isEmpty())
|
if (exp.isEmpty())
|
||||||
return WatchWindow::tr("Remove Evaluated Expression");
|
return WatchWindow::tr("Remove Evaluated Expression");
|
||||||
@@ -597,7 +601,7 @@ static inline QString removeWatchActionText(QString exp)
|
|||||||
return WatchWindow::tr("Remove Evaluated Expression \"%1\"").arg(exp);
|
return WatchWindow::tr("Remove Evaluated Expression \"%1\"").arg(exp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void copyToClipboard(const QString &clipboardText)
|
static void copyToClipboard(const QString &clipboardText)
|
||||||
{
|
{
|
||||||
QClipboard *clipboard = QApplication::clipboard();
|
QClipboard *clipboard = QApplication::clipboard();
|
||||||
#ifdef Q_WS_X11
|
#ifdef Q_WS_X11
|
||||||
|
|||||||
Reference in New Issue
Block a user