Commit 5aebd173 authored by hjk's avatar hjk
Browse files

debugger: make 'watch widget-by-mouseclick' work again

This was the last feature that was only available in the compiled dumpers.
parent 50ea7ab3
...@@ -3717,25 +3717,31 @@ void GdbEngine::assignValueInDebugger(const WatchData *, ...@@ -3717,25 +3717,31 @@ void GdbEngine::assignValueInDebugger(const WatchData *,
void GdbEngine::watchPoint(const QPoint &pnt) void GdbEngine::watchPoint(const QPoint &pnt)
{ {
//qDebug() << "WATCH " << 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("call (void*)watchPoint(" + x + ',' + y + ')', postCommand("print 'QApplication::widgetAt'(" + x + ',' + y + ')',
NeedsStop, CB(handleWatchPoint)); NeedsStop, CB(handleWatchPoint));
} }
void GdbEngine::handleWatchPoint(const GdbResponse &response) void GdbEngine::handleWatchPoint(const GdbResponse &response)
{ {
//qDebug() << "HANDLE WATCH POINT:" << response.toString();
if (response.resultClass == GdbResultDone) { if (response.resultClass == GdbResultDone) {
GdbMi contents = response.data.findChild("consolestreamoutput"); GdbMi contents = response.data.findChild("consolestreamoutput");
// "$5 = (void *) 0xbfa7ebfc\n" // "$5 = (void *) 0xbfa7ebfc\n"
QString str = _(parsePlainConsoleStream(response)); QByteArray ba = parsePlainConsoleStream(response);
// "(void *) 0xbfa7ebfc" const int posWidget = ba.indexOf("QWidget");
QString addr = str.mid(9); if (posWidget == -1)
QByteArray ns = m_dumperHelper.qtNamespace(); return;
QByteArray type = ns.isEmpty() ? "QWidget*" : ("'" + ns + "QWidget'*"); const int posNs = ba.lastIndexOf(' ', posWidget) + 1;
QString exp = _("(*(%1)%2)").arg(_(type)).arg(addr); if (posNs == 0)
return;
const int pos0x = ba.indexOf("0x", posWidget + 7);
if (pos0x == -1)
return;
const QByteArray addr = ba.mid(pos0x);
const QByteArray ns = ba.mid(posNs, posWidget - posNs);
const QByteArray type = ns.isEmpty() ? "QWidget*" : ("'" + ns + "QWidget'*");
const QString exp = _("(*(%1)%2)").arg(_(type)).arg(_(addr));
watchHandler()->watchExpression(exp); watchHandler()->watchExpression(exp);
} }
} }
......
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