forked from qt-creator/qt-creator
debugger: refactor passing of options to new dumpers
This commit is contained in:
@@ -303,11 +303,11 @@ class FrameCommand(gdb.Command):
|
|||||||
args = arg.split(' ')
|
args = arg.split(' ')
|
||||||
#warn("ARG: %s" % arg)
|
#warn("ARG: %s" % arg)
|
||||||
#warn("ARGS: %s" % args)
|
#warn("ARGS: %s" % args)
|
||||||
useFancy = int(args[0])
|
options = args[0].split(",")
|
||||||
passExceptions = int(args[1])
|
useFancy = "fancy" in options
|
||||||
expandedINames = set()
|
expandedINames = set()
|
||||||
if len(args) > 2:
|
if len(args) > 1:
|
||||||
expandedINames = set(args[2].split(","))
|
expandedINames = set(args[1].split(","))
|
||||||
#warn("EXPANDED INAMES: %s" % expandedINames)
|
#warn("EXPANDED INAMES: %s" % expandedINames)
|
||||||
module = sys.modules[__name__]
|
module = sys.modules[__name__]
|
||||||
self.dumpers = {}
|
self.dumpers = {}
|
||||||
@@ -339,10 +339,11 @@ class FrameCommand(gdb.Command):
|
|||||||
|
|
||||||
d = Dumper()
|
d = Dumper()
|
||||||
d.dumpers = self.dumpers
|
d.dumpers = self.dumpers
|
||||||
d.passExceptions = passExceptions
|
d.useFancy = useFancy
|
||||||
|
d.passExceptions = "passexceptions" in options
|
||||||
|
d.autoDerefPointers = "autoderef" in options
|
||||||
d.ns = qtNamespace()
|
d.ns = qtNamespace()
|
||||||
d.expandedINames = expandedINames
|
d.expandedINames = expandedINames
|
||||||
d.useFancy = useFancy
|
|
||||||
#warn(" NAMESPACE IS: '%s'" % d.ns)
|
#warn(" NAMESPACE IS: '%s'" % d.ns)
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -396,8 +397,8 @@ class FrameCommand(gdb.Command):
|
|||||||
#
|
#
|
||||||
d.safeoutput = ""
|
d.safeoutput = ""
|
||||||
watchers = ""
|
watchers = ""
|
||||||
if len(args) > 3:
|
if len(args) > 2:
|
||||||
watchers = base64.b16decode(args[3], True)
|
watchers = base64.b16decode(args[2], True)
|
||||||
if len(watchers) > 0:
|
if len(watchers) > 0:
|
||||||
for watcher in watchers.split("$$"):
|
for watcher in watchers.split("$$"):
|
||||||
(exp, name) = watcher.split("$")
|
(exp, name) = watcher.split("$")
|
||||||
@@ -406,6 +407,11 @@ class FrameCommand(gdb.Command):
|
|||||||
watchers = d.safeoutput
|
watchers = d.safeoutput
|
||||||
|
|
||||||
print('locals={iname="local",name="Locals",value=" ",type=" ",'
|
print('locals={iname="local",name="Locals",value=" ",type=" ",'
|
||||||
|
+ 'children=[' + locals + ']},'
|
||||||
|
+ 'watchers={iname="watch",name="Watchers",value=" ",type=" ",'
|
||||||
|
+ 'children=[' + watchers + ']}\n')
|
||||||
|
|
||||||
|
warn('OUTPUT: locals={iname="local",name="Locals",value=" ",type=" ",'
|
||||||
+ 'children=[' + locals + ']},'
|
+ 'children=[' + locals + ']},'
|
||||||
+ 'watchers={iname="watch",name="Watchers",value=" ",type=" ",'
|
+ 'watchers={iname="watch",name="Watchers",value=" ",type=" ",'
|
||||||
+ 'children=[' + watchers + ']}')
|
+ 'children=[' + watchers + ']}')
|
||||||
@@ -454,7 +460,7 @@ class FrameCommand(gdb.Command):
|
|||||||
try:
|
try:
|
||||||
value = parseAndEvaluate(exp)
|
value = parseAndEvaluate(exp)
|
||||||
item = Item(value, "watch", None, None)
|
item = Item(value, "watch", None, None)
|
||||||
d.safePutItemHelper(item)
|
d.putItemHelper(item)
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
d.put(',value="<invalid>",')
|
d.put(',value="<invalid>",')
|
||||||
d.put('type="<unknown>",numchild="0"')
|
d.put('type="<unknown>",numchild="0"')
|
||||||
@@ -712,7 +718,10 @@ class Dumper:
|
|||||||
# FIXME: Gui shows references stripped?
|
# FIXME: Gui shows references stripped?
|
||||||
#warn("REAL INAME: %s " % item.iname)
|
#warn("REAL INAME: %s " % item.iname)
|
||||||
#warn("REAL TYPE: %s " % item.value.type)
|
#warn("REAL TYPE: %s " % item.value.type)
|
||||||
#warn("REAL VALUE: %s " % item.value)
|
#try:
|
||||||
|
# warn("REAL VALUE: %s " % item.value)
|
||||||
|
#except UnicodeEncodeError:
|
||||||
|
# warn("REAL VALUE: <unprintable>")
|
||||||
|
|
||||||
value = item.value
|
value = item.value
|
||||||
type = value.type
|
type = value.type
|
||||||
@@ -741,33 +750,36 @@ class Dumper:
|
|||||||
#warn("IS DUMPABLE: %s " % type)
|
#warn("IS DUMPABLE: %s " % type)
|
||||||
self.putType(item.value.type)
|
self.putType(item.value.type)
|
||||||
self.dumpers[strippedType](self, item)
|
self.dumpers[strippedType](self, item)
|
||||||
|
warn(" RESULT: %s " % self.output)
|
||||||
|
|
||||||
elif type.code == gdb.TYPE_CODE_ENUM:
|
elif type.code == gdb.TYPE_CODE_ENUM:
|
||||||
#warn("GENERIC ENUM: %s" % value)
|
warn("GENERIC ENUM: %s" % value)
|
||||||
self.putType(item.value.type)
|
self.putType(item.value.type)
|
||||||
self.putValue(value)
|
self.putValue(value)
|
||||||
self.putNumChild(0)
|
self.putNumChild(0)
|
||||||
|
|
||||||
|
|
||||||
elif type.code == gdb.TYPE_CODE_PTR:
|
elif type.code == gdb.TYPE_CODE_PTR:
|
||||||
|
isHandled = False
|
||||||
if self.useFancy:
|
if self.useFancy:
|
||||||
#warn("A POINTER: %s" % value.type)
|
#warn("A POINTER: %s" % value.type)
|
||||||
isHandled = False
|
|
||||||
if isNull(value):
|
if isNull(value):
|
||||||
self.putValue("0x0")
|
self.putValue("0x0")
|
||||||
self.putType(item.value.type)
|
self.putType(item.value.type)
|
||||||
self.putNumChild(0)
|
self.putNumChild(0)
|
||||||
isHandled = True
|
isHandled = True
|
||||||
|
|
||||||
target = str(type.target().unqualified())
|
target = str(type.target().strip_typedefs().unqualified())
|
||||||
if target == "void" and not isHandled:
|
if (not isHandled) and target == "void":
|
||||||
self.putType(item.value.type)
|
self.putType(item.value.type)
|
||||||
self.putValue(str(value))
|
self.putValue(str(value))
|
||||||
self.putNumChild(0)
|
self.putNumChild(0)
|
||||||
isHandled = True
|
isHandled = True
|
||||||
|
|
||||||
if target == "char" and not isHandled:
|
if (not isHandled) and (target == "char"
|
||||||
|
or target == "signed char" or target == "unsigned char"):
|
||||||
# Display values up to given length directly
|
# Display values up to given length directly
|
||||||
|
#warn("CHAR AUTODEREF: %s" % value.address)
|
||||||
self.putType(item.value.type)
|
self.putType(item.value.type)
|
||||||
firstNul = -1
|
firstNul = -1
|
||||||
p = value
|
p = value
|
||||||
@@ -780,9 +792,12 @@ class Dumper:
|
|||||||
break
|
break
|
||||||
p += 1
|
p += 1
|
||||||
|
|
||||||
if not isHandled:
|
#warn("AUTODEREF: %s" % self.autoDerefPointers)
|
||||||
|
#warn("IS HANDLED: %s" % isHandled)
|
||||||
|
#warn("RES: %s" % (self.autoDerefPointers and not isHandled))
|
||||||
|
if self.autoDerefPointers and not isHandled:
|
||||||
## Generic pointer type.
|
## Generic pointer type.
|
||||||
#warn("GENERIC POINTER: %s" % value)
|
warn("GENERIC AUTODEREF POINTER: %s" % value.address)
|
||||||
innerType = item.value.type.target()
|
innerType = item.value.type.target()
|
||||||
self.putType(innerType)
|
self.putType(innerType)
|
||||||
self.childTypes.append(
|
self.childTypes.append(
|
||||||
@@ -790,7 +805,11 @@ class Dumper:
|
|||||||
self.putItemHelper(
|
self.putItemHelper(
|
||||||
Item(item.value.dereference(), item.iname, None, None))
|
Item(item.value.dereference(), item.iname, None, None))
|
||||||
self.childTypes.pop()
|
self.childTypes.pop()
|
||||||
else:
|
isHandled = True
|
||||||
|
|
||||||
|
# Fall back to plain pointer printing
|
||||||
|
if not isHandled:
|
||||||
|
#warn("GENERIC PLAIN POINTER: %s" % type(value))
|
||||||
self.putType(item.value.type)
|
self.putType(item.value.type)
|
||||||
self.putValue(str(value.address))
|
self.putValue(str(value.address))
|
||||||
self.putNumChild(1)
|
self.putNumChild(1)
|
||||||
|
@@ -3605,6 +3605,7 @@ void GdbEngine::updateLocals(const QVariant &cookie)
|
|||||||
m_toolTipExpression.clear();
|
m_toolTipExpression.clear();
|
||||||
WatchHandler *handler = m_manager->watchHandler();
|
WatchHandler *handler = m_manager->watchHandler();
|
||||||
QStringList expanded = handler->expandedINames().toList();
|
QStringList expanded = handler->expandedINames().toList();
|
||||||
|
expanded.append(_("defaults"));
|
||||||
QString watchers;
|
QString watchers;
|
||||||
QHash<QString, int> watcherNames = handler->watcherNames();
|
QHash<QString, int> watcherNames = handler->watcherNames();
|
||||||
QHashIterator<QString, int> it(watcherNames);
|
QHashIterator<QString, int> it(watcherNames);
|
||||||
@@ -3618,8 +3619,17 @@ void GdbEngine::updateLocals(const QVariant &cookie)
|
|||||||
watchers += _("%1$%2").arg(it.key()).arg(it.value());
|
watchers += _("%1$%2").arg(it.key()).arg(it.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
postCommand(_("-interpreter-exec console \"bb %1 0 %2 %3\"")
|
QString options;
|
||||||
.arg(int(theDebuggerBoolSetting(UseDebuggingHelpers)))
|
if (theDebuggerBoolSetting(UseDebuggingHelpers))
|
||||||
|
options += _("fancy,");
|
||||||
|
if (theDebuggerBoolSetting(AutoDerefPointers))
|
||||||
|
options += _("autoderef,");
|
||||||
|
if (options.isEmpty())
|
||||||
|
options += _("defaults,");
|
||||||
|
options.chop(1);
|
||||||
|
|
||||||
|
postCommand(_("-interpreter-exec console \"bb %1 %2 %3\"")
|
||||||
|
.arg(options)
|
||||||
.arg(expanded.join(_(",")))
|
.arg(expanded.join(_(",")))
|
||||||
.arg(_(watchers.toLatin1().toHex())),
|
.arg(_(watchers.toLatin1().toHex())),
|
||||||
CB(handleStackFrame));
|
CB(handleStackFrame));
|
||||||
|
@@ -564,7 +564,11 @@ void tst_Gdb::check(const QByteArray &label, const QByteArray &expected0,
|
|||||||
{
|
{
|
||||||
//qDebug() << "\nABOUT TO RUN TEST: " << expanded;
|
//qDebug() << "\nABOUT TO RUN TEST: " << expanded;
|
||||||
qWarning() << label << "...";
|
qWarning() << label << "...";
|
||||||
writeToGdb("bb " + N(int(fancy)) + " 1 " + expanded);
|
QByteArray options = "passexceptions";
|
||||||
|
options += "autoderef,";
|
||||||
|
if (fancy)
|
||||||
|
options += ",fancy";
|
||||||
|
writeToGdb("bb " + options + " " + expanded);
|
||||||
|
|
||||||
//qDebug() << "\n1 ABOUT TO AQUIRE USED ";
|
//qDebug() << "\n1 ABOUT TO AQUIRE USED ";
|
||||||
usedBytes.acquire();
|
usedBytes.acquire();
|
||||||
|
Reference in New Issue
Block a user