Commit ef9db9cf authored by hjk's avatar hjk

debugger: make 'watch' item work with new dumpers

parent b0640b9a
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
import sys import sys
import traceback import traceback
import gdb import gdb
import base64
import curses.ascii import curses.ascii
verbosity = 0 verbosity = 0
...@@ -195,10 +196,11 @@ class FrameCommand(gdb.Command): ...@@ -195,10 +196,11 @@ class FrameCommand(gdb.Command):
passExceptions = int(args[1]) passExceptions = int(args[1])
expandedINames = set() expandedINames = set()
if len(args) > 2: if len(args) > 2:
expandedINames = set(args[2].split(',')) expandedINames = set(args[2].split(","))
watchers = set() watchers = ()
if len(args) > 3: if len(args) > 3:
watchers = set(args[3].split(',')) #watchers = set(args[3].split(','))
watchers = base64.b64decode(args[3]).split("$")
#warn("EXPANDED INAMES: %s" % expandedINames) #warn("EXPANDED INAMES: %s" % expandedINames)
#warn("WATCHERS: %s" % watchers) #warn("WATCHERS: %s" % watchers)
module = sys.modules[__name__] module = sys.modules[__name__]
...@@ -222,24 +224,31 @@ class FrameCommand(gdb.Command): ...@@ -222,24 +224,31 @@ class FrameCommand(gdb.Command):
print output print output
return return
if useFancy: if useFancy:
for key, value in module.__dict__.items(): for key, value in module.__dict__.items():
#if callable(value): #if callable(value):
if key.startswith("qqDump"): if key.startswith("qqDump"):
self.dumpers[key[6:]] = value self.dumpers[key[6:]] = value
try:
frame = gdb.selected_frame()
except RuntimeError:
return ""
d = Dumper() d = Dumper()
d.dumpers = self.dumpers d.dumpers = self.dumpers
d.passExceptions = passExceptions d.passExceptions = passExceptions
d.ns = qtNamespace() d.ns = qtNamespace()
block = frame.block() d.expandedINames = expandedINames
d.useFancy = useFancy
#warn(" NAMESPACE IS: '%s'" % d.ns) #warn(" NAMESPACE IS: '%s'" % d.ns)
#
# Locals
#
try:
frame = gdb.selected_frame()
#warn("FRAME %s: " % frame) #warn("FRAME %s: " % frame)
except RuntimeError:
return ""
block = frame.block()
while True: while True:
if block is None: if block is None:
warn("UNEXPECTED 'None' BLOCK") warn("UNEXPECTED 'None' BLOCK")
...@@ -263,8 +272,6 @@ class FrameCommand(gdb.Command): ...@@ -263,8 +272,6 @@ class FrameCommand(gdb.Command):
continue continue
#warn("ITEM %s: " % item.value) #warn("ITEM %s: " % item.value)
d.expandedINames = expandedINames
d.useFancy = useFancy
d.beginHash() d.beginHash()
d.put('iname="%s",' % item.iname) d.put('iname="%s",' % item.iname)
d.safePutItemHelper(item) d.safePutItemHelper(item)
...@@ -278,6 +285,30 @@ class FrameCommand(gdb.Command): ...@@ -278,6 +285,30 @@ class FrameCommand(gdb.Command):
block = block.superblock block = block.superblock
#warn("BLOCK %s: " % block) #warn("BLOCK %s: " % block)
#
# Watchers
#
watcherCount = 0
for watcher in watchers:
warn("HANDLING WATCH %s" % watcher)
name = str(watcherCount)
try:
value = gdb.parse_and_eval(watcher)
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:
d.beginHash()
d.put('iname="watch.%d",' % watcherCount)
d.put('name="%s",' % watcher)
d.put('value="<invalid>",' % watcherCount)
d.put('type=<unknown>,numchild="0"')
d.endHash()
watcherCount += 1
d.pushOutput() d.pushOutput()
print('locals={iname="local",name="Locals",value=" ",type=" ",' print('locals={iname="local",name="Locals",value=" ",type=" ",'
......
...@@ -3543,10 +3543,20 @@ void GdbEngine::updateLocals(const QVariant &cookie) ...@@ -3543,10 +3543,20 @@ void GdbEngine::updateLocals(const QVariant &cookie)
m_processedNames.clear(); m_processedNames.clear();
manager()->watchHandler()->beginCycle(); manager()->watchHandler()->beginCycle();
m_toolTipExpression.clear(); m_toolTipExpression.clear();
QStringList expanded = m_manager->watchHandler()->expandedINames().toList(); WatchHandler *handler = m_manager->watchHandler();
postCommand(_("-interpreter-exec console \"bb %1 0 %2\"") QStringList expanded = handler->expandedINames().toList();
QString watchers;
foreach (QString item, handler->watchedExpressions()) {
if (!watchers.isEmpty())
watchers += _("$");
//item.replace(_("\""), _("\\\""));
watchers += item;
}
postCommand(_("-interpreter-exec console \"bb %1 0 %2 %3\"")
.arg(int(theDebuggerBoolSetting(UseDebuggingHelpers))) .arg(int(theDebuggerBoolSetting(UseDebuggingHelpers)))
.arg(expanded.join(_(","))), .arg(expanded.join(_(",")))
.arg(_(watchers.toLatin1().toBase64())),
CB(handleStackFrame)); CB(handleStackFrame));
} else { } else {
m_processedNames.clear(); m_processedNames.clear();
......
...@@ -644,7 +644,8 @@ static QString formattedValue(const WatchData &data, ...@@ -644,7 +644,8 @@ static QString formattedValue(const WatchData &data,
bool WatchModel::canFetchMore(const QModelIndex &index) const bool WatchModel::canFetchMore(const QModelIndex &index) const
{ {
return !m_inExtraLayoutChanged && index.isValid() && !m_fetchTriggered.contains(watchItem(index)->iname); return !m_inExtraLayoutChanged && index.isValid()
&& !m_fetchTriggered.contains(watchItem(index)->iname);
} }
void WatchModel::fetchMore(const QModelIndex &index) void WatchModel::fetchMore(const QModelIndex &index)
...@@ -1389,10 +1390,9 @@ void WatchHandler::loadWatchers() ...@@ -1389,10 +1390,9 @@ void WatchHandler::loadWatchers()
//reinitializeWatchersHelper(); //reinitializeWatchersHelper();
} }
void WatchHandler::saveWatchers() QStringList WatchHandler::watchedExpressions() const
{ {
//qDebug() << "SAVE WATCHERS: " << m_watchers; // Filter out invalid watchers.
// Filter out valid watchers.
QStringList watcherNames; QStringList watcherNames;
QHashIterator<QString, int> it(m_watcherNames); QHashIterator<QString, int> it(m_watcherNames);
while (it.hasNext()) { while (it.hasNext()) {
...@@ -1401,7 +1401,13 @@ void WatchHandler::saveWatchers() ...@@ -1401,7 +1401,13 @@ void WatchHandler::saveWatchers()
if (!watcherName.isEmpty() && watcherName != watcherEditPlaceHolder()) if (!watcherName.isEmpty() && watcherName != watcherEditPlaceHolder())
watcherNames.push_back(watcherName); watcherNames.push_back(watcherName);
} }
m_manager->setSessionValue("Watchers", QVariant(watcherNames)); return watcherNames;
}
void WatchHandler::saveWatchers()
{
//qDebug() << "SAVE WATCHERS: " << m_watchers;
m_manager->setSessionValue("Watchers", QVariant(watchedExpressions()));
} }
void WatchHandler::loadTypeFormats() void WatchHandler::loadTypeFormats()
......
...@@ -274,6 +274,7 @@ public: ...@@ -274,6 +274,7 @@ public:
{ return m_expandedINames.contains(iname); } { return m_expandedINames.contains(iname); }
QSet<QString> expandedINames() const QSet<QString> expandedINames() const
{ return m_expandedINames; } { return m_expandedINames; }
QStringList watchedExpressions() const;
static QString watcherEditPlaceHolder(); static QString watcherEditPlaceHolder();
......
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