forked from qt-creator/qt-creator
debugger: make 'watch' item work with new dumpers
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
import sys
|
||||
import traceback
|
||||
import gdb
|
||||
import base64
|
||||
import curses.ascii
|
||||
|
||||
verbosity = 0
|
||||
@@ -195,10 +196,11 @@ class FrameCommand(gdb.Command):
|
||||
passExceptions = int(args[1])
|
||||
expandedINames = set()
|
||||
if len(args) > 2:
|
||||
expandedINames = set(args[2].split(','))
|
||||
watchers = set()
|
||||
expandedINames = set(args[2].split(","))
|
||||
watchers = ()
|
||||
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("WATCHERS: %s" % watchers)
|
||||
module = sys.modules[__name__]
|
||||
@@ -222,24 +224,31 @@ class FrameCommand(gdb.Command):
|
||||
print output
|
||||
return
|
||||
|
||||
|
||||
if useFancy:
|
||||
for key, value in module.__dict__.items():
|
||||
#if callable(value):
|
||||
if key.startswith("qqDump"):
|
||||
self.dumpers[key[6:]] = value
|
||||
try:
|
||||
frame = gdb.selected_frame()
|
||||
except RuntimeError:
|
||||
return ""
|
||||
|
||||
d = Dumper()
|
||||
d.dumpers = self.dumpers
|
||||
d.passExceptions = passExceptions
|
||||
d.ns = qtNamespace()
|
||||
block = frame.block()
|
||||
d.expandedINames = expandedINames
|
||||
d.useFancy = useFancy
|
||||
#warn(" NAMESPACE IS: '%s'" % d.ns)
|
||||
#warn("FRAME %s: " % frame)
|
||||
|
||||
#
|
||||
# Locals
|
||||
#
|
||||
try:
|
||||
frame = gdb.selected_frame()
|
||||
#warn("FRAME %s: " % frame)
|
||||
except RuntimeError:
|
||||
return ""
|
||||
|
||||
block = frame.block()
|
||||
while True:
|
||||
if block is None:
|
||||
warn("UNEXPECTED 'None' BLOCK")
|
||||
@@ -263,8 +272,6 @@ class FrameCommand(gdb.Command):
|
||||
continue
|
||||
#warn("ITEM %s: " % item.value)
|
||||
|
||||
d.expandedINames = expandedINames
|
||||
d.useFancy = useFancy
|
||||
d.beginHash()
|
||||
d.put('iname="%s",' % item.iname)
|
||||
d.safePutItemHelper(item)
|
||||
@@ -278,6 +285,30 @@ class FrameCommand(gdb.Command):
|
||||
block = block.superblock
|
||||
#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()
|
||||
|
||||
print('locals={iname="local",name="Locals",value=" ",type=" ",'
|
||||
|
@@ -3543,10 +3543,20 @@ void GdbEngine::updateLocals(const QVariant &cookie)
|
||||
m_processedNames.clear();
|
||||
manager()->watchHandler()->beginCycle();
|
||||
m_toolTipExpression.clear();
|
||||
QStringList expanded = m_manager->watchHandler()->expandedINames().toList();
|
||||
postCommand(_("-interpreter-exec console \"bb %1 0 %2\"")
|
||||
WatchHandler *handler = m_manager->watchHandler();
|
||||
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(expanded.join(_(","))),
|
||||
.arg(expanded.join(_(",")))
|
||||
.arg(_(watchers.toLatin1().toBase64())),
|
||||
CB(handleStackFrame));
|
||||
} else {
|
||||
m_processedNames.clear();
|
||||
|
@@ -644,7 +644,8 @@ static QString formattedValue(const WatchData &data,
|
||||
|
||||
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)
|
||||
@@ -1389,10 +1390,9 @@ void WatchHandler::loadWatchers()
|
||||
//reinitializeWatchersHelper();
|
||||
}
|
||||
|
||||
void WatchHandler::saveWatchers()
|
||||
QStringList WatchHandler::watchedExpressions() const
|
||||
{
|
||||
//qDebug() << "SAVE WATCHERS: " << m_watchers;
|
||||
// Filter out valid watchers.
|
||||
// Filter out invalid watchers.
|
||||
QStringList watcherNames;
|
||||
QHashIterator<QString, int> it(m_watcherNames);
|
||||
while (it.hasNext()) {
|
||||
@@ -1401,7 +1401,13 @@ void WatchHandler::saveWatchers()
|
||||
if (!watcherName.isEmpty() && watcherName != watcherEditPlaceHolder())
|
||||
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()
|
||||
|
@@ -274,6 +274,7 @@ public:
|
||||
{ return m_expandedINames.contains(iname); }
|
||||
QSet<QString> expandedINames() const
|
||||
{ return m_expandedINames; }
|
||||
QStringList watchedExpressions() const;
|
||||
|
||||
static QString watcherEditPlaceHolder();
|
||||
|
||||
|
Reference in New Issue
Block a user