diff --git a/src/plugins/debugger/stackframe.cpp b/src/plugins/debugger/stackframe.cpp index 687aa7a443f..2a9441bde0e 100644 --- a/src/plugins/debugger/stackframe.cpp +++ b/src/plugins/debugger/stackframe.cpp @@ -29,6 +29,7 @@ **************************************************************************/ #include "stackframe.h" +#include "watchutils.h" #include #include @@ -87,13 +88,9 @@ QString StackFrame::toToolTip() const QString res; QTextStream str(&res); str << ""; - if (address) { - str << ""; + if (address) + str << ""; if (!function.isEmpty()) str << ""; if (!file.isEmpty()) diff --git a/src/plugins/debugger/threadshandler.cpp b/src/plugins/debugger/threadshandler.cpp index 7aae6423fb6..e9368abd09d 100644 --- a/src/plugins/debugger/threadshandler.cpp +++ b/src/plugins/debugger/threadshandler.cpp @@ -30,6 +30,7 @@ #include "threadshandler.h" #include "gdb/gdbmi.h" +#include "watchutils.h" #include "debuggerconstants.h" #include "debuggercore.h" @@ -75,9 +76,7 @@ static QString threadToolTip(const ThreadData &thread) str << thread.function << "
"; if (!thread.fileName.isEmpty()) str << thread.fileName << ':' << thread.lineNumber << "
"; - str.setIntegerBase(16); - str << "0x" << thread.address; - str.setIntegerBase(10); + str << formatToolTipAddress(thread.address); } str << "
" << tr("Address:") << "0x"; - str.setIntegerBase(16); - str << address; - } - str.setIntegerBase(10); - str << "
" << tr("Address:") << "" + << formatToolTipAddress(address) << "
" << tr("Function:") << "" << function << "
"; return rc; diff --git a/src/plugins/debugger/watchdata.cpp b/src/plugins/debugger/watchdata.cpp index e2cd90b40c5..96bcedeecc1 100644 --- a/src/plugins/debugger/watchdata.cpp +++ b/src/plugins/debugger/watchdata.cpp @@ -29,6 +29,7 @@ **************************************************************************/ #include "watchdata.h" +#include "watchutils.h" #include #include @@ -388,11 +389,9 @@ QString WatchData::toToolTip() const val += tr(" ... "); } formatToolTipRow(str, tr("Value"), val); - formatToolTipRow(str, tr("Object Address"), - QString::fromLatin1(hexAddress())); - if (referencingAddress) - formatToolTipRow(str, tr("Referencing Address"), - QString::fromLatin1(hexReferencingAddress())); + formatToolTipRow(str, tr("Object Address"), formatToolTipAddress(address)); + if (referencingAddress) + formatToolTipRow(str, tr("Referencing Address"), formatToolTipAddress(referencingAddress)); if (size) formatToolTipRow(str, tr("Static Object Size"), tr("%n bytes", 0, size)); formatToolTipRow(str, tr("Internal ID"), QLatin1String(iname)); diff --git a/src/plugins/debugger/watchutils.cpp b/src/plugins/debugger/watchutils.cpp index 1bdaa10ac37..de26258c3de 100644 --- a/src/plugins/debugger/watchutils.cpp +++ b/src/plugins/debugger/watchutils.cpp @@ -308,6 +308,26 @@ QByteArray stripPointerType(QByteArray type) return type; } +// Format a hex address with colons as in the memory editor. +QString formatToolTipAddress(quint64 a) +{ + QString rc = QString::number(a, 16); + if (a) { + if (const int remainder = rc.size() % 4) + rc.prepend(QString(4 - remainder, QLatin1Char('0'))); + const QChar colon = QLatin1Char(':'); + switch (rc.size()) { + case 16: + rc.insert(12, colon); + case 12: + rc.insert(8, colon); + case 8: + rc.insert(4, colon); + } + } + return QLatin1String("0x") + rc; +} + /* getUninitializedVariables(): Get variables that are not initialized * at a certain line of a function from the code model to be able to * indicate them as not in scope in the locals view. diff --git a/src/plugins/debugger/watchutils.h b/src/plugins/debugger/watchutils.h index 6e77da9625d..28ff1767a9d 100644 --- a/src/plugins/debugger/watchutils.h +++ b/src/plugins/debugger/watchutils.h @@ -98,6 +98,8 @@ bool isIntOrFloatType(const QByteArray &type); bool isIntType(const QByteArray &type); bool isSymbianIntType(const QByteArray &type); +QString formatToolTipAddress(quint64 a); + QString quoteUnprintableLatin1(const QByteArray &ba); // Editor tooltip support