Debugger: Split qttypes.py

... into qttypes, stdtypes, boosttypes, and misctypes.py

Change-Id: I3bce8dfe912c528f3a0d8d6670108f8d3272b4af
Reviewed-by: David Schulz <david.schulz@digia.com>
This commit is contained in:
hjk
2013-10-10 16:40:56 +02:00
committed by David Schulz
parent 6c0ef3670c
commit d6afbdd047
7 changed files with 1210 additions and 1080 deletions
+109
View File
@@ -0,0 +1,109 @@
############################################################################
#
# Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
# Contact: http://www.qt-project.org/legal
#
# This file is part of Qt Creator.
#
# Commercial License Usage
# Licensees holding valid commercial Qt licenses may use this file in
# accordance with the commercial license agreement provided with the
# Software or, alternatively, in accordance with the terms contained in
# a written agreement between you and Digia. For licensing terms and
# conditions see http://qt.digia.com/licensing. For further information
# use the contact form at http://qt.digia.com/contact-us.
#
# GNU Lesser General Public License Usage
# Alternatively, this file may be used under the terms of the GNU Lesser
# General Public License version 2.1 as published by the Free Software
# Foundation and appearing in the file LICENSE.LGPL included in the
# packaging of this file. Please review the following information to
# ensure the GNU Lesser General Public License version 2.1 requirements
# will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
#
# In addition, as a special exception, Digia gives you certain additional
# rights. These rights are described in the Digia Qt LGPL Exception
# version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
#
#############################################################################
from dumper import *
def qdump__boost__bimaps__bimap(d, value):
#leftType = d.templateArgument(value.type, 0)
#rightType = d.templateArgument(value.type, 1)
size = int(value["core"]["node_count"])
d.putItemCount(size)
d.putNumChild(size)
if d.isExpanded():
d.putPlainChildren(value)
def qdump__boost__optional(d, value):
if int(value["m_initialized"]) == 0:
d.putValue("<uninitialized>")
d.putNumChild(0)
else:
type = d.templateArgument(value.type, 0)
storage = value["m_storage"]
if d.isReferenceType(type):
d.putItem(storage.cast(type.target().pointer()).dereference())
else:
d.putItem(storage.cast(type))
d.putBetterType(value.type)
def qdump__boost__shared_ptr(d, value):
# s boost::shared_ptr<int>
# pn boost::detail::shared_count
# pi_ 0x0 boost::detail::sp_counted_base *
# px 0x0 int *
if d.isNull(value["pn"]["pi_"]):
d.putValue("(null)")
d.putNumChild(0)
return
if d.isNull(value["px"]):
d.putValue("(null)")
d.putNumChild(0)
return
countedbase = value["pn"]["pi_"].dereference()
weakcount = int(countedbase["weak_count_"])
usecount = int(countedbase["use_count_"])
d.check(weakcount >= 0)
d.check(weakcount <= int(usecount))
d.check(usecount <= 10*1000*1000)
val = value["px"].dereference()
if d.isSimpleType(val.type):
d.putNumChild(3)
d.putItem(val)
d.putBetterType(value.type)
else:
d.putEmptyValue()
d.putNumChild(3)
if d.isExpanded():
with Children(d, 3):
d.putSubItem("data", val)
d.putIntItem("weakcount", weakcount)
d.putIntItem("usecount", usecount)
def qdump__boost__gregorian__date(d, value):
d.putValue(int(value["days_"]), JulianDate)
d.putNumChild(0)
def qdump__boost__posix_time__ptime(d, item):
ms = int(item["time_"]["time_count_"]["value_"]) / 1000
d.putValue("%s/%s" % divmod(ms, 86400000), JulianDateAndMillisecondsSinceMidnight)
d.putNumChild(0)
def qdump__boost__posix_time__time_duration(d, item):
d.putValue(int(item["ticks_"]["value_"]) / 1000, MillisecondsSinceMidnight)
d.putNumChild(0)
+127
View File
@@ -0,0 +1,127 @@
############################################################################
#
# Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
# Contact: http://www.qt-project.org/legal
#
# This file is part of Qt Creator.
#
# Commercial License Usage
# Licensees holding valid commercial Qt licenses may use this file in
# accordance with the commercial license agreement provided with the
# Software or, alternatively, in accordance with the terms contained in
# a written agreement between you and Digia. For licensing terms and
# conditions see http://qt.digia.com/licensing. For further information
# use the contact form at http://qt.digia.com/contact-us.
#
# GNU Lesser General Public License Usage
# Alternatively, this file may be used under the terms of the GNU Lesser
# General Public License version 2.1 as published by the Free Software
# Foundation and appearing in the file LICENSE.LGPL included in the
# packaging of this file. Please review the following information to
# ensure the GNU Lesser General Public License version 2.1 requirements
# will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
#
# In addition, as a special exception, Digia gives you certain additional
# rights. These rights are described in the Digia Qt LGPL Exception
# version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
#
#############################################################################
from dumper import *
def qdump__Core__Id(d, value):
try:
name = parseAndEvaluate("Core::nameForId(%d)" % value["m_id"])
d.putValue(encodeCharArray(name), Hex2EncodedLatin1)
d.putPlainChildren(value)
except:
d.putValue(value["m_id"])
d.putNumChild(0)
def qdump__Debugger__Internal__GdbMi(d, value):
str = d.encodeByteArray(value["m_name"]) + "3a20" \
+ d.encodeByteArray(value["m_data"])
d.putValue(str, Hex2EncodedLatin1)
d.putPlainChildren(value)
def qdump__Debugger__Internal__WatchData(d, value):
d.putByteArrayValue(value["iname"])
d.putPlainChildren(value)
def qdump__Debugger__Internal__WatchItem(d, value):
d.putByteArrayValue(value["iname"])
d.putPlainChildren(value)
def qdump__Debugger__Internal__BreakpointModelId(d, value):
d.putValue("%s.%s" % (value["m_majorPart"], value["m_minorPart"]))
d.putPlainChildren(value)
def qdump__CPlusPlus__ByteArrayRef(d, value):
d.putValue(encodeCharArray(value["m_start"], 100, value["m_length"]),
Hex2EncodedLatin1)
d.putPlainChildren(value)
def qdump__CPlusPlus__Identifier(d, value):
d.putValue(encodeCharArray(value["_chars"]), Hex2EncodedLatin1)
d.putPlainChildren(value)
def qdump__CPlusPlus__IntegerType(d, value):
d.putValue(value["_kind"])
d.putPlainChildren(value)
def qdump__CPlusPlus__NamedType(d, value):
literal = downcast(value["_name"])
d.putValue(encodeCharArray(literal["_chars"]), Hex2EncodedLatin1)
d.putPlainChildren(value)
def qdump__CPlusPlus__TemplateNameId(d, value):
s = encodeCharArray(value["_identifier"]["_chars"])
d.putValue(s + "3c2e2e2e3e", Hex2EncodedLatin1)
d.putPlainChildren(value)
def qdump__CPlusPlus__Literal(d, value):
d.putValue(encodeCharArray(value["_chars"]), Hex2EncodedLatin1)
d.putPlainChildren(value)
def qdump__CPlusPlus__StringLiteral(d, value):
d.putValue(encodeCharArray(value["_chars"]), Hex2EncodedLatin1)
d.putPlainChildren(value)
def qdump__CPlusPlus__Internal__Value(d, value):
d.putValue(value["l"])
d.putPlainChildren(value)
def qdump__Utils__FileName(d, value):
d.putStringValue(value)
d.putPlainChildren(value)
def qdump__Utils__ElfSection(d, value):
d.putByteArrayValue(value["name"])
d.putPlainChildren(value)
def qdump__CPlusPlus__Token(d, value):
k = int(value["f"]["kind"])
if int(k) == 6:
d.putValue("T_IDENTIFIER. offset: %d, len: %d"
% (value["offset"], value["f"]["length"]))
elif int(k) == 7:
d.putValue("T_NUMERIC_LITERAL. offset: %d, value: %d"
% (value["offset"], value["f"]["length"]))
elif int(k) == 60:
d.putValue("T_RPAREN")
else:
d.putValue("Type: %s" % k)
d.putPlainChildren(value)
def qdump__CPlusPlus__Internal__PPToken(d, value):
k = value["f"]["kind"];
data, size, alloc = d.byteArrayData(value["m_src"])
length = int(value["f"]["length"])
offset = int(value["offset"])
#warn("size: %s, alloc: %s, offset: %s, length: %s, data: %s"
# % (size, alloc, offset, length, data))
d.putValue(d.readMemory(data + offset, min(100, length)),
Hex2EncodedLatin1)
d.putPlainChildren(value)
+4
View File
@@ -23,6 +23,10 @@ def warn(message):
from dumper import *
from qttypes import *
from stdtypes import *
from misctypes import *
from boosttypes import *
#######################################################################
#
+3
View File
@@ -41,6 +41,9 @@ sys.path.insert(1, currentDir)
from dumper import *
from qttypes import *
from stdtypes import *
from misctypes import *
from boosttypes import *
+316
View File
@@ -0,0 +1,316 @@
############################################################################
#
# Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
# Contact: http://www.qt-project.org/legal
#
# This file is part of Qt Creator.
#
# Commercial License Usage
# Licensees holding valid commercial Qt licenses may use this file in
# accordance with the commercial license agreement provided with the
# Software or, alternatively, in accordance with the terms contained in
# a written agreement between you and Digia. For licensing terms and
# conditions see http://qt.digia.com/licensing. For further information
# use the contact form at http://qt.digia.com/contact-us.
#
# GNU Lesser General Public License Usage
# Alternatively, this file may be used under the terms of the GNU Lesser
# General Public License version 2.1 as published by the Free Software
# Foundation and appearing in the file LICENSE.LGPL included in the
# packaging of this file. Please review the following information to
# ensure the GNU Lesser General Public License version 2.1 requirements
# will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
#
# In addition, as a special exception, Digia gives you certain additional
# rights. These rights are described in the Digia Qt LGPL Exception
# version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
#
#############################################################################
from dumper import *
#######################################################################
#
# SSE
#
#######################################################################
def qform____m128():
return "As Floats,As Doubles"
def qdump____m128(d, value):
d.putEmptyValue()
d.putNumChild(1)
if d.isExpanded():
format = d.currentItemFormat()
if format == 2: # As Double
d.putArrayData(d.lookupType("double"), value.address, 2)
else: # Default, As float
d.putArrayData(d.lookupType("float"), value.address, 4)
#######################################################################
#
# Eigen
#
#######################################################################
#def qform__Eigen__Matrix():
# return "Transposed"
def qdump__Eigen__Matrix(d, value):
innerType = d.templateArgument(value.type, 0)
storage = value["m_storage"]
options = d.numericTemplateArgument(value.type, 3)
rowMajor = (int(options) & 0x1)
argRow = d.numericTemplateArgument(value.type, 1)
argCol = d.numericTemplateArgument(value.type, 2)
nrows = value["m_storage"]["m_rows"] if argRow == -1 else int(argRow)
ncols = value["m_storage"]["m_cols"] if argCol == -1 else int(argCol)
p = storage["m_data"]
if d.isStructType(p.type): # Static
p = p["array"].cast(innerType.pointer())
d.putValue("(%s x %s), %s" % (nrows, ncols, ["ColumnMajor", "RowMajor"][rowMajor]))
d.putField("keeporder", "1")
d.putNumChild(nrows * ncols)
limit = 10000
nncols = min(ncols, limit)
nnrows = min(nrows, limit * limit / nncols)
if d.isExpanded():
#format = d.currentItemFormat() # format == 1 is "Transposed"
with Children(d, nrows * ncols, childType=innerType):
if ncols == 1 or nrows == 1:
for i in range(0, min(nrows * ncols, 10000)):
d.putSubItem(i, (p + i).dereference())
elif rowMajor == 1:
s = 0
for i in range(0, nnrows):
for j in range(0, nncols):
v = (p + i * ncols + j).dereference()
d.putNamedSubItem(s, v, "[%d,%d]" % (i, j))
s = s + 1
else:
s = 0
for j in range(0, nncols):
for i in range(0, nnrows):
v = (p + i + j * nrows).dereference()
d.putNamedSubItem(s, v, "[%d,%d]" % (i, j))
s = s + 1
#######################################################################
#
# D
#
#######################################################################
def cleanDType(type):
return d.stripClassTag(str(type)).replace("uns long long", "string")
def qdump_Array(d, value):
n = value["length"]
p = value["ptr"]
t = cleanDType(value.type)[7:]
d.putType("%s[%d]" % (t, n))
if t == "char":
d.putValue(encodeCharArray(p, 100), Hex2EncodedLocal8Bit)
d.putNumChild(0)
else:
d.putEmptyValue()
d.putNumChild(n)
innerType = p.type
if d.isExpanded():
with Children(d, n, childType=innerType):
for i in range(0, n):
d.putSubItem(i, p.dereference())
p = p + 1
def qdump_AArray(d, value):
#n = value["length"]
# This ends up as _AArray_<key>_<value> with a single .ptr
# member of type void *. Not much that can be done here.
p = value["ptr"]
t = cleanDType(value.type)[8:]
d.putType("%s]" % t.replace("_", "["))
d.putEmptyValue()
d.putNumChild(1)
if d.isExpanded():
with Children(d, 1):
d.putSubItem("ptr", p)
#######################################################################
#
# Display Test
#
#######################################################################
if False:
# FIXME: Make that work
def qdump__Color(d, value):
v = value
d.putValue("(%s, %s, %s; %s)" % (v["r"], v["g"], v["b"], v["a"]))
d.putPlainChildren(value)
def qdump__Color_(d, value):
v = value
d.putValue("(%s, %s, %s; %s)" % (v["r"], v["g"], v["b"], v["a"]))
if d.isExpanded():
with Children(d):
with SubItem(d, "0"):
d.putItem(v["r"])
with SubItem(d, "1"):
d.putItem(v["g"])
with SubItem(d, "2"):
d.putItem(v["b"])
with SubItem(d, "3"):
d.putItem(v["a"])
if False:
def qform__basic__Function():
return "Normal,Displayed"
def qdump__basic__Function(d, value):
min = value["min"]
max = value["max"]
data, size, alloc = d.byteArrayData(value["var"])
var = extractCString(data, 0)
data, size, alloc = d.byteArrayData(value["f"])
f = extractCString(data, 0)
d.putValue("%s, %s=%f..%f" % (f, var, min, max))
d.putNumChild(0)
format = d.currentItemFormat()
if format == 1:
d.putDisplay(StopDisplay)
elif format == 2:
input = "plot [%s=%f:%f] %s" % (var, min, max, f)
d.putDisplay(DisplayProcess, input, "gnuplot")
if False:
def qdump__tree_entry(d, value):
d.putValue("len: %s, offset: %s, type: %s" %
(value["blocklength"], value["offset"], value["type"]))
d.putNumChild(0)
def qdump__tree(d, value):
count = value["count"]
entries = value["entries"]
base = value["base"].cast(d.charPtrType())
d.putItemCount(count)
d.putNumChild(count)
if d.isExpanded():
with Children(d):
with SubItem(d, "tree"):
d.putEmptyValue()
d.putNoType()
d.putNumChild(1)
if d.isExpanded():
with Children(d):
for i in xrange(count):
d.putSubItem(Item(entries[i], iname))
with SubItem(d, "data"):
d.putEmptyValue()
d.putNoType()
d.putNumChild(1)
if d.isExpanded():
with Children(d):
for i in xrange(count):
with SubItem(d, i):
entry = entries[i]
mpitype = str(entry["type"])
d.putType(mpitype)
length = int(entry["blocklength"])
offset = int(entry["offset"])
d.putValue("%s items at %s" % (length, offset))
if mpitype == "MPI_INT":
innerType = "int"
elif mpitype == "MPI_CHAR":
innerType = "char"
elif mpitype == "MPI_DOUBLE":
innerType = "double"
else:
length = 0
d.putNumChild(length)
if d.isExpanded():
with Children(d):
t = d.lookupType(innerType).pointer()
p = (base + offset).cast(t)
for j in range(length):
d.putSubItem(j, p.dereference())
#struct KRBase
#{
# enum Type { TYPE_A, TYPE_B } type;
# KRBase(Type _type) : type(_type) {}
#};
#
#struct KRA : KRBase { int x; int y; KRA():KRBase(TYPE_A),x(1),y(32) {} };
#struct KRB : KRBase { KRB():KRBase(TYPE_B) {} };
#
#void testKR()
#{
# KRBase *ptr1 = new KRA;
# KRBase *ptr2 = new KRB;
# ptr2 = new KRB;
#}
def qdump__KRBase(d, value):
if getattr(value, "__nested__", None) is None:
base = ["KRA", "KRB"][int(value["type"])]
nest = value.cast(d.lookupType(base))
nest.__nested__ = True
warn("NEST %s " % dir(nest))
d.putItem(nest)
else:
d.putName("type")
d.putValue(value["type"])
d.putNoType()
if False:
def qdump__bug5106__A5106(d, value):
d.putName("a")
d.putValue("This is the value: %s" % value["m_a"])
d.putNoType()
d.putNumChild(0)
if False:
def qdump__bug6933__Base(d, value):
d.putValue("foo")
d.putPlainChildren(value)
if False:
def qdump__gdb13393__Base(d, value):
d.putValue("Base (%s)" % value["a"])
d.putType(value.type)
d.putPlainChildren(value)
def qdump__gdb13393__Derived(d, value):
d.putValue("Derived (%s, %s)" % (value["a"], value["b"]))
d.putType(value.type)
d.putPlainChildren(value)
def qdump__KDSoapValue1(d, value):
inner = value["d"]["d"].dereference()
d.putStringValue(inner["m_name"])
if d.isExpanded():
with Children(d):
d.putFields(inner)
def qdump__KDSoapValue(d, value):
p = (value.cast(lookupType("char*")) + 4).dereference().cast(lookupType("QString"))
d.putStringValue(p)
if d.isExpanded():
with Children(d):
data = value["d"]["d"].dereference()
d.putFields(data)
File diff suppressed because it is too large Load Diff
+625
View File
@@ -0,0 +1,625 @@
############################################################################
#
# Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
# Contact: http://www.qt-project.org/legal
#
# This file is part of Qt Creator.
#
# Commercial License Usage
# Licensees holding valid commercial Qt licenses may use this file in
# accordance with the commercial license agreement provided with the
# Software or, alternatively, in accordance with the terms contained in
# a written agreement between you and Digia. For licensing terms and
# conditions see http://qt.digia.com/licensing. For further information
# use the contact form at http://qt.digia.com/contact-us.
#
# GNU Lesser General Public License Usage
# Alternatively, this file may be used under the terms of the GNU Lesser
# General Public License version 2.1 as published by the Free Software
# Foundation and appearing in the file LICENSE.LGPL included in the
# packaging of this file. Please review the following information to
# ensure the GNU Lesser General Public License version 2.1 requirements
# will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
#
# In addition, as a special exception, Digia gives you certain additional
# rights. These rights are described in the Digia Qt LGPL Exception
# version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
#
#############################################################################
from dumper import *
def qdump____c_style_array__(d, value):
type = value.type.unqualified()
targetType = value[0].type
#d.putAddress(value.address)
d.putType(type)
d.putNumChild(1)
format = d.currentItemFormat()
isDefault = format == None and str(targetType.unqualified()) == "char"
if isDefault or format == 0 or format == 1 or format == 2:
blob = d.readMemory(value.address, type.sizeof)
if isDefault:
# Use Latin1 as default for char [].
d.putValue(blob, Hex2EncodedLatin1)
elif format == 0:
# Explicitly requested Latin1 formatting.
d.putValue(blob, Hex2EncodedLatin1)
elif format == 1:
# Explicitly requested UTF-8 formatting.
d.putValue(blob, Hex2EncodedUtf8)
elif format == 2:
# Explicitly requested Local 8-bit formatting.
d.putValue(blob, Hex2EncodedLocal8Bit)
else:
d.putValue("@0x%x" % d.pointerValue(value.cast(targetType.pointer())))
if d.currentIName in d.expandedINames:
p = value.address
ts = targetType.sizeof
if not d.tryPutArrayContents(targetType, p, int(type.sizeof / ts)):
with Children(d, childType=targetType,
addrBase=p, addrStep=ts):
d.putFields(value)
def qdump__std__array(d, value):
size = d.numericTemplateArgument(value.type, 1)
d.putItemCount(size)
d.putNumChild(size)
if d.isExpanded():
innerType = d.templateArgument(value.type, 0)
d.putArrayData(innerType, d.addressOf(value), size)
def qdump__std____1__array(d, value):
qdump__std__array(d, value)
def qdump__std__complex(d, value):
innerType = d.templateArgument(value.type, 0)
base = value.address.cast(innerType.pointer())
real = base.dereference()
imag = (base + 1).dereference()
d.putValue("(%f, %f)" % (real, imag));
d.putNumChild(2)
if d.isExpanded():
with Children(d, 2, childType=innerType):
d.putSubItem("real", real)
d.putSubItem("imag", imag)
def qdump__std__deque(d, value):
innerType = d.templateArgument(value.type, 0)
innerSize = innerType.sizeof
bufsize = 1
if innerSize < 512:
bufsize = int(512 / innerSize)
impl = value["_M_impl"]
start = impl["_M_start"]
finish = impl["_M_finish"]
size = bufsize * toInteger(finish["_M_node"] - start["_M_node"] - 1)
size += toInteger(finish["_M_cur"] - finish["_M_first"])
size += toInteger(start["_M_last"] - start["_M_cur"])
d.check(0 <= size and size <= 1000 * 1000 * 1000)
d.putItemCount(size)
d.putNumChild(size)
if d.isExpanded():
with Children(d, size, maxNumChild=2000, childType=innerType):
pcur = start["_M_cur"]
pfirst = start["_M_first"]
plast = start["_M_last"]
pnode = start["_M_node"]
for i in d.childRange():
d.putSubItem(i, pcur.dereference())
pcur += 1
if pcur == plast:
newnode = pnode + 1
pnode = newnode
pfirst = newnode.dereference()
plast = pfirst + bufsize
pcur = pfirst
def qdump__std____debug__deque(d, value):
qdump__std__deque(d, value)
def qdump__std__list(d, value):
head = d.dereferenceValue(value)
impl = value["_M_impl"]
node = impl["_M_node"]
size = 0
pp = d.dereference(head)
while head != pp and size <= 1001:
size += 1
pp = d.dereference(pp)
d.putItemCount(size, 1000)
d.putNumChild(size)
if d.isExpanded():
p = node["_M_next"]
innerType = d.templateArgument(value.type, 0)
with Children(d, size, maxNumChild=1000, childType=innerType):
for i in d.childRange():
innerPointer = innerType.pointer()
d.putSubItem(i, (p + 1).cast(innerPointer).dereference())
p = p["_M_next"]
def qdump__std____debug__list(d, value):
qdump__std__list(d, value)
def qform__std__map():
return mapForms()
def qdump__std__map(d, value):
impl = value["_M_t"]["_M_impl"]
size = int(impl["_M_node_count"])
d.check(0 <= size and size <= 100*1000*1000)
d.putItemCount(size)
d.putNumChild(size)
if d.isExpanded():
keyType = d.templateArgument(value.type, 0)
valueType = d.templateArgument(value.type, 1)
try:
# Does not work on gcc 4.4, the allocator type (fourth template
# argument) seems not to be available.
pairType = d.templateArgument(d.templateArgument(value.type, 3), 0)
pairPointer = pairType.pointer()
except:
# So use this as workaround:
pairType = d.templateArgument(impl.type, 1)
pairPointer = pairType.pointer()
isCompact = d.isMapCompact(keyType, valueType)
innerType = pairType
if isCompact:
innerType = valueType
node = impl["_M_header"]["_M_left"]
childType = innerType
if size == 0:
childType = pairType
childNumChild = 2
if isCompact:
childNumChild = None
with Children(d, size, maxNumChild=1000,
childType=childType, childNumChild=childNumChild):
for i in d.childRange():
with SubItem(d, i):
pair = (node + 1).cast(pairPointer).dereference()
if isCompact:
d.putMapName(pair["first"])
d.putItem(pair["second"])
else:
d.putEmptyValue()
if d.isExpanded():
with Children(d, 2):
d.putSubItem("first", pair["first"])
d.putSubItem("second", pair["second"])
if d.isNull(node["_M_right"]):
parent = node["_M_parent"]
while node == parent["_M_right"]:
node = parent
parent = parent["_M_parent"]
if node["_M_right"] != parent:
node = parent
else:
node = node["_M_right"]
while not d.isNull(node["_M_left"]):
node = node["_M_left"]
def qdump__std____debug__map(d, value):
qdump__std__map(d, value)
def qdump__std____debug__set(d, value):
qdump__std__set(d, value)
def qdump__std____cxx1998__map(d, value):
qdump__std__map(d, value)
def stdTreeIteratorHelper(d, value):
pnode = value["_M_node"]
node = pnode.dereference()
d.putNumChild(1)
d.putEmptyValue()
if d.isExpanded():
dataType = d.templateArgument(value.type, 0)
nodeType = d.lookupType("std::_Rb_tree_node<%s>" % dataType)
data = pnode.cast(nodeType.pointer()).dereference()["_M_value_field"]
with Children(d):
try:
d.putSubItem("first", data["first"])
d.putSubItem("second", data["second"])
except:
d.putSubItem("value", data)
with SubItem(d, "node"):
d.putNumChild(1)
d.putEmptyValue()
d.putType(" ")
if d.isExpanded():
with Children(d):
d.putSubItem("color", node["_M_color"])
d.putSubItem("left", node["_M_left"])
d.putSubItem("right", node["_M_right"])
d.putSubItem("parent", node["_M_parent"])
def qdump__std___Rb_tree_iterator(d, value):
stdTreeIteratorHelper(d, value)
def qdump__std___Rb_tree_const_iterator(d, value):
stdTreeIteratorHelper(d, value)
def qdump__std__map__iterator(d, value):
stdTreeIteratorHelper(d, value)
def qdump____gnu_debug___Safe_iterator(d, value):
d.putItem(value["_M_current"])
def qdump__std__map__const_iterator(d, value):
stdTreeIteratorHelper(d, value)
def qdump__std__set__iterator(d, value):
stdTreeIteratorHelper(d, value)
def qdump__std__set__const_iterator(d, value):
stdTreeIteratorHelper(d, value)
def qdump__std____cxx1998__set(d, value):
qdump__std__set(d, value)
def qdump__std__set(d, value):
impl = value["_M_t"]["_M_impl"]
size = int(impl["_M_node_count"])
d.check(0 <= size and size <= 100*1000*1000)
d.putItemCount(size)
d.putNumChild(size)
if d.isExpanded():
valueType = d.templateArgument(value.type, 0)
node = impl["_M_header"]["_M_left"]
with Children(d, size, maxNumChild=1000, childType=valueType):
for i in d.childRange():
d.putSubItem(i, (node + 1).cast(valueType.pointer()).dereference())
if d.isNull(node["_M_right"]):
parent = node["_M_parent"]
while node == parent["_M_right"]:
node = parent
parent = parent["_M_parent"]
if node["_M_right"] != parent:
node = parent
else:
node = node["_M_right"]
while not d.isNull(node["_M_left"]):
node = node["_M_left"]
def qdump__std__stack(d, value):
qdump__std__deque(d, value["c"])
def qdump__std____debug__stack(d, value):
qdump__std__stack(d, value)
def qform__std__string():
return "Inline,In Separate Window"
def qdump__std__string(d, value):
qdump__std__stringHelper1(d, value, 1)
def qdump__std__stringHelper1(d, value, charSize):
data = value["_M_dataplus"]["_M_p"]
# We can't lookup the std::string::_Rep type without crashing LLDB,
# so hard-code assumption on member position
# struct { size_type _M_length, size_type _M_capacity, int _M_refcount; }
sizePtr = data.cast(d.sizetType().pointer())
size = int(sizePtr[-3])
alloc = int(sizePtr[-2])
refcount = int(sizePtr[-1])
d.check(refcount >= -1) # Can be -1 accoring to docs.
d.check(0 <= size and size <= alloc and alloc <= 100*1000*1000)
qdump_stringHelper(d, sizePtr, size * charSize, charSize)
def qdump_stringHelper(d, data, size, charSize):
cutoff = min(size, qqStringCutOff)
mem = d.readMemory(data, cutoff)
if charSize == 1:
encodingType = Hex2EncodedLatin1
displayType = DisplayLatin1String
elif charSize == 2:
encodingType = Hex4EncodedLittleEndian
displayType = DisplayUtf16String
else:
encodingType = Hex8EncodedLittleEndian
displayType = DisplayUtf16String
d.putNumChild(0)
d.putValue(mem, encodingType)
format = d.currentItemFormat()
if format == 1:
d.putDisplay(StopDisplay)
elif format == 2:
d.putField("editformat", displayType)
d.putField("editvalue", d.readMemory(data, size))
def qdump__std____1__string(d, value):
inner = d.childAt(d.childAt(value["__r_"]["__first_"], 0), 0)
size = int(inner["__size_"])
alloc = int(inner["__cap_"])
data = d.pointerValue(inner["__data_"])
qdump_stringHelper(d, data, size, 1)
d.putType("std::string")
def qdump__std____1__wstring(d, value):
inner = d.childAt(d.childAt(value["__r_"]["__first_"], 0), 0)
size = int(inner["__size_"]) * 4
alloc = int(inner["__cap_"])
data = d.pointerValue(inner["__data_"])
qdump_stringHelper(d, data, size, 4)
d.putType("std::wstring")
def qdump__std__shared_ptr(d, value):
i = value["_M_ptr"]
if d.isNull(i):
d.putValue("(null)")
d.putNumChild(0)
return
if d.isSimpleType(d.templateArgument(value.type, 0)):
d.putValue("%s @0x%x" % (i.dereference(), d.pointerValue(i)))
else:
i = expensiveDowncast(i)
d.putValue("@0x%x" % d.pointerValue(i))
d.putNumChild(3)
with Children(d, 3):
d.putSubItem("data", i)
refcount = value["_M_refcount"]["_M_pi"]
d.putIntItem("usecount", refcount["_M_use_count"])
d.putIntItem("weakcount", refcount["_M_weak_count"])
def qdump__std____1__shared_ptr(d, value):
i = value["__ptr_"]
if d.isNull(i):
d.putValue("(null)")
d.putNumChild(0)
return
if d.isSimpleType(d.templateArgument(value.type, 0)):
d.putValue("%s @0x%x" % (i.dereference().value, d.pointerValue(i)))
else:
d.putValue("@0x%x" % d.pointerValue(i))
d.putNumChild(3)
with Children(d, 3):
d.putSubItem("data", i.dereference())
d.putFields(value["__cntrl_"].dereference())
#d.putIntItem("usecount", refcount["_M_use_count"])
#d.putIntItem("weakcount", refcount["_M_weak_count"])
def qdump__std__unique_ptr(d, value):
i = value["_M_t"]["_M_head_impl"]
if d.isNull(i):
d.putValue("(null)")
d.putNumChild(0)
return
if d.isSimpleType(d.templateArgument(value.type, 0)):
d.putValue("%s @0x%x" % (i.dereference(), d.pointerValue(i)))
else:
i = expensiveDowncast(i)
d.putValue("@0x%x" % d.pointerValue(i))
d.putNumChild(1)
with Children(d, 1):
d.putSubItem("data", i)
def qdump__std____1__unique_ptr(d, value):
i = d.childAt(d.childAt(value["__ptr_"], 0), 0)
if d.isNull(i):
d.putValue("(null)")
d.putNumChild(0)
return
if d.isSimpleType(d.templateArgument(value.type, 0)):
d.putValue("%s @0x%x" % (i.dereference().value, d.pointerValue(i)))
else:
d.putValue("@0x%x" % d.pointerValue(i))
d.putNumChild(1)
with Children(d, 1):
d.putSubItem("data", i.dereference())
def qform__std__unordered_map():
return mapForms()
def qform__std____debug__unordered_map():
return mapForms()
def qdump__std__unordered_map(d, value):
try:
size = value["_M_element_count"]
start = value["_M_before_begin"]["_M_nxt"]
except:
size = value["_M_h"]["_M_element_count"]
start = value["_M_h"]["_M_bbegin"]["_M_node"]["_M_nxt"]
d.putItemCount(size)
d.putNumChild(size)
if d.isExpanded():
p = d.pointerValue(start)
keyType = d.templateArgument(value.type, 0)
valueType = d.templateArgument(value.type, 1)
allocatorType = d.templateArgument(value.type, 4)
pairType = d.templateArgument(allocatorType, 0)
ptrSize = d.ptrSize()
if d.isMapCompact(keyType, valueType):
with Children(d, size, childType=valueType):
for i in d.childRange():
pair = d.createValue(p + ptrSize, pairType)
with SubItem(d, i):
d.putField("iname", d.currentIName)
d.putName("[%s] %s" % (i, pair["first"]))
d.putValue(pair["second"])
p = d.dereference(p)
else:
with Children(d, size, childType=pairType):
for i in d.childRange():
d.putSubItem(i, d.createValue(p + ptrSize, pairType))
p = d.dereference(p)
def qdump__std____debug__unordered_map(d, value):
qdump__std__unordered_map(d, value)
def qdump__std__unordered_set(d, value):
try:
size = value["_M_element_count"]
start = value["_M_before_begin"]["_M_nxt"]
except:
size = value["_M_h"]["_M_element_count"]
start = value["_M_h"]["_M_bbegin"]["_M_node"]["_M_nxt"]
d.putItemCount(size)
d.putNumChild(size)
if d.isExpanded():
p = d.pointerValue(start)
valueType = d.templateArgument(value.type, 0)
with Children(d, size, childType=valueType):
ptrSize = d.ptrSize()
for i in d.childRange():
d.putSubItem(i, d.createValue(p + ptrSize, valueType))
p = d.dereference(p)
def qdump__std____debug__unordered_set(d, value):
qdump__std__unordered_set(d, value)
def qedit__std__vector(expr, value):
values = value.split(',')
n = len(values)
ob = gdb.parse_and_eval(expr)
innerType = d.templateArgument(ob.type, 0)
cmd = "set $d = (%s*)calloc(sizeof(%s)*%s,1)" % (innerType, innerType, n)
gdb.execute(cmd)
cmd = "set {void*[3]}%s = {$d, $d+%s, $d+%s}" % (ob.address, n, n)
gdb.execute(cmd)
cmd = "set (%s[%d])*$d={%s}" % (innerType, n, value)
gdb.execute(cmd)
def qdump__std__vector(d, value):
impl = value["_M_impl"]
type = d.templateArgument(value.type, 0)
alloc = impl["_M_end_of_storage"]
isBool = str(type) == 'bool'
if isBool:
start = impl["_M_start"]["_M_p"]
finish = impl["_M_finish"]["_M_p"]
# FIXME: 8 is CHAR_BIT
storage = d.lookupType("unsigned long")
storagesize = storage.sizeof * 8
size = (finish - start) * storagesize
size += impl["_M_finish"]["_M_offset"]
size -= impl["_M_start"]["_M_offset"]
else:
start = impl["_M_start"]
finish = impl["_M_finish"]
size = finish - start
d.check(0 <= size and size <= 1000 * 1000 * 1000)
d.check(finish <= alloc)
d.checkPointer(start)
d.checkPointer(finish)
d.checkPointer(alloc)
d.putItemCount(size)
d.putNumChild(size)
if d.isExpanded():
if isBool:
with Children(d, size, maxNumChild=10000, childType=type):
for i in d.childRange():
q = start + int(i / storagesize)
d.putBoolItem(str(i), (q.dereference() >> (i % storagesize)) & 1)
else:
d.putArrayData(type, start, size)
def qdump__std____1__vector(d, value):
innerType = d.templateArgument(value.type, 0)
if d.isLldb and d.childAt(value, 0).type == innerType:
# That's old lldb automatically formatting
begin = d.dereferenceValue(value)
size = value.GetNumChildren()
else:
# Normal case
begin = d.pointerValue(value['__begin_'])
end = d.pointerValue(value['__end_'])
size = (end - begin) / innerType.sizeof
d.putItemCount(size)
d.putNumChild(size)
if d.isExpanded():
d.putArrayData(innerType, begin, size)
def qdump__std____debug__vector(d, value):
qdump__std__vector(d, value)
def qedit__std__string(expr, value):
cmd = "print (%s).assign(\"%s\")" % (expr, value)
gdb.execute(cmd)
def qedit__string(expr, value):
qedit__std__string(expr, value)
def qdump__string(d, value):
qdump__std__string(d, value)
def qdump__std__wstring(d, value):
charSize = d.lookupType('wchar_t').sizeof
qdump__std__stringHelper1(d, value, charSize)
def qdump__std__basic_string(d, value):
innerType = d.templateArgument(value.type, 0)
qdump__std__stringHelper1(d, value, innerType.sizeof)
def qdump__wstring(d, value):
qdump__std__wstring(d, value)
def qdump____gnu_cxx__hash_set(d, value):
ht = value["_M_ht"]
size = int(ht["_M_num_elements"])
d.check(0 <= size and size <= 1000 * 1000 * 1000)
d.putItemCount(size)
d.putNumChild(size)
type = d.templateArgument(value.type, 0)
d.putType("__gnu__cxx::hash_set<%s>" % type)
if d.isExpanded():
with Children(d, size, maxNumChild=1000, childType=type):
buckets = ht["_M_buckets"]["_M_impl"]
bucketStart = buckets["_M_start"]
bucketFinish = buckets["_M_finish"]
p = bucketStart
itemCount = 0
for i in xrange(toInteger(bucketFinish - bucketStart)):
if not d.isNull(p.dereference()):
cur = p.dereference()
while not d.isNull(cur):
with SubItem(d, itemCount):
d.putValue(cur["_M_val"])
cur = cur["_M_next"]
itemCount += 1
p = p + 1
def qdump__uint8_t(d, value):
d.putNumChild(0)
d.putValue(int(value))
def qdump__int8_t(d, value):
d.putNumChild(0)
d.putValue(int(value))