From 4bd6bb4d55e6ab9bb2389dcbbd5ec6e96d2c0adc Mon Sep 17 00:00:00 2001 From: hjk <qtc-committer@nokia.com> Date: Mon, 23 May 2011 18:54:12 +0200 Subject: [PATCH] debugger: improve robustness of watchers This solves one common case of adding the 'class' *(class X*)0xdeadbeef "needed" by gdb in case a local variable at the same location is known. Change-Id: I5b25530b00e512c6e9155fb111ff4dc916832074 Reviewed-on: http://codereview.qt.nokia.com/76 Reviewed-by: hjk --- src/plugins/debugger/watchhandler.cpp | 20 ++++++++++---------- src/plugins/debugger/watchutils.cpp | 10 ++++++++-- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 4702b6394a1..9cd7dbd5e49 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -595,16 +595,16 @@ static inline QString expression(const WatchItem *item) { if (!item->exp.isEmpty()) return QString::fromAscii(item->exp); - if (item->address && !item->type.isEmpty()) { - return QString::fromAscii("*(%1*)%2"). - arg(QLatin1String(item->type), QLatin1String(item->hexAddress())); - } - if (const WatchItem *parent = item->parent) { - if (!parent->exp.isEmpty()) - return QString::fromAscii("(%1).%2") - .arg(QString::fromLatin1(parent->exp), item->name); - } - return QString(); + if (item->address && !item->type.isEmpty()) { + return QString::fromAscii("*(%1*)%2"). + arg(QLatin1String(item->type), QLatin1String(item->hexAddress())); + } + if (const WatchItem *parent = item->parent) { + if (!parent->exp.isEmpty()) + return QString::fromAscii("(%1).%2") + .arg(QString::fromLatin1(parent->exp), item->name); + } + return QString(); } QVariant WatchModel::data(const QModelIndex &idx, int role) const diff --git a/src/plugins/debugger/watchutils.cpp b/src/plugins/debugger/watchutils.cpp index ed59a6979e7..f8bcb1c64a7 100644 --- a/src/plugins/debugger/watchutils.cpp +++ b/src/plugins/debugger/watchutils.cpp @@ -739,8 +739,14 @@ static void setWatchDataAddress(WatchData &data, quint64 address , quint64 origA } else { data.address = address; } - if (data.exp.isEmpty() && !data.dumperFlags.startsWith('$')) - data.exp = "*(" + gdbQuoteTypes(data.type) + "*)" +data.hexAddress(); + if (data.exp.isEmpty() && !data.dumperFlags.startsWith('$')) { + if (data.iname.startsWith("local.") && data.iname.count('.') == 1) + // Solve one common case of adding 'class' in + // *(class X*)0xdeadbeef for gdb. + data.exp = data.name.toLatin1(); + else + data.exp = "*(" + gdbQuoteTypes(data.type) + "*)" +data.hexAddress(); + } } void setWatchDataAddress(WatchData &data, const GdbMi &addressMi, const GdbMi &origAddressMi) -- GitLab