Commit 122f6a18 authored by Friedemann Kleint's avatar Friedemann Kleint

Debugger: Add size to watch data.

Have CDB report it, pass it on to adding watches.
parent e5f72538
......@@ -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;
......
......@@ -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,
......
......@@ -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;
......
......@@ -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));
......
......@@ -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?
......
......@@ -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)) {
......
......@@ -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"));
......
......@@ -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";
......
......@@ -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());
......
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