Commit d9ba7998 authored by hjk's avatar hjk
Browse files

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