Commit 04ad4ba3 authored by Friedemann Kleint's avatar Friedemann Kleint Committed by hjk

Debugger: Format addresses in tooltips.

Pad to 4 digit groups and insert colons for readability.

Change-Id: Icdda754e1d5ac26fd5bb90b5434b0cfa1f7a2f4e
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 0e8ac9b6
......@@ -29,6 +29,7 @@
**************************************************************************/
#include "stackframe.h"
#include "watchutils.h"
#include <QFileInfo>
#include <QDebug>
......@@ -87,13 +88,9 @@ QString StackFrame::toToolTip() const
QString res;
QTextStream str(&res);
str << "<html><body><table>";
if (address) {
str << "<tr><td>" << tr("Address:") << "</td><td>0x";
str.setIntegerBase(16);
str << address;
}
str.setIntegerBase(10);
str << "</td></tr>";
if (address)
str << "<tr><td>" << tr("Address:") << "</td><td>"
<< formatToolTipAddress(address) << "</td></tr>";
if (!function.isEmpty())
str << "<tr><td>" << tr("Function:") << "</td><td>" << function << "</td></tr>";
if (!file.isEmpty())
......
......@@ -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 << "<br>";
if (!thread.fileName.isEmpty())
str << thread.fileName << ':' << thread.lineNumber << "<br>";
str.setIntegerBase(16);
str << "0x" << thread.address;
str.setIntegerBase(10);
str << formatToolTipAddress(thread.address);
}
str << "</table></body></html>";
return rc;
......
......@@ -29,6 +29,7 @@
**************************************************************************/
#include "watchdata.h"
#include "watchutils.h"
#include <QTextStream>
#include <QDebug>
......@@ -388,11 +389,9 @@ QString WatchData::toToolTip() const
val += tr(" ... <cut off>");
}
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));
......
......@@ -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.
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment