forked from qt-creator/qt-creator
Debugger: improve std::unordered_map dumper for cdb
and fix dumper tests Change-Id: I1debd25a835aba28d77e5605dc49a5ea01221995 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -872,43 +872,58 @@ def qform__std____debug__unordered_map():
|
||||
|
||||
|
||||
def qdump__std__unordered_map(d, value):
|
||||
if d.isQnxTarget() or d.isMsvcTarget():
|
||||
if d.isQnxTarget():
|
||||
qdump__std__list__QNX(d, value["_List"])
|
||||
return
|
||||
|
||||
try:
|
||||
# gcc ~= 4.7
|
||||
size = value["_M_element_count"].integer()
|
||||
start = value["_M_before_begin"]["_M_nxt"]
|
||||
except:
|
||||
if d.isMsvcTarget():
|
||||
_list = value["_List"]
|
||||
try:
|
||||
# libc++ (Mac)
|
||||
size = value["_M_h"]["_M_element_count"].integer()
|
||||
start = value["_M_h"]["_M_bbegin"]["_M_node"]["_M_nxt"]
|
||||
_ = _list["_Mypair"]["_Myval2"]["_Myproxy"]
|
||||
(_, start, size) = _list.split("ppp")
|
||||
except Exception:
|
||||
(start, size) = _list.split("pp")
|
||||
else:
|
||||
try:
|
||||
# gcc ~= 4.7
|
||||
size = value["_M_element_count"].integer()
|
||||
start = value["_M_before_begin"]["_M_nxt"]
|
||||
except:
|
||||
try:
|
||||
# gcc 4.9.1
|
||||
# libc++ (Mac)
|
||||
size = value["_M_h"]["_M_element_count"].integer()
|
||||
start = value["_M_h"]["_M_before_begin"]["_M_nxt"]
|
||||
start = value["_M_h"]["_M_bbegin"]["_M_node"]["_M_nxt"]
|
||||
except:
|
||||
# gcc 4.6.2
|
||||
size = value["_M_element_count"].integer()
|
||||
start = value["_M_buckets"].dereference()
|
||||
# FIXME: Pointer-aligned?
|
||||
d.putItemCount(size)
|
||||
# We don't know where the data is
|
||||
d.putNumChild(0)
|
||||
return
|
||||
try:
|
||||
# gcc 4.9.1
|
||||
size = value["_M_h"]["_M_element_count"].integer()
|
||||
start = value["_M_h"]["_M_before_begin"]["_M_nxt"]
|
||||
except:
|
||||
# gcc 4.6.2
|
||||
size = value["_M_element_count"].integer()
|
||||
start = value["_M_buckets"].dereference()
|
||||
# FIXME: Pointer-aligned?
|
||||
d.putItemCount(size)
|
||||
# We don't know where the data is
|
||||
d.putNumChild(0)
|
||||
return
|
||||
|
||||
d.putItemCount(size)
|
||||
if d.isExpanded():
|
||||
keyType = value.type[0]
|
||||
valueType = value.type[1]
|
||||
typeCode = 'p@{%s}@{%s}' % (value.type[0].name, value.type[1].name)
|
||||
p = start.pointer()
|
||||
if d.isMsvcTarget():
|
||||
typeCode = 'pp@{%s}@{%s}' % (keyType.name, valueType.name)
|
||||
p = d.extractPointer(start)
|
||||
else:
|
||||
typeCode = 'p@{%s}@{%s}' % (keyType.name, valueType.name)
|
||||
p = start.pointer()
|
||||
with Children(d, size):
|
||||
for i in d.childRange():
|
||||
p, pad, key, pad, val = d.split(typeCode, p)
|
||||
if d.isMsvcTarget():
|
||||
p, _, _, key, _, val = d.split(typeCode, p)
|
||||
else:
|
||||
p, _, key, _, val = d.split(typeCode, p)
|
||||
d.putPairItem(i, (key, val))
|
||||
|
||||
|
||||
|
@@ -5466,8 +5466,8 @@ void tst_Dumpers::dumper_data()
|
||||
+ Check("map1", "<2 items>", "std::unordered_map<unsigned int, unsigned int>")
|
||||
+ Check("map1.0", "[0] 22", "2", "") % NoCdbEngine
|
||||
+ Check("map1.1", "[1] 11", "1", "") % NoCdbEngine
|
||||
+ Check("map1.0", "11", "1", "std::pair<unsigned int const ,unsigned int>") % CdbEngine
|
||||
+ Check("map1.1", "22", "2", "std::pair<unsigned int const ,unsigned int>") % CdbEngine
|
||||
+ Check("map1.0", "[0] 11", "1", "") % CdbEngine
|
||||
+ Check("map1.1", "[1] 22", "2", "") % CdbEngine
|
||||
|
||||
+ Check("map2", "<2 items>", "std::unordered_map<std::string, float>")
|
||||
+ Check("map2.0", "[0] \"22.0\"", FloatValue("22.0"), "") % NoCdbEngine
|
||||
@@ -5476,20 +5476,18 @@ void tst_Dumpers::dumper_data()
|
||||
+ Check("map2.1", "[1] \"11.0\"", FloatValue("11.0"), "") % NoCdbEngine
|
||||
+ Check("map2.1.first", "\"11.0\"", "std::string") % NoCdbEngine
|
||||
+ Check("map2.1.second", FloatValue("11"), "float") % NoCdbEngine
|
||||
+ Check("map2.0", "\"11.0\"", FloatValue("11.0"),
|
||||
"std::pair<std::string, float>") % CdbEngine
|
||||
+ Check("map2.0.first", "\"11.0\"", "std::string") % CdbEngine
|
||||
+ Check("map2.0.second", FloatValue("11"), "float") % CdbEngine
|
||||
+ Check("map2.1", "\"22.0\"", FloatValue("22.0"),
|
||||
"std::pair<std::string, float>") % CdbEngine
|
||||
+ Check("map2.1.first", "\"22.0\"", "std::string") % CdbEngine
|
||||
+ Check("map2.1.second", FloatValue("22"), "float") % CdbEngine
|
||||
+ Check("map2.0", "[0] \"11.0\"", FloatValue("11.0"), "") % CdbEngine
|
||||
+ Check("map2.0.first", "\"11.0\"", "std::string") % CdbEngine
|
||||
+ Check("map2.0.second", FloatValue("11"), "float") % CdbEngine
|
||||
+ Check("map2.1", "[1] \"22.0\"", FloatValue("22.0"), "") % CdbEngine
|
||||
+ Check("map2.1.first", "\"22.0\"", "std::string") % CdbEngine
|
||||
+ Check("map2.1.second", FloatValue("22"), "float") % CdbEngine
|
||||
|
||||
+ Check("map3", "<2 items>", "std::unordered_multimap<int, std::string>")
|
||||
+ Check("map3.0", "[0] 1", "\"Bar\"", "") % NoCdbEngine
|
||||
+ Check("map3.1", "[1] 1", "\"Foo\"", "") % NoCdbEngine
|
||||
+ Check("map3.0", "1", "\"Foo\"", "std::pair<int const ,std::string>") % CdbEngine
|
||||
+ Check("map3.1", "1", "\"Bar\"", "std::pair<int const ,std::string>") % CdbEngine;
|
||||
+ Check("map3.0", "[0] 1", "\"Foo\"", "") % CdbEngine
|
||||
+ Check("map3.1", "[1] 1", "\"Bar\"", "") % CdbEngine;
|
||||
|
||||
|
||||
QTest::newRow("StdUnorderedSet")
|
||||
|
Reference in New Issue
Block a user