From 122f6a1845be0cbce767233c3cf7431b6fe4b3d8 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@nokia.com> Date: Mon, 4 Apr 2011 16:15:03 +0200 Subject: [PATCH] Debugger: Add size to watch data. Have CDB report it, pass it on to adding watches. --- src/libs/qtcreatorcdbext/symbolgroupnode.cpp | 3 ++- src/plugins/debugger/debuggerconstants.h | 1 + src/plugins/debugger/debuggerstreamops.cpp | 2 ++ src/plugins/debugger/watchdata.cpp | 5 +++++ src/plugins/debugger/watchdata.h | 1 + src/plugins/debugger/watchhandler.cpp | 2 ++ src/plugins/debugger/watchutils.cpp | 11 +++++++++++ src/plugins/debugger/watchwindow.cpp | 8 +++++--- src/plugins/debugger/watchwindow.h | 2 +- 9 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/libs/qtcreatorcdbext/symbolgroupnode.cpp b/src/libs/qtcreatorcdbext/symbolgroupnode.cpp index 43f9a04b653..bb2e950fc5f 100644 --- a/src/libs/qtcreatorcdbext/symbolgroupnode.cpp +++ b/src/libs/qtcreatorcdbext/symbolgroupnode.cpp @@ -987,7 +987,8 @@ int SymbolGroupNode::dumpNode(std::ostream &str, if (addr) str << ",addr=\"" << std::hex << std::showbase << addr << std::noshowbase << std::dec << '"'; - + if (const ULONG s = size()) + str << ",size=\"" << s << '"'; const bool uninitialized = flags() & Uninitialized; bool valueEditable = !uninitialized; bool valueEnabled = !uninitialized; diff --git a/src/plugins/debugger/debuggerconstants.h b/src/plugins/debugger/debuggerconstants.h index c7ba8834b6d..a91ea319a2d 100644 --- a/src/plugins/debugger/debuggerconstants.h +++ b/src/plugins/debugger/debuggerconstants.h @@ -220,6 +220,7 @@ enum ModelRoles LocalsTypeFormatRole, // Used to communicate alternative formats to the view LocalsIndividualFormatRole, LocalsAddressRole, // Memory address of variable as quint64 + LocalsSizeRole, // Size of variable as quint LocalsRawValueRole, // Unformatted value as string LocalsPointerValueRole, // Pointer value (address) as quint64 LocalsIsWatchpointAtAddressRole, diff --git a/src/plugins/debugger/debuggerstreamops.cpp b/src/plugins/debugger/debuggerstreamops.cpp index 75cab5badff..22b9cab3550 100644 --- a/src/plugins/debugger/debuggerstreamops.cpp +++ b/src/plugins/debugger/debuggerstreamops.cpp @@ -225,6 +225,7 @@ QDataStream &operator<<(QDataStream &stream, const WatchData &wd) stream << wd.displayedType; stream << wd.variable; stream << wd.address; + stream << wd.size; stream << wd.hasChildren; stream << wd.generation; stream << wd.valueEnabled; @@ -250,6 +251,7 @@ QDataStream &operator>>(QDataStream &stream, WatchData &wd) stream >> wd.displayedType; stream >> wd.variable; stream >> wd.address; + stream >> wd.size; stream >> wd.hasChildren; stream >> wd.generation; stream >> wd.valueEnabled; diff --git a/src/plugins/debugger/watchdata.cpp b/src/plugins/debugger/watchdata.cpp index 817d0fc2a13..c807f86606b 100644 --- a/src/plugins/debugger/watchdata.cpp +++ b/src/plugins/debugger/watchdata.cpp @@ -145,6 +145,7 @@ WatchData::WatchData() : state(InitialState), editformat(0), address(0), + size(0), bitpos(0), bitsize(0), generation(-1), @@ -170,6 +171,7 @@ bool WatchData::isEqual(const WatchData &other) const && displayedType == other.displayedType && variable == other.variable && address == other.address + && size == other.size && hasChildren == other.hasChildren && valueEnabled == other.valueEnabled && valueEditable == other.valueEditable @@ -370,6 +372,9 @@ QString WatchData::toToolTip() const formatToolTipRow(str, tr("Value"), val); formatToolTipRow(str, tr("Object Address"), QString::fromAscii(hexAddress())); + if (size) + formatToolTipRow(str, tr("Size"), + QString::number(size)); formatToolTipRow(str, tr("Internal ID"), iname); formatToolTipRow(str, tr("Generation"), QString::number(generation)); diff --git a/src/plugins/debugger/watchdata.h b/src/plugins/debugger/watchdata.h index e65b159cd36..f62d73c3826 100644 --- a/src/plugins/debugger/watchdata.h +++ b/src/plugins/debugger/watchdata.h @@ -128,6 +128,7 @@ public: QByteArray type; // Type for further processing QString displayedType;// Displayed type (optional) quint64 address; // Displayed address + uint size; // Size uint bitpos; // Position within bit fields uint bitsize; // Size in case of bit fields qint32 generation; // When updated? diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 776a82dfa5d..a232b098439 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -735,6 +735,8 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const case LocalsAddressRole: return data.coreAddress(); + case LocalsSizeRole: + return QVariant(data.size); case LocalsIsWatchpointAtPointerValueRole: if (isPointerType(data.type)) { diff --git a/src/plugins/debugger/watchutils.cpp b/src/plugins/debugger/watchutils.cpp index 7cd2a79ef56..0c784b0f082 100644 --- a/src/plugins/debugger/watchutils.cpp +++ b/src/plugins/debugger/watchutils.cpp @@ -1349,6 +1349,16 @@ void setWatchDataAddress(WatchData &data, const GdbMi &mi) setWatchDataAddressHelper(data, mi.data()); } +void setWatchDataSize(WatchData &data, const GdbMi &mi) +{ + if (mi.isValid()) { + bool ok = false; + const unsigned size = mi.data().toUInt(&ok); + if (ok) + data.size = size; + } +} + void setWatchDataAddressHelper(WatchData &data, const QByteArray &addr) { if (addr.startsWith("0x")) { // Item model dumpers pull tricks @@ -1408,6 +1418,7 @@ void parseWatchData(const QSet<QByteArray> &expandedINames, setWatchDataValue(data, item); setWatchDataAddress(data, item.findChild("addr")); + setWatchDataSize(data, item.findChild("size")); setWatchDataExpression(data, item.findChild("exp")); setWatchDataValueEnabled(data, item.findChild("valueenabled")); setWatchDataValueEditable(data, item.findChild("valueeditable")); diff --git a/src/plugins/debugger/watchwindow.cpp b/src/plugins/debugger/watchwindow.cpp index d61dcd58b3e..9dea686ed1b 100644 --- a/src/plugins/debugger/watchwindow.cpp +++ b/src/plugins/debugger/watchwindow.cpp @@ -279,6 +279,7 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev) const QModelIndex mi1 = idx.sibling(idx.row(), 1); const QModelIndex mi2 = idx.sibling(idx.row(), 2); const quint64 address = mi0.data(LocalsAddressRole).toULongLong(); + const uint size = mi0.data(LocalsSizeRole).toUInt(); const quint64 pointerValue = mi0.data(LocalsPointerValueRole).toULongLong(); const QString exp = mi0.data(LocalsExpressionRole).toString(); const QString type = mi2.data().toString(); @@ -513,9 +514,9 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev) if (dialog.exec() == QDialog::Accepted) currentEngine()->openMemoryView(dialog.address()); } else if (act == actSetWatchpointAtVariableAddress) { - setWatchpoint(address); + setWatchpoint(address, size); } else if (act == actSetWatchpointAtPointerValue) { - setWatchpoint(pointerValue); + setWatchpoint(pointerValue, 1); } else if (act == actSelectWidgetToWatch) { grabMouse(Qt::CrossCursor); m_grabbing = true; @@ -661,10 +662,11 @@ void WatchWindow::setModelData model()->setData(index, value, role); } -void WatchWindow::setWatchpoint(quint64 address) +void WatchWindow::setWatchpoint(quint64 address, unsigned size) { BreakpointParameters data(Watchpoint); data.address = address; + data.size = size; BreakpointId id = breakHandler()->findWatchpoint(data); if (id) { qDebug() << "WATCHPOINT EXISTS"; diff --git a/src/plugins/debugger/watchwindow.h b/src/plugins/debugger/watchwindow.h index 4f0059d8d25..5b952e809e1 100644 --- a/src/plugins/debugger/watchwindow.h +++ b/src/plugins/debugger/watchwindow.h @@ -79,7 +79,7 @@ private: void editItem(const QModelIndex &idx); void resetHelper(const QModelIndex &idx); - void setWatchpoint(quint64 address); + void setWatchpoint(quint64 address, unsigned size); void setModelData(int role, const QVariant &value = QVariant(), const QModelIndex &index = QModelIndex()); -- GitLab