forked from qt-creator/qt-creator
Debugger: Rename byteArrayDataHelper to qArrayDataHelper in dumpers
It's generic, and operating on QArrayData (-subclasses). Change-Id: Ieedc0f1e3f573aeeb422eb9516d4634e6e0da4b9 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -298,7 +298,7 @@ def qdump__CPlusPlus__Token(d, value):
|
|||||||
|
|
||||||
|
|
||||||
def qdump__CPlusPlus__Internal__PPToken(d, value):
|
def qdump__CPlusPlus__Internal__PPToken(d, value):
|
||||||
data, size, alloc = d.byteArrayData(value["m_src"])
|
data, size, alloc = d.qArrayData(value["m_src"])
|
||||||
length = value["f"]["utf16chars"].integer()
|
length = value["f"]["utf16chars"].integer()
|
||||||
offset = value["utf16charOffset"].integer()
|
offset = value["utf16charOffset"].integer()
|
||||||
#DumperBase.warn("size: %s, alloc: %s, offset: %s, length: %s, data: %s"
|
#DumperBase.warn("size: %s, alloc: %s, offset: %s, length: %s, data: %s"
|
||||||
|
@@ -570,17 +570,17 @@ class DumperBase():
|
|||||||
self.check(0 <= size and size <= alloc and alloc <= 1000 * 1000 * 1000)
|
self.check(0 <= size and size <= alloc and alloc <= 1000 * 1000 * 1000)
|
||||||
return data, size, alloc
|
return data, size, alloc
|
||||||
|
|
||||||
def byteArrayDataHelper(self, bytearray_data_ptr):
|
def qArrayDataHelper(self, array_data_ptr):
|
||||||
# bytearray_data_ptr is what is e.g. stored in a QByteArray's d_ptr.
|
# array_data_ptr is what is e.g. stored in a QByteArray's d_ptr.
|
||||||
if self.qtVersion() >= 0x050000:
|
if self.qtVersion() >= 0x050000:
|
||||||
# QTypedArray:
|
# QTypedArray:
|
||||||
# - QtPrivate::RefCount ref
|
# - QtPrivate::RefCount ref
|
||||||
# - int size
|
# - int size
|
||||||
# - uint alloc : 31, capacityReserved : 1
|
# - uint alloc : 31, capacityReserved : 1
|
||||||
# - qptrdiff offset
|
# - qptrdiff offset
|
||||||
(ref, size, alloc, offset) = self.split('IIpp', bytearray_data_ptr)
|
(ref, size, alloc, offset) = self.split('IIpp', array_data_ptr)
|
||||||
alloc = alloc & 0x7ffffff
|
alloc = alloc & 0x7ffffff
|
||||||
data = bytearray_data_ptr + offset
|
data = array_data_ptr + offset
|
||||||
if self.ptrSize() == 4:
|
if self.ptrSize() == 4:
|
||||||
data = data & 0xffffffff
|
data = data & 0xffffffff
|
||||||
else:
|
else:
|
||||||
@@ -592,19 +592,19 @@ class DumperBase():
|
|||||||
# - [padding]
|
# - [padding]
|
||||||
# - char *data;
|
# - char *data;
|
||||||
if self.ptrSize() == 4:
|
if self.ptrSize() == 4:
|
||||||
(ref, alloc, size, data) = self.split('IIIp', bytearray_data_ptr)
|
(ref, alloc, size, data) = self.split('IIIp', array_data_ptr)
|
||||||
else:
|
else:
|
||||||
(ref, alloc, size, pad, data) = self.split('IIIIp', bytearray_data_ptr)
|
(ref, alloc, size, pad, data) = self.split('IIIIp', array_data_ptr)
|
||||||
else:
|
else:
|
||||||
# Data:
|
# Data:
|
||||||
# - QShared count;
|
# - QShared count;
|
||||||
# - QChar *unicode
|
# - QChar *unicode
|
||||||
# - char *ascii
|
# - char *ascii
|
||||||
# - uint len: 30
|
# - uint len: 30
|
||||||
(dummy, dummy, dummy, size) = self.split('IIIp', bytearray_data_ptr)
|
(dummy, dummy, dummy, size) = self.split('IIIp', array_data_ptr)
|
||||||
size = self.extractInt(bytearray_data_ptr + 3 * self.ptrSize()) & 0x3ffffff
|
size = self.extractInt(array_data_ptr + 3 * self.ptrSize()) & 0x3ffffff
|
||||||
alloc = size # pretend.
|
alloc = size # pretend.
|
||||||
data = self.extractPointer(bytearray_data_ptr + self.ptrSize())
|
data = self.extractPointer(array_data_ptr + self.ptrSize())
|
||||||
return data, size, alloc
|
return data, size, alloc
|
||||||
|
|
||||||
# addr is the begin of a QByteArrayData structure
|
# addr is the begin of a QByteArrayData structure
|
||||||
@@ -613,14 +613,14 @@ class DumperBase():
|
|||||||
# of inferior calls
|
# of inferior calls
|
||||||
if addr == 0:
|
if addr == 0:
|
||||||
return 0, ''
|
return 0, ''
|
||||||
data, size, alloc = self.byteArrayDataHelper(addr)
|
data, size, alloc = self.qArrayDataHelper(addr)
|
||||||
if alloc != 0:
|
if alloc != 0:
|
||||||
self.check(0 <= size and size <= alloc and alloc <= 100 * 1000 * 1000)
|
self.check(0 <= size and size <= alloc and alloc <= 100 * 1000 * 1000)
|
||||||
elided, shown = self.computeLimit(size, limit)
|
elided, shown = self.computeLimit(size, limit)
|
||||||
return elided, self.readMemory(data, 2 * shown)
|
return elided, self.readMemory(data, 2 * shown)
|
||||||
|
|
||||||
def encodeByteArrayHelper(self, addr, limit):
|
def encodeByteArrayHelper(self, addr, limit):
|
||||||
data, size, alloc = self.byteArrayDataHelper(addr)
|
data, size, alloc = self.qArrayDataHelper(addr)
|
||||||
if alloc != 0:
|
if alloc != 0:
|
||||||
self.check(0 <= size and size <= alloc and alloc <= 100 * 1000 * 1000)
|
self.check(0 <= size and size <= alloc and alloc <= 100 * 1000 * 1000)
|
||||||
elided, shown = self.computeLimit(size, limit)
|
elided, shown = self.computeLimit(size, limit)
|
||||||
@@ -673,8 +673,8 @@ class DumperBase():
|
|||||||
elided, data = self.encodeByteArrayHelper(self.extractPointer(value), limit)
|
elided, data = self.encodeByteArrayHelper(self.extractPointer(value), limit)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def byteArrayData(self, value):
|
def qArrayData(self, value):
|
||||||
return self.byteArrayDataHelper(self.extractPointer(value))
|
return self.qArrayDataHelper(self.extractPointer(value))
|
||||||
|
|
||||||
def putByteArrayValue(self, value):
|
def putByteArrayValue(self, value):
|
||||||
elided, data = self.encodeByteArrayHelper(
|
elided, data = self.encodeByteArrayHelper(
|
||||||
@@ -708,7 +708,7 @@ class DumperBase():
|
|||||||
alloc = size
|
alloc = size
|
||||||
return data, size, alloc
|
return data, size, alloc
|
||||||
else:
|
else:
|
||||||
return self.byteArrayDataHelper(self.extractPointer(value))
|
return self.qArrayData(value)
|
||||||
|
|
||||||
def extractTemplateArgument(self, typename, position):
|
def extractTemplateArgument(self, typename, position):
|
||||||
level = 0
|
level = 0
|
||||||
@@ -1479,7 +1479,7 @@ class DumperBase():
|
|||||||
# - QString objectName
|
# - QString objectName
|
||||||
objectName = self.extractPointer(extra + 5 * ptrSize)
|
objectName = self.extractPointer(extra + 5 * ptrSize)
|
||||||
|
|
||||||
data, size, alloc = self.byteArrayDataHelper(objectName)
|
data, size, alloc = self.qArrayDataHelper(objectName)
|
||||||
|
|
||||||
# Object names are short, and GDB can crash on to big chunks.
|
# Object names are short, and GDB can crash on to big chunks.
|
||||||
# Since this here is a convenience feature only, limit it.
|
# Since this here is a convenience feature only, limit it.
|
||||||
@@ -1769,7 +1769,7 @@ class DumperBase():
|
|||||||
if revision >= 7: # Qt 5.
|
if revision >= 7: # Qt 5.
|
||||||
byteArrayDataSize = 24 if ptrSize == 8 else 16
|
byteArrayDataSize = 24 if ptrSize == 8 else 16
|
||||||
literal = stringdata + toInteger(index) * byteArrayDataSize
|
literal = stringdata + toInteger(index) * byteArrayDataSize
|
||||||
ldata, lsize, lalloc = self.byteArrayDataHelper(literal)
|
ldata, lsize, lalloc = self.qArrayDataHelper(literal)
|
||||||
try:
|
try:
|
||||||
s = struct.unpack_from('%ds' % lsize, self.readRawMemory(ldata, lsize))[0]
|
s = struct.unpack_from('%ds' % lsize, self.readRawMemory(ldata, lsize))[0]
|
||||||
return s if sys.version_info[0] == 2 else s.decode('utf8')
|
return s if sys.version_info[0] == 2 else s.decode('utf8')
|
||||||
|
@@ -62,7 +62,7 @@ def qdump__QByteArray(d, value):
|
|||||||
else: # fromRawData
|
else: # fromRawData
|
||||||
alloc = size
|
alloc = size
|
||||||
else:
|
else:
|
||||||
data, size, alloc = d.byteArrayData(value)
|
data, size, alloc = d.qArrayData(value)
|
||||||
|
|
||||||
d.check(alloc == 0 or (0 <= size and size <= alloc and alloc <= 100000000))
|
d.check(alloc == 0 or (0 <= size and size <= alloc and alloc <= 100000000))
|
||||||
if size > 0:
|
if size > 0:
|
||||||
@@ -90,7 +90,7 @@ def qdump__QByteArray(d, value):
|
|||||||
|
|
||||||
|
|
||||||
def qdump__QArrayData(d, value):
|
def qdump__QArrayData(d, value):
|
||||||
data, size, alloc = d.byteArrayDataHelper(value.address())
|
data, size, alloc = d.qArrayDataHelper(value.address())
|
||||||
d.check(alloc == 0 or (0 <= size and size <= alloc and alloc <= 100000000))
|
d.check(alloc == 0 or (0 <= size and size <= alloc and alloc <= 100000000))
|
||||||
d.putValue(d.readMemory(data, size), 'latin1')
|
d.putValue(d.readMemory(data, size), 'latin1')
|
||||||
d.putPlainChildren(value)
|
d.putPlainChildren(value)
|
||||||
@@ -104,7 +104,7 @@ def qdump__QBitArray(d, value):
|
|||||||
if d.qtVersion() >= 0x60000:
|
if d.qtVersion() >= 0x60000:
|
||||||
_, data, basize = value.split('ppi')
|
_, data, basize = value.split('ppi')
|
||||||
else:
|
else:
|
||||||
data, basize, _ = d.byteArrayDataHelper(d.extractPointer(value['d']))
|
data, basize, _ = d.qArrayData(value['d'])
|
||||||
unused = d.extractByte(data) if data else 0
|
unused = d.extractByte(data) if data else 0
|
||||||
size = basize * 8 - unused
|
size = basize * 8 - unused
|
||||||
d.putItemCount(size)
|
d.putItemCount(size)
|
||||||
@@ -3158,7 +3158,7 @@ def qdumpHelper_QCbor_string(d, container_ptr, element_index, is_bytes):
|
|||||||
element_at_n_addr = elements_data_ptr + element_index * 16 # sizeof(QtCbor::Element) == 15
|
element_at_n_addr = elements_data_ptr + element_index * 16 # sizeof(QtCbor::Element) == 15
|
||||||
element_value, _, element_flags = d.split('qII', element_at_n_addr)
|
element_value, _, element_flags = d.split('qII', element_at_n_addr)
|
||||||
enc = 'latin1' if is_bytes or (element_flags & 8) else 'utf16'
|
enc = 'latin1' if is_bytes or (element_flags & 8) else 'utf16'
|
||||||
bytedata, _, _ = d.byteArrayDataHelper(data_d_ptr)
|
bytedata, _, _ = d.qArrayDataHelper(data_d_ptr)
|
||||||
bytedata += element_value
|
bytedata += element_value
|
||||||
if d.qtVersion() >= 0x060000:
|
if d.qtVersion() >= 0x060000:
|
||||||
bytedata_len = d.extractInt64(bytedata)
|
bytedata_len = d.extractInt64(bytedata)
|
||||||
@@ -3193,7 +3193,7 @@ def qdumpHelper_QCbor_array(d, container_ptr, is_cbor):
|
|||||||
elements_data_ptr, elements_size, _ = d.vectorDataHelper(elements_d_ptr)
|
elements_data_ptr, elements_size, _ = d.vectorDataHelper(elements_d_ptr)
|
||||||
d.putItemCount(elements_size)
|
d.putItemCount(elements_size)
|
||||||
if d.isExpanded():
|
if d.isExpanded():
|
||||||
bytedata, _, _ = d.byteArrayDataHelper(data_d_ptr)
|
bytedata, _, _ = d.qArrayDataHelper(data_d_ptr)
|
||||||
with Children(d, maxNumChild=1000):
|
with Children(d, maxNumChild=1000):
|
||||||
for i in range(elements_size):
|
for i in range(elements_size):
|
||||||
d.putSubItem(i, qdumpHelper_QCborArray_valueAt(d, container_ptr, elements_data_ptr, i, bytedata, is_cbor))
|
d.putSubItem(i, qdumpHelper_QCborArray_valueAt(d, container_ptr, elements_data_ptr, i, bytedata, is_cbor))
|
||||||
@@ -3215,7 +3215,7 @@ def qdumpHelper_QCbor_map(d, container_ptr, is_cbor):
|
|||||||
elements_size = int(elements_size / 2)
|
elements_size = int(elements_size / 2)
|
||||||
d.putItemCount(elements_size)
|
d.putItemCount(elements_size)
|
||||||
if d.isExpanded():
|
if d.isExpanded():
|
||||||
bytedata, _, _ = d.byteArrayDataHelper(data_d_ptr)
|
bytedata, _, _ = d.qArrayDataHelper(data_d_ptr)
|
||||||
with Children(d, maxNumChild=1000):
|
with Children(d, maxNumChild=1000):
|
||||||
for i in range(elements_size):
|
for i in range(elements_size):
|
||||||
key = qdumpHelper_QCborArray_valueAt(d, container_ptr, elements_data_ptr, 2 * i, bytedata, is_cbor)
|
key = qdumpHelper_QCborArray_valueAt(d, container_ptr, elements_data_ptr, 2 * i, bytedata, is_cbor)
|
||||||
|
Reference in New Issue
Block a user