Commit ecb0df0c authored by hjk's avatar hjk

debugger: work on "watchers" for use with new dumpers

parent accc2c69
......@@ -294,17 +294,17 @@ class FrameCommand(gdb.Command):
name = str(watcherCount)
try:
value = gdb.parse_and_eval(watcher)
item = Item(value), "watch", name, name)
item = Item(value, "watch", name, name)
warn(" VALUE %s" % item.value)
d.beginHash()
d.put('iname="%s",' % item.iname)
d.safePutItemHelper(item)
d.endHash()
else:
except RuntimeError:
d.beginHash()
d.put('iname="watch.%d",' % watcherCount)
d.put('name="%s",' % watcher)
d.put('value="<invalid>",' % watcherCount)
d.put('value="<invalid>",')
d.put('type=<unknown>,numchild="0"')
d.endHash()
watcherCount += 1
......
......@@ -2819,7 +2819,7 @@ static void setWatchDataValueEditable(WatchData &data, const GdbMi &mi)
static void setWatchDataExpression(WatchData &data, const GdbMi &mi)
{
if (mi.isValid())
data.exp = _('(' + mi.data() + ')');
data.exp = _(mi.data());
}
static void setWatchDataAddress(WatchData &data, const GdbMi &mi)
......@@ -2827,7 +2827,7 @@ static void setWatchDataAddress(WatchData &data, const GdbMi &mi)
if (mi.isValid()) {
data.addr = _(mi.data());
if (data.exp.isEmpty() && !data.addr.startsWith(_("$")))
data.exp = _("(*(") + gdbQuoteTypes(data.type) + _("*)") + data.addr + _c(')');
data.exp = _("*(") + gdbQuoteTypes(data.type) + _("*)") + data.addr;
}
}
......@@ -2886,9 +2886,9 @@ void GdbEngine::runDirectDebuggingHelper(const WatchData &data, bool dumpChildre
QString cmd;
if (type == __("QString") || type.endsWith(__("::QString")))
cmd = _("qdumpqstring (&") + data.exp + _c(')');
cmd = _("qdumpqstring (&(") + data.exp + _("))");
else if (type == __("QStringList") || type.endsWith(__("::QStringList")))
cmd = _("qdumpqstringlist (&") + data.exp + _c(')');
cmd = _("qdumpqstringlist (&(") + data.exp + _("))");
QVariant var;
var.setValue(data);
......@@ -3546,17 +3546,22 @@ void GdbEngine::updateLocals(const QVariant &cookie)
WatchHandler *handler = m_manager->watchHandler();
QStringList expanded = handler->expandedINames().toList();
QString watchers;
foreach (QString item, handler->watchedExpressions()) {
QHash<QString, int> watcherNames = handler->watcherNames();
QHashIterator<QString, int> it(watcherNames);
while (it.hasNext()) {
it.next();
if (!watchers.isEmpty())
watchers += _("$");
//item.replace(_("\""), _("\\\""));
watchers += item;
watchers += _("$$");
if (it.key() == WatchHandler::watcherEditPlaceHolder())
watchers += _("<Edit>$%1").arg(it.value());
else
watchers += _("%1$%2").arg(it.key()).arg(it.value());
}
postCommand(_("-interpreter-exec console \"bb %1 0 %2 %3\"")
.arg(int(theDebuggerBoolSetting(UseDebuggingHelpers)))
.arg(expanded.join(_(",")))
.arg(_(watchers.toLatin1().toBase64())),
.arg(_(watchers.toLatin1().toHex())),
CB(handleStackFrame));
} else {
m_processedNames.clear();
......@@ -3598,18 +3603,22 @@ void GdbEngine::handleStackFrame(const GdbResponse &response)
GdbMi all;
all.fromStringMultiple(out);
//qDebug() << "\n\n\nALL: " << all.toString() << "\n";
GdbMi locals = all.findChild("locals");
//qDebug() << "\n\n\nLOCALS: " << locals.toString() << "\n";
WatchData *data = manager()->watchHandler()->findItem(_("local"));
QTC_ASSERT(data, return);
QList<WatchData> list;
//foreach (const GdbMi &local, locals.children)
// handleChildren(*data, local, &list);
handleChildren(*data, locals, &list);
//for (int i = 0; i != list.size(); ++i)
// qDebug() << "READ: " << list.at(i).toString();
// qDebug() << "LOCAL: " << list.at(i).toString();
manager()->watchHandler()->insertBulkData(list);
GdbMi watchers = all.findChild("watchers");
data = manager()->watchHandler()->findItem(_("watch"));
QTC_ASSERT(data, return);
list.clear();
handleChildren(*data, watchers, &list);
//for (int i = 0; i != list.size(); ++i)
// qDebug() << "WATCH: " << list.at(i).toString();
manager()->watchHandler()->insertBulkData(list);
// FIXME:
......
......@@ -1268,7 +1268,12 @@ void WatchHandler::watchExpression(const QString &exp)
if (exp.isEmpty() || exp == watcherEditPlaceHolder())
data.setAllUnneeded();
data.iname = watcherName(exp);
insertData(data);
IDebuggerEngine *engine = m_manager->currentEngine();
if (engine && engine->isSynchroneous())
m_manager->updateWatchData(data);
else
insertData(data);
m_manager->updateWatchData(data);
saveWatchers();
}
......
......@@ -275,6 +275,8 @@ public:
QSet<QString> expandedINames() const
{ return m_expandedINames; }
QStringList watchedExpressions() const;
QHash<QString, int> watcherNames() const
{ return m_watcherNames; }
static QString watcherEditPlaceHolder();
......
......@@ -267,8 +267,15 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
actWatchKnownMemory = new QAction(tr("Open memory editor at %1").arg(address), &menu);
menu.addSeparator();
int atype = (m_type == LocalsType) ? WatchExpression : RemoveWatchExpression;
menu.addAction(theDebuggerAction(atype)->updatedAction(exp));
QAction *actWatchOrRemove;
if (m_type == LocalsType) {
actWatchOrRemove = theDebuggerAction(WatchExpression)->updatedAction(exp);
} else {
actWatchOrRemove = theDebuggerAction(RemoveWatchExpression)->updatedAction(exp);
// Also for the case where the user cleared the expression.
actWatchOrRemove->setEnabled(true);
}
menu.addAction(actWatchOrRemove);
menu.addAction(actInsertNewWatchItem);
menu.addAction(actSelectWidgetToWatch);
......
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