debugger: make original value of automatically dereferenced pointer accessible

This commit is contained in:
hjk
2011-04-06 18:39:56 +02:00
parent 5a2c64b482
commit cd9aec6df9
6 changed files with 32 additions and 4 deletions

View File

@@ -1766,6 +1766,7 @@ class Dumper:
Item(item.value.dereference(), item.iname, None, None)) Item(item.value.dereference(), item.iname, None, None))
self.currentChildType = savedCurrentChildType self.currentChildType = savedCurrentChildType
self.putPointerValue(value.address) self.putPointerValue(value.address)
self.put('origaddr="%s",' % value)
return return
# Fall back to plain pointer printing. # Fall back to plain pointer printing.

View File

@@ -145,6 +145,7 @@ WatchData::WatchData() :
state(InitialState), state(InitialState),
editformat(0), editformat(0),
address(0), address(0),
origAddress(0),
size(0), size(0),
bitpos(0), bitpos(0),
bitsize(0), bitsize(0),
@@ -309,6 +310,11 @@ QString WatchData::toString() const
str << "addr=\"0x" << address << doubleQuoteComma; str << "addr=\"0x" << address << doubleQuoteComma;
str.setIntegerBase(10); str.setIntegerBase(10);
} }
if (origAddress) {
str.setIntegerBase(16);
str << "origaddr=\"0x" << origAddress << doubleQuoteComma;
str.setIntegerBase(10);
}
if (!exp.isEmpty()) if (!exp.isEmpty())
str << "exp=\"" << exp << doubleQuoteComma; str << "exp=\"" << exp << doubleQuoteComma;
@@ -372,6 +378,9 @@ QString WatchData::toToolTip() const
formatToolTipRow(str, tr("Value"), val); formatToolTipRow(str, tr("Value"), val);
formatToolTipRow(str, tr("Object Address"), formatToolTipRow(str, tr("Object Address"),
QString::fromAscii(hexAddress())); QString::fromAscii(hexAddress()));
if (origAddress)
formatToolTipRow(str, tr("Original Address"),
QString::fromAscii(hexOrigAddress()));
if (size) if (size)
formatToolTipRow(str, tr("Size"), formatToolTipRow(str, tr("Size"),
QString::number(size)); QString::number(size));
@@ -415,6 +424,11 @@ QByteArray WatchData::hexAddress() const
return address ? (QByteArray("0x") + QByteArray::number(address, 16)) : QByteArray(); return address ? (QByteArray("0x") + QByteArray::number(address, 16)) : QByteArray();
} }
QByteArray WatchData::hexOrigAddress() const
{
return origAddress ? (QByteArray("0x") + QByteArray::number(origAddress, 16)) : QByteArray();
}
} // namespace Internal } // namespace Internal
} // namespace Debugger } // namespace Debugger

View File

@@ -113,6 +113,7 @@ public:
quint64 coreAddress() const; quint64 coreAddress() const;
QByteArray hexAddress() const; QByteArray hexAddress() const;
QByteArray hexOrigAddress() const;
public: public:
quint64 id; // Token for the engine for internal mapping quint64 id; // Token for the engine for internal mapping
@@ -128,6 +129,7 @@ public:
QByteArray type; // Type for further processing QByteArray type; // Type for further processing
QString displayedType;// Displayed type (optional) QString displayedType;// Displayed type (optional)
quint64 address; // Displayed address quint64 address; // Displayed address
quint64 origAddress; // Original address for dereferenced pointers
uint size; // Size uint size; // Size
uint bitpos; // Position within bit fields uint bitpos; // Position within bit fields
uint bitsize; // Size in case of bit fields uint bitsize; // Size in case of bit fields

View File

@@ -641,6 +641,10 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const
case 1: case 1:
result = removeInitialNamespace(truncateValue( result = removeInitialNamespace(truncateValue(
formattedValue(data, itemFormat(data))), ns); formattedValue(data, itemFormat(data))), ns);
if (data.origAddress) {
result += QLatin1String(" @");
result += QString::fromLatin1(data.hexOrigAddress());
}
break; break;
case 2: case 2:
result = removeNamespaces(displayType(data), ns); result = removeNamespaces(displayType(data), ns);
@@ -692,16 +696,16 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const
return m_handler->m_expandedINames.contains(data.iname); return m_handler->m_expandedINames.contains(data.iname);
case LocalsTypeFormatListRole: { case LocalsTypeFormatListRole: {
if (isIntType(data.type) && data.type != "bool") if (data.origAddress || data.type.endsWith('*'))
return QStringList() << tr("decimal") << tr("hexadecimal")
<< tr("binary") << tr("octal");
if (data.type.endsWith('*'))
return QStringList() return QStringList()
<< tr("Raw pointer") << tr("Raw pointer")
<< tr("Latin1 string") << tr("Latin1 string")
<< tr("UTF8 string") << tr("UTF8 string")
<< tr("UTF16 string") << tr("UTF16 string")
<< tr("UCS4 string"); << tr("UCS4 string");
if (isIntType(data.type) && data.type != "bool")
return QStringList() << tr("decimal") << tr("hexadecimal")
<< tr("binary") << tr("octal");
// Hack: Compensate for namespaces. // Hack: Compensate for namespaces.
QString type = data.type; QString type = data.type;
int pos = type.indexOf("::Q"); int pos = type.indexOf("::Q");

View File

@@ -1349,6 +1349,11 @@ void setWatchDataAddress(WatchData &data, const GdbMi &mi)
setWatchDataAddressHelper(data, mi.data()); setWatchDataAddressHelper(data, mi.data());
} }
void setWatchDataOrigAddress(WatchData &data, const GdbMi &mi)
{
data.origAddress = mi.data().toULongLong(0, 16);
}
void setWatchDataSize(WatchData &data, const GdbMi &mi) void setWatchDataSize(WatchData &data, const GdbMi &mi)
{ {
if (mi.isValid()) { if (mi.isValid()) {
@@ -1418,6 +1423,7 @@ void parseWatchData(const QSet<QByteArray> &expandedINames,
setWatchDataValue(data, item); setWatchDataValue(data, item);
setWatchDataAddress(data, item.findChild("addr")); setWatchDataAddress(data, item.findChild("addr"));
setWatchDataOrigAddress(data, item.findChild("origaddr"));
setWatchDataSize(data, item.findChild("size")); setWatchDataSize(data, item.findChild("size"));
setWatchDataExpression(data, item.findChild("exp")); setWatchDataExpression(data, item.findChild("exp"));
setWatchDataValueEnabled(data, item.findChild("valueenabled")); setWatchDataValueEnabled(data, item.findChild("valueenabled"));

View File

@@ -2559,6 +2559,7 @@ void testMPI()
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int *x = new int(32);
testQXmlAttributes(); testQXmlAttributes();
testQRegExp(); testQRegExp();
testInlineBreakpoints(); testInlineBreakpoints();