Commit d9ba7998 authored by hjk's avatar hjk

Debugger: Fix/simplify selection of Widget to watch with newer GDBs

GDB does return dynamic types nowadays, and some widgets are
not plain QWidgets but subclasses...

Change-Id: If3b7b0f7d639858eeb1e42659a649db22822c20f
Reviewed-by: default avatarChristian Stenger <christian.stenger@digia.com>
parent e5bef06d
......@@ -3814,7 +3814,7 @@ void GdbEngine::watchPoint(const QPoint &pnt)
{
QByteArray x = QByteArray::number(pnt.x());
QByteArray y = QByteArray::number(pnt.y());
postCommand("print '" + qtNamespace() + "QApplication::widgetAt'("
postCommand("print " + qtNamespace() + "QApplication::widgetAt("
+ x + ',' + y + ')',
NeedsStop, CB(handleWatchPoint));
}
......@@ -3824,19 +3824,14 @@ void GdbEngine::handleWatchPoint(const GdbResponse &response)
if (response.resultClass == GdbResultDone) {
// "$5 = (void *) 0xbfa7ebfc\n"
const QByteArray ba = parsePlainConsoleStream(response);
//qDebug() << "BA: " << ba;
const int posWidget = ba.indexOf("QWidget");
const int pos0x = ba.indexOf("0x", posWidget + 7);
if (posWidget == -1 || pos0x == -1) {
const int pos0x = ba.indexOf("0x");
if (pos0x == -1) {
showStatusMessage(tr("Cannot read widget data: %1").arg(_(ba)));
} else {
const QByteArray addr = ba.mid(pos0x);
if (addr.toULongLong(0, 0)) { // Non-null pointer
const QByteArray ns = qtNamespace();
const QByteArray type = ns.isEmpty() ? "QWidget*"
: QByteArray("'" + ns + "QWidget'*");
const QString exp = _("(*(struct %1)%2)").arg(_(type)).arg(_(addr));
// qDebug() << posNs << posWidget << pos0x << addr << ns << type;
const QByteArray type = "::" + qtNamespace() + "QWidget";
const QString exp = _("{%1}%2").arg(_(type)).arg(_(addr));
watchHandler()->watchExpression(exp);
} else {
showStatusMessage(tr("Could not find a widget."));
......
......@@ -804,7 +804,7 @@ void WatchTreeView::contextMenuEvent(QContextMenuEvent *ev)
actInsertNewWatchItem->setEnabled(canHandleWatches && canInsertWatches);
QAction *actSelectWidgetToWatch =
menu.addAction(tr("Select Widget to Add into Expression Evaluator"));
actSelectWidgetToWatch->setEnabled(canHandleWatches && canInsertWatches
actSelectWidgetToWatch->setEnabled(canHandleWatches
&& engine->hasCapability(WatchWidgetsCapability));
menu.addSeparator();
......
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