Commit bdd98e68 authored by hjk's avatar hjk
Browse files

debugger: implement gdb pretty printer for std::{map,set}::iterator



Change-Id: Idbe63b40f88d901fa762dd0ecbda2b5aa5d59642
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 785a9cea
......@@ -1856,6 +1856,53 @@ def qdump__std__map(d, value):
node = node["_M_left"]
def stdTreeIteratorHelper(d, value):
pnode = value["_M_node"]
node = pnode.dereference()
d.putNumChild(1)
d.putValue(" ")
if d.isExpanded():
dataType = templateArgument(value.type, 0)
nodeType = 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.putValue(" ")
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__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__set(d, value):
impl = value["_M_t"]["_M_impl"]
size = impl["_M_node_count"]
......
......@@ -2710,6 +2710,36 @@ namespace stdmap {
dummyStatement(&map);
}
void testStdMapUIntFloatIterator()
{
typedef std::map<uint, float> Map;
Map map;
map[11] = 11.0;
map[22] = 22.0;
map[33] = 33.0;
map[44] = 44.0;
map[55] = 55.0;
map[66] = 66.0;
Map::iterator it1 = map.begin();
Map::iterator it2 = it1; ++it2;
Map::iterator it3 = it2; ++it2;
Map::iterator it4 = it3; ++it3;
Map::iterator it5 = it4; ++it4;
Map::iterator it6 = it5; ++it5;
BREAK_HERE;
// Expand map.
// Check map <6 items> std::map<unsigned int, float>.
// Check map.11 11 float.
// Check it1.first 11 unsigned int.
// Check it1.second 11 float.
// Check it1.first 55 unsigned int.
// Check it1.second 55 float.
// Continue.
dummyStatement(&map, &it1, &it2, &it3, &it4, &it5, &it6);
}
void testStdMapStringFloat()
{
std::map<QString, float> map;
......@@ -2773,6 +2803,7 @@ namespace stdmap {
testStdMapUIntStringList();
testStdMapUIntStringListTypedef();
testStdMapUIntFloat();
testStdMapUIntFloatIterator();
testStdMapStringFloat();
testStdMapIntString();
testStdMapStringPointer();
......@@ -2853,6 +2884,33 @@ namespace stdset {
dummyStatement(&set);
}
void testStdSetIntIterator()
{
typedef std::set<int> Set;
Set set;
set.insert(11.0);
set.insert(22.0);
set.insert(33.0);
set.insert(44.0);
set.insert(55.0);
set.insert(66.0);
Set::iterator it1 = set.begin();
Set::iterator it2 = it1; ++it2;
Set::iterator it3 = it2; ++it2;
Set::iterator it4 = it3; ++it3;
Set::iterator it5 = it4; ++it4;
Set::iterator it6 = it5; ++it5;
BREAK_HERE;
// Check set <6 items> std::set<int>.
// Check it1.key 11 unsigned int.
// Check it1.value 11 int.
// Check it1.key 55 unsigned int.
// Check it1.value 55 int.
dummyStatement(&set, &it1, &it2, &it3, &it4, &it5, &it6);
}
void testStdSetString()
{
std::set<QString> set;
......@@ -2881,6 +2939,7 @@ namespace stdset {
void testStdSet()
{
testStdSetInt();
testStdSetIntIterator();
testStdSetString();
testStdSetPointer();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment