forked from qt-creator/qt-creator
debugger: make dumper code a bit more backend-agnostic
Change-Id: I29fcdb6e82afbb21038427343656238997c9d053 Reviewed-on: http://codereview.qt.nokia.com/3265 Reviewed-by: hjk <qthjk@ovi.com> Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
This commit is contained in:
@@ -20,7 +20,7 @@ except:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
import gdb
|
import gdb
|
||||||
#gdbLoaded = True
|
gdbLoaded = True
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
#
|
#
|
||||||
|
@@ -346,7 +346,7 @@ class Children:
|
|||||||
if isSimpleType(childType):
|
if isSimpleType(childType):
|
||||||
self.d.put('childnumchild="0",')
|
self.d.put('childnumchild="0",')
|
||||||
self.childNumChild = 0
|
self.childNumChild = 0
|
||||||
elif childType.code == gdb.TYPE_CODE_PTR:
|
elif childType.code == PointerCode:
|
||||||
self.d.put('childnumchild="1",')
|
self.d.put('childnumchild="1",')
|
||||||
self.childNumChild = 1
|
self.childNumChild = 1
|
||||||
else:
|
else:
|
||||||
@@ -388,17 +388,6 @@ class Children:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
# Creates a list of field names of an anon union or struct
|
|
||||||
#def listOfFields(type):
|
|
||||||
# fields = []
|
|
||||||
# for field in type.fields():
|
|
||||||
# if len(field.name) > 0:
|
|
||||||
# fields += field.name
|
|
||||||
# else:
|
|
||||||
# fields += listOfFields(field.type)
|
|
||||||
# return fields
|
|
||||||
|
|
||||||
|
|
||||||
def value(expr):
|
def value(expr):
|
||||||
value = parseAndEvaluate(expr)
|
value = parseAndEvaluate(expr)
|
||||||
try:
|
try:
|
||||||
@@ -408,17 +397,11 @@ def value(expr):
|
|||||||
|
|
||||||
def isSimpleType(typeobj):
|
def isSimpleType(typeobj):
|
||||||
code = typeobj.code
|
code = typeobj.code
|
||||||
return code == gdb.TYPE_CODE_BOOL \
|
return code == BoolCode \
|
||||||
or code == gdb.TYPE_CODE_CHAR \
|
or code == CharCode \
|
||||||
or code == gdb.TYPE_CODE_INT \
|
or code == IntCode \
|
||||||
or code == gdb.TYPE_CODE_FLT \
|
or code == FloatCode \
|
||||||
or code == gdb.TYPE_CODE_ENUM
|
or code == EnumCode
|
||||||
|
|
||||||
#return code == BoolCode \
|
|
||||||
# or code == CharCode \
|
|
||||||
# or code == IntCode \
|
|
||||||
# or code == FloatCode \
|
|
||||||
# or code == EnumCode
|
|
||||||
|
|
||||||
def warn(message):
|
def warn(message):
|
||||||
if True or verbosity > 0:
|
if True or verbosity > 0:
|
||||||
@@ -747,22 +730,12 @@ def extractFields(type):
|
|||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
#
|
#
|
||||||
# Item
|
# LocalItem
|
||||||
#
|
#
|
||||||
#######################################################################
|
#######################################################################
|
||||||
|
|
||||||
#class Item:
|
# Contains iname, name, and value.
|
||||||
# def __init__(self, value, parentiname, component):
|
|
||||||
# self.value = value
|
|
||||||
# self.iname = "%s.%s" % (parentiname, component)
|
|
||||||
|
|
||||||
#class SameItem:
|
|
||||||
# def __init__(self, value, iname):
|
|
||||||
# self.value = value
|
|
||||||
# self.iname = iname
|
|
||||||
|
|
||||||
class LocalItem:
|
class LocalItem:
|
||||||
def __init__(self):
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
@@ -1004,7 +977,7 @@ class Dumper:
|
|||||||
typeName = str(type)
|
typeName = str(type)
|
||||||
|
|
||||||
# Special handling for char** argv.
|
# Special handling for char** argv.
|
||||||
if type.code == gdb.TYPE_CODE_PTR \
|
if type.code == PointerCode \
|
||||||
and item.iname == "local.argv" \
|
and item.iname == "local.argv" \
|
||||||
and typeName == "char **":
|
and typeName == "char **":
|
||||||
n = 0
|
n = 0
|
||||||
@@ -1061,7 +1034,6 @@ class Dumper:
|
|||||||
qqQObjectCache[name] = False
|
qqQObjectCache[name] = False
|
||||||
return False
|
return False
|
||||||
base = fields[0].type.strip_typedefs()
|
base = fields[0].type.strip_typedefs()
|
||||||
#if base.code != gdb.TYPE_CODE_STRUCT:
|
|
||||||
if base.code != StructCode:
|
if base.code != StructCode:
|
||||||
return False
|
return False
|
||||||
# Prevent infinite recursion in Qt 3.3.8
|
# Prevent infinite recursion in Qt 3.3.8
|
||||||
@@ -1285,7 +1257,7 @@ class Dumper:
|
|||||||
#warn("REAL CODE: %s " % value.type.code)
|
#warn("REAL CODE: %s " % value.type.code)
|
||||||
#warn("REAL VALUE: %s " % value)
|
#warn("REAL VALUE: %s " % value)
|
||||||
|
|
||||||
if type.code == gdb.TYPE_CODE_REF:
|
if type.code == ReferenceCode:
|
||||||
#try:
|
#try:
|
||||||
# This throws "RuntimeError: Attempt to dereference a
|
# This throws "RuntimeError: Attempt to dereference a
|
||||||
# generic pointer." with MinGW's gcc 4.5 when it "identifies"
|
# generic pointer." with MinGW's gcc 4.5 when it "identifies"
|
||||||
@@ -1295,7 +1267,6 @@ class Dumper:
|
|||||||
#except RuntimeError:
|
#except RuntimeError:
|
||||||
# pass
|
# pass
|
||||||
|
|
||||||
#if type.code == gdb.TYPE_CODE_INT or type.code == gdb.TYPE_CODE_CHAR:
|
|
||||||
if type.code == IntCode or type.code == CharCode:
|
if type.code == IntCode or type.code == CharCode:
|
||||||
self.putAddress(value.address)
|
self.putAddress(value.address)
|
||||||
self.putType(typeName)
|
self.putType(typeName)
|
||||||
@@ -1303,23 +1274,20 @@ class Dumper:
|
|||||||
self.putNumChild(0)
|
self.putNumChild(0)
|
||||||
return
|
return
|
||||||
|
|
||||||
if type.code == gdb.TYPE_CODE_FLT or type.code == gdb.TYPE_CODE_BOOL:
|
if type.code == FloatCode or type.code == BoolCode:
|
||||||
#if type.code == FloatCode or type.code == BoolCode:
|
|
||||||
self.putAddress(value.address)
|
self.putAddress(value.address)
|
||||||
self.putType(typeName)
|
self.putType(typeName)
|
||||||
self.putValue(value)
|
self.putValue(value)
|
||||||
self.putNumChild(0)
|
self.putNumChild(0)
|
||||||
return
|
return
|
||||||
|
|
||||||
if type.code == gdb.TYPE_CODE_ENUM:
|
if type.code == EnumCode:
|
||||||
#if type.code == EnumCode:
|
|
||||||
self.putType(typeName)
|
self.putType(typeName)
|
||||||
self.putValue("%s (%d)" % (value, value))
|
self.putValue("%s (%d)" % (value, value))
|
||||||
self.putNumChild(0)
|
self.putNumChild(0)
|
||||||
return
|
return
|
||||||
|
|
||||||
if type.code == gdb.TYPE_CODE_TYPEDEF:
|
if type.code == TypedefCode:
|
||||||
#if type.code == TypedefCode:
|
|
||||||
self.putItem(value.cast(type.strip_typedefs()))
|
self.putItem(value.cast(type.strip_typedefs()))
|
||||||
self.putBetterType(typeName)
|
self.putBetterType(typeName)
|
||||||
return
|
return
|
||||||
@@ -1328,7 +1296,7 @@ class Dumper:
|
|||||||
if format is None:
|
if format is None:
|
||||||
format = self.typeformats.get(stripClassTag(typeName))
|
format = self.typeformats.get(stripClassTag(typeName))
|
||||||
|
|
||||||
if type.code == gdb.TYPE_CODE_ARRAY:
|
if type.code == ArrayCode:
|
||||||
targettype = type.target()
|
targettype = type.target()
|
||||||
self.putAddress(value.address)
|
self.putAddress(value.address)
|
||||||
self.putType(typeName)
|
self.putType(typeName)
|
||||||
@@ -1354,7 +1322,7 @@ class Dumper:
|
|||||||
i = i + 1
|
i = i + 1
|
||||||
return
|
return
|
||||||
|
|
||||||
if type.code == gdb.TYPE_CODE_PTR:
|
if type.code == PointerCode:
|
||||||
#warn("POINTER: %s" % value)
|
#warn("POINTER: %s" % value)
|
||||||
|
|
||||||
if isNull(value):
|
if isNull(value):
|
||||||
@@ -1368,7 +1336,7 @@ class Dumper:
|
|||||||
innerType = type.target()
|
innerType = type.target()
|
||||||
innerTypeName = str(innerType.unqualified())
|
innerTypeName = str(innerType.unqualified())
|
||||||
|
|
||||||
if innerType.code == gdb.TYPE_CODE_VOID:
|
if innerType.code == VoidCode:
|
||||||
#warn("VOID POINTER: %s" % format)
|
#warn("VOID POINTER: %s" % format)
|
||||||
self.putType(typeName)
|
self.putType(typeName)
|
||||||
self.putValue(str(value))
|
self.putValue(str(value))
|
||||||
@@ -1481,8 +1449,8 @@ class Dumper:
|
|||||||
self.listAnonymous(value, "#%d" % self.anonNumber, type)
|
self.listAnonymous(value, "#%d" % self.anonNumber, type)
|
||||||
return
|
return
|
||||||
|
|
||||||
if type.code != gdb.TYPE_CODE_STRUCT:
|
if type.code != StructCode:
|
||||||
warning("WRONG ASSUMPTION HERE: %s " % gdb.TYPE_CODE_STRUCT)
|
warning("WRONG ASSUMPTION HERE: %s " % type.code)
|
||||||
check(False)
|
check(False)
|
||||||
|
|
||||||
# Is this derived from QObject?
|
# Is this derived from QObject?
|
||||||
@@ -1553,7 +1521,6 @@ class Dumper:
|
|||||||
def putFields(self, value, dumpBase = True):
|
def putFields(self, value, dumpBase = True):
|
||||||
type = stripTypedefs(value.type)
|
type = stripTypedefs(value.type)
|
||||||
# Insufficient, see http://sourceware.org/bugzilla/show_bug.cgi?id=10953:
|
# Insufficient, see http://sourceware.org/bugzilla/show_bug.cgi?id=10953:
|
||||||
#fields = value.type.fields()
|
|
||||||
#fields = type.fields()
|
#fields = type.fields()
|
||||||
fields = extractFields(type)
|
fields = extractFields(type)
|
||||||
#warn("TYPE: %s" % type)
|
#warn("TYPE: %s" % type)
|
||||||
@@ -1582,13 +1549,6 @@ class Dumper:
|
|||||||
|
|
||||||
#warn("FIELD NAME: %s" % field.name)
|
#warn("FIELD NAME: %s" % field.name)
|
||||||
#warn("FIELD TYPE: %s" % field.type)
|
#warn("FIELD TYPE: %s" % field.type)
|
||||||
# The 'field.is_base_class' attribute exists in gdb 7.0.X
|
|
||||||
# and later only. Symbian gdb is 6.8 as of 20.10.2010.
|
|
||||||
# TODO: Remove once Symbian gdb is up to date.
|
|
||||||
#if hasattr(field, 'is_base_class'):
|
|
||||||
# isBaseClass = field.is_base_class
|
|
||||||
#else:
|
|
||||||
# isBaseClass = field.name == stripClassTag(str(field.type))
|
|
||||||
if field.is_base_class:
|
if field.is_base_class:
|
||||||
# Field is base type. We cannot use field.name as part
|
# Field is base type. We cannot use field.name as part
|
||||||
# of the iname as it might contain spaces and other
|
# of the iname as it might contain spaces and other
|
||||||
|
@@ -449,7 +449,7 @@ def qdump__QList(d, value):
|
|||||||
|
|
||||||
# Additional checks on pointer arrays.
|
# Additional checks on pointer arrays.
|
||||||
innerType = templateArgument(value.type, 0)
|
innerType = templateArgument(value.type, 0)
|
||||||
innerTypeIsPointer = innerType.code == gdb.TYPE_CODE_PTR \
|
innerTypeIsPointer = innerType.code == PointerCode \
|
||||||
and str(innerType.target().unqualified()) != "char"
|
and str(innerType.target().unqualified()) != "char"
|
||||||
if innerTypeIsPointer:
|
if innerTypeIsPointer:
|
||||||
p = gdb.Value(array).cast(innerType.pointer()) + begin
|
p = gdb.Value(array).cast(innerType.pointer()) + begin
|
||||||
@@ -1817,7 +1817,7 @@ def qdump__std__stack(d, value):
|
|||||||
def qdump__std__string(d, value):
|
def qdump__std__string(d, value):
|
||||||
data = value["_M_dataplus"]["_M_p"]
|
data = value["_M_dataplus"]["_M_p"]
|
||||||
baseType = value.type.unqualified().strip_typedefs()
|
baseType = value.type.unqualified().strip_typedefs()
|
||||||
if baseType.code == gdb.TYPE_CODE_REF:
|
if baseType.code == ReferenceType:
|
||||||
baseType = baseType.target().unqualified().strip_typedefs()
|
baseType = baseType.target().unqualified().strip_typedefs()
|
||||||
# We might encounter 'std::string' or 'std::basic_string<>'
|
# We might encounter 'std::string' or 'std::basic_string<>'
|
||||||
# or even 'std::locale::string' on MinGW due to some type lookup glitch.
|
# or even 'std::locale::string' on MinGW due to some type lookup glitch.
|
||||||
@@ -1983,7 +1983,7 @@ def qdump__boost__optional(d, value):
|
|||||||
d.putBetterType(value.type)
|
d.putBetterType(value.type)
|
||||||
type = templateArgument(value.type, 0)
|
type = templateArgument(value.type, 0)
|
||||||
storage = value["m_storage"]
|
storage = value["m_storage"]
|
||||||
if type.code == gdb.TYPE_CODE_REF:
|
if type.code == ReferenceCode:
|
||||||
d.putItem(storage.cast(type.target().pointer()).dereference())
|
d.putItem(storage.cast(type.target().pointer()).dereference())
|
||||||
else:
|
else:
|
||||||
d.putItem(storage.cast(type))
|
d.putItem(storage.cast(type))
|
||||||
@@ -2251,7 +2251,7 @@ def qdump__Eigen__Matrix(d, value):
|
|||||||
options = numericTemplateArgument(value.type, 3)
|
options = numericTemplateArgument(value.type, 3)
|
||||||
rowMajor = (int(options) & 0x1)
|
rowMajor = (int(options) & 0x1)
|
||||||
p = storage["m_data"]
|
p = storage["m_data"]
|
||||||
if p.type.code == gdb.TYPE_CODE_STRUCT: # Static
|
if p.type.code == StructCode: # Static
|
||||||
nrows = numericTemplateArgument(value.type, 1)
|
nrows = numericTemplateArgument(value.type, 1)
|
||||||
ncols = numericTemplateArgument(value.type, 2)
|
ncols = numericTemplateArgument(value.type, 2)
|
||||||
p = p["array"].cast(innerType.pointer())
|
p = p["array"].cast(innerType.pointer())
|
||||||
|
Reference in New Issue
Block a user