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):
|
def qdump__std__unordered_map(d, value):
|
||||||
if d.isQnxTarget() or d.isMsvcTarget():
|
if d.isQnxTarget():
|
||||||
qdump__std__list__QNX(d, value["_List"])
|
qdump__std__list__QNX(d, value["_List"])
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
if d.isMsvcTarget():
|
||||||
# gcc ~= 4.7
|
_list = value["_List"]
|
||||||
size = value["_M_element_count"].integer()
|
|
||||||
start = value["_M_before_begin"]["_M_nxt"]
|
|
||||||
except:
|
|
||||||
try:
|
try:
|
||||||
# libc++ (Mac)
|
_ = _list["_Mypair"]["_Myval2"]["_Myproxy"]
|
||||||
size = value["_M_h"]["_M_element_count"].integer()
|
(_, start, size) = _list.split("ppp")
|
||||||
start = value["_M_h"]["_M_bbegin"]["_M_node"]["_M_nxt"]
|
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:
|
except:
|
||||||
try:
|
try:
|
||||||
# gcc 4.9.1
|
# libc++ (Mac)
|
||||||
size = value["_M_h"]["_M_element_count"].integer()
|
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:
|
except:
|
||||||
# gcc 4.6.2
|
try:
|
||||||
size = value["_M_element_count"].integer()
|
# gcc 4.9.1
|
||||||
start = value["_M_buckets"].dereference()
|
size = value["_M_h"]["_M_element_count"].integer()
|
||||||
# FIXME: Pointer-aligned?
|
start = value["_M_h"]["_M_before_begin"]["_M_nxt"]
|
||||||
d.putItemCount(size)
|
except:
|
||||||
# We don't know where the data is
|
# gcc 4.6.2
|
||||||
d.putNumChild(0)
|
size = value["_M_element_count"].integer()
|
||||||
return
|
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)
|
d.putItemCount(size)
|
||||||
if d.isExpanded():
|
if d.isExpanded():
|
||||||
keyType = value.type[0]
|
keyType = value.type[0]
|
||||||
valueType = value.type[1]
|
valueType = value.type[1]
|
||||||
typeCode = 'p@{%s}@{%s}' % (value.type[0].name, value.type[1].name)
|
if d.isMsvcTarget():
|
||||||
p = start.pointer()
|
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):
|
with Children(d, size):
|
||||||
for i in d.childRange():
|
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))
|
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", "<2 items>", "std::unordered_map<unsigned int, unsigned int>")
|
||||||
+ Check("map1.0", "[0] 22", "2", "") % NoCdbEngine
|
+ Check("map1.0", "[0] 22", "2", "") % NoCdbEngine
|
||||||
+ Check("map1.1", "[1] 11", "1", "") % NoCdbEngine
|
+ Check("map1.1", "[1] 11", "1", "") % NoCdbEngine
|
||||||
+ Check("map1.0", "11", "1", "std::pair<unsigned int const ,unsigned int>") % CdbEngine
|
+ Check("map1.0", "[0] 11", "1", "") % CdbEngine
|
||||||
+ Check("map1.1", "22", "2", "std::pair<unsigned int const ,unsigned int>") % CdbEngine
|
+ Check("map1.1", "[1] 22", "2", "") % CdbEngine
|
||||||
|
|
||||||
+ Check("map2", "<2 items>", "std::unordered_map<std::string, float>")
|
+ Check("map2", "<2 items>", "std::unordered_map<std::string, float>")
|
||||||
+ Check("map2.0", "[0] \"22.0\"", FloatValue("22.0"), "") % NoCdbEngine
|
+ 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", "[1] \"11.0\"", FloatValue("11.0"), "") % NoCdbEngine
|
||||||
+ Check("map2.1.first", "\"11.0\"", "std::string") % NoCdbEngine
|
+ Check("map2.1.first", "\"11.0\"", "std::string") % NoCdbEngine
|
||||||
+ Check("map2.1.second", FloatValue("11"), "float") % NoCdbEngine
|
+ Check("map2.1.second", FloatValue("11"), "float") % NoCdbEngine
|
||||||
+ Check("map2.0", "\"11.0\"", FloatValue("11.0"),
|
+ Check("map2.0", "[0] \"11.0\"", FloatValue("11.0"), "") % CdbEngine
|
||||||
"std::pair<std::string, float>") % CdbEngine
|
+ Check("map2.0.first", "\"11.0\"", "std::string") % CdbEngine
|
||||||
+ Check("map2.0.first", "\"11.0\"", "std::string") % CdbEngine
|
+ Check("map2.0.second", FloatValue("11"), "float") % CdbEngine
|
||||||
+ Check("map2.0.second", FloatValue("11"), "float") % CdbEngine
|
+ Check("map2.1", "[1] \"22.0\"", FloatValue("22.0"), "") % CdbEngine
|
||||||
+ Check("map2.1", "\"22.0\"", FloatValue("22.0"),
|
+ Check("map2.1.first", "\"22.0\"", "std::string") % CdbEngine
|
||||||
"std::pair<std::string, float>") % CdbEngine
|
+ Check("map2.1.second", FloatValue("22"), "float") % 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", "<2 items>", "std::unordered_multimap<int, std::string>")
|
||||||
+ Check("map3.0", "[0] 1", "\"Bar\"", "") % NoCdbEngine
|
+ Check("map3.0", "[0] 1", "\"Bar\"", "") % NoCdbEngine
|
||||||
+ Check("map3.1", "[1] 1", "\"Foo\"", "") % NoCdbEngine
|
+ Check("map3.1", "[1] 1", "\"Foo\"", "") % NoCdbEngine
|
||||||
+ Check("map3.0", "1", "\"Foo\"", "std::pair<int const ,std::string>") % CdbEngine
|
+ Check("map3.0", "[0] 1", "\"Foo\"", "") % CdbEngine
|
||||||
+ Check("map3.1", "1", "\"Bar\"", "std::pair<int const ,std::string>") % CdbEngine;
|
+ Check("map3.1", "[1] 1", "\"Bar\"", "") % CdbEngine;
|
||||||
|
|
||||||
|
|
||||||
QTest::newRow("StdUnorderedSet")
|
QTest::newRow("StdUnorderedSet")
|
||||||
|
Reference in New Issue
Block a user