forked from qt-creator/qt-creator
Pretty printers: Unify code for different allocators
The code path for allocators other than 'std::allocator' does work for 'std::allocator' as well, so unify this. This also fixes the case of std containers when 'std::allocator' is used and the compiler flag '-D_GLIBCXX_DEBUG' in place which results in size assumptions that were made in the now dropped path to not be fulfilled, thus leading to an incorrect display. Fixes: QTCREATORBUG-22606 Change-Id: I2b6f8ac9933b210d26197975017292e2fc227541 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -953,43 +953,27 @@ def qdumpHelper__std__vector(d, value, isLibCpp):
|
|||||||
innerType = value.type[0]
|
innerType = value.type[0]
|
||||||
isBool = innerType.name == 'bool'
|
isBool = innerType.name == 'bool'
|
||||||
|
|
||||||
try:
|
|
||||||
allocator = value.type[1].name
|
|
||||||
except:
|
|
||||||
allocator = ''
|
|
||||||
|
|
||||||
isStdAllocator = allocator == 'std::allocator<%s>' % innerType.name
|
|
||||||
|
|
||||||
if isBool:
|
if isBool:
|
||||||
if isLibCpp:
|
if isLibCpp:
|
||||||
if isStdAllocator:
|
start = value["__begin_"].pointer()
|
||||||
(start, size) = value.split("pp") # start is 'unsigned long *'
|
size = value["__size_"]
|
||||||
else:
|
|
||||||
start = value["__begin_"].pointer()
|
|
||||||
size = value["__size_"]
|
|
||||||
alloc = size
|
alloc = size
|
||||||
else:
|
else:
|
||||||
if isStdAllocator:
|
start = value["_M_start"]["_M_p"].pointer()
|
||||||
(start, soffset, pad, finish, foffset, pad, alloc) = value.split("pI@pI@p")
|
soffset = value["_M_start"]["_M_offset"].integer()
|
||||||
else:
|
finish = value["_M_finish"]["_M_p"].pointer()
|
||||||
start = value["_M_start"]["_M_p"].pointer()
|
foffset = value["_M_finish"]["_M_offset"].integer()
|
||||||
soffset = value["_M_start"]["_M_offset"].integer()
|
alloc = value["_M_end_of_storage"].pointer()
|
||||||
finish = value["_M_finish"]["_M_p"].pointer()
|
|
||||||
foffset = value["_M_finish"]["_M_offset"].integer()
|
|
||||||
alloc = value["_M_end_of_storage"].pointer()
|
|
||||||
size = (finish - start) * 8 + foffset - soffset # 8 is CHAR_BIT.
|
size = (finish - start) * 8 + foffset - soffset # 8 is CHAR_BIT.
|
||||||
else:
|
else:
|
||||||
if isStdAllocator:
|
if isLibCpp:
|
||||||
(start, finish, alloc) = value.split("ppp")
|
start = value["__begin_"].pointer()
|
||||||
|
finish = value["__end_"].pointer()
|
||||||
|
alloc = value["__end_cap_"].pointer()
|
||||||
else:
|
else:
|
||||||
if isLibCpp:
|
start = value["_M_start"].pointer()
|
||||||
start = value["__begin_"].pointer()
|
finish = value["_M_finish"].pointer()
|
||||||
finish = value["__end_"].pointer()
|
alloc = value["_M_end_of_storage"].pointer()
|
||||||
alloc = value["__end_cap_"].pointer()
|
|
||||||
else:
|
|
||||||
start = value["_M_start"].pointer()
|
|
||||||
finish = value["_M_finish"].pointer()
|
|
||||||
alloc = value["_M_end_of_storage"].pointer()
|
|
||||||
size = int((finish - start) / innerType.size())
|
size = int((finish - start) / innerType.size())
|
||||||
d.check(finish <= alloc)
|
d.check(finish <= alloc)
|
||||||
if size > 0:
|
if size > 0:
|
||||||
@@ -1088,19 +1072,12 @@ def qdump__std__basic_string(d, value):
|
|||||||
def qdump__std____cxx11__basic_string(d, value):
|
def qdump__std____cxx11__basic_string(d, value):
|
||||||
innerType = value.type[0]
|
innerType = value.type[0]
|
||||||
try:
|
try:
|
||||||
allocator = value.type[2].name
|
data = value["_M_dataplus"]["_M_p"].pointer()
|
||||||
|
size = int(value["_M_string_length"])
|
||||||
except:
|
except:
|
||||||
allocator = ''
|
d.putEmptyValue()
|
||||||
if allocator == 'std::allocator<%s>' % innerType.name:
|
d.putPlainChildren(value)
|
||||||
(data, size) = value.split("pI")
|
return
|
||||||
else:
|
|
||||||
try:
|
|
||||||
data = value["_M_dataplus"]["_M_p"].pointer()
|
|
||||||
size = int(value["_M_string_length"])
|
|
||||||
except:
|
|
||||||
d.putEmptyValue()
|
|
||||||
d.putPlainChildren(value)
|
|
||||||
return
|
|
||||||
d.check(0 <= size) #and size <= alloc and alloc <= 100*1000*1000)
|
d.check(0 <= size) #and size <= alloc and alloc <= 100*1000*1000)
|
||||||
d.putCharArrayHelper(data, size, innerType, d.currentItemFormat())
|
d.putCharArrayHelper(data, size, innerType, d.currentItemFormat())
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user