From 776da7b5b3f2609495da96eeb2f587ddfe320c0d Mon Sep 17 00:00:00 2001 From: hjk Date: Sat, 19 Jul 2014 23:37:17 +0200 Subject: [PATCH] Debugger: Improve associative std container display Handle multimap and multiset. Use the "[index] key" display that's also used for Q{Multi,}Map both for consistency and because it's needed to distiguish otherwise identical keys. Change-Id: Ib9e369206bce89e5e27d1f6f60ead11ca88e2dcb Reviewed-by: hjk --- share/qtcreator/debugger/stdtypes.py | 11 ++++- tests/auto/debugger/tst_dumpers.cpp | 41 +++++++++++++++---- .../debugger/simple/simple_test_app.cpp | 28 +++++++++++++ 3 files changed, 70 insertions(+), 10 deletions(-) diff --git a/share/qtcreator/debugger/stdtypes.py b/share/qtcreator/debugger/stdtypes.py index c929d19381b..1ae9dc7562a 100644 --- a/share/qtcreator/debugger/stdtypes.py +++ b/share/qtcreator/debugger/stdtypes.py @@ -192,7 +192,7 @@ def qdump__std__map(d, value): for i in d.childRange(): with SubItem(d, i): pair = (node + 1).cast(pairPointer).dereference() - d.putPair(pair) + d.putPair(pair, i) if d.isNull(node["_M_right"]): parent = node["_M_parent"] while node == parent["_M_right"]: @@ -267,9 +267,18 @@ def qdump__std____debug__map(d, value): def qdump__std____debug__set(d, value): qdump__std__set(d, value) +def qdump__std__multiset(d, value): + qdump__std__set(d, value) + def qdump__std____cxx1998__map(d, value): qdump__std__map(d, value) +def qform__std__multimap(): + return mapForms() + +def qdump__std__multimap(d, value): + return qdump__std__map(d, value) + def stdTreeIteratorHelper(d, value): node = value["_M_node"].dereference() d.putNumChild(1) diff --git a/tests/auto/debugger/tst_dumpers.cpp b/tests/auto/debugger/tst_dumpers.cpp index e3b79fd1c60..412656a7fcb 100644 --- a/tests/auto/debugger/tst_dumpers.cpp +++ b/tests/auto/debugger/tst_dumpers.cpp @@ -3728,22 +3728,33 @@ void tst_Dumpers::dumper_data() "Map::iterator it4 = it3; ++it4;\n" "Map::iterator it5 = it4; ++it5;\n" "Map::iterator it6 = it5; ++it6;\n" - "unused(&it6);\n") + "unused(&it6);\n" + + "std::multimap map4;\n" + "map4.insert(std::pair(11, 11.0));\n" + "map4.insert(std::pair(22, 22.0));\n" + "map4.insert(std::pair(22, 23.0));\n" + "map4.insert(std::pair(22, 24.0));\n" + "map4.insert(std::pair(22, 25.0));\n") + Check("map1", "<2 items>", "std::map") - + Check("map1.11", "[11]", "1", "unsigned int") - + Check("map1.22", "[22]", "2", "unsigned int") + + Check("map1.0", "[0] 11", "1", "unsigned int") + + Check("map1.1", "[1] 22", "2", "unsigned int") + Check("map2", "<2 items>", "std::map") - + Check("map2.11", "[11]", "11", "float") - + Check("map2.22", "[22]", "22", "float") + + Check("map2.0", "[0] 11", "11", "float") + + Check("map2.1", "[1] 22", "22", "float") + Check("map3", "<6 items>", "Map") - + Check("map3.11", "[11]", "11", "float") + + Check("map3.0", "[0] 11", "11", "float") + Check("it1.first", "11", "int") + Check("it1.second", "11", "float") + Check("it6.first", "66", "int") - + Check("it6.second", "66", "float"); + + Check("it6.second", "66", "float") + + + Check("map4", "<5 items>", "std::multimap") + + Check("map4.0", "[0] 11", "11", "float") + + Check("map4.4", "[4] 22", "25", "float"); QTest::newRow("StdMapQt") @@ -3911,7 +3922,15 @@ void tst_Dumpers::dumper_data() "Set::iterator it1 = s2.begin();\n" "Set::iterator it2 = it1; ++it2;\n" "Set::iterator it3 = it2; ++it3;\n" - "unused(&it3);\n") + "unused(&it3);\n\n" + + "std::multiset s3;\n" + "s3.insert(1);\n" + "s3.insert(1);\n" + "s3.insert(2);\n" + "s3.insert(3);\n" + "s3.insert(3);\n" + "s3.insert(3);\n") + Check("s0", "<0 items>", "std::set") @@ -3919,7 +3938,11 @@ void tst_Dumpers::dumper_data() + Check("s2", "<3 items>", "Set") + Check("it1.value", "11", "int") - + Check("it3.value", "33", "int"); + + Check("it3.value", "33", "int") + + + Check("s3", "<6 items>", "std::multiset") + + Check("s3.0", "[0]", "1", "int") + + Check("s3.5", "[5]", "3", "int"); QTest::newRow("StdSetQt") diff --git a/tests/manual/debugger/simple/simple_test_app.cpp b/tests/manual/debugger/simple/simple_test_app.cpp index c7f46d44294..dfda50eb324 100644 --- a/tests/manual/debugger/simple/simple_test_app.cpp +++ b/tests/manual/debugger/simple/simple_test_app.cpp @@ -3262,6 +3262,32 @@ namespace stdmap { dummyStatement(&map); } + void testStdMultiMapUIntFloat() + { + typedef std::pair V; + std::multimap map; + map.insert(V(11, 11.0)); + map.insert(V(22, 22.0)); + map.insert(V(22, 33.0)); + map.insert(V(22, 34.0)); + map.insert(V(22, 35.0)); + map.insert(V(22, 36.0)); + BREAK_HERE; + // Expand map. + // Check map <6 items> std:multimap. + // Check map.0 11 float. + // Check map.5 22 float. + // Continue. + dummyStatement(&map); + } + + void testStdMultiSetInt() + { + std::multiset set = {1, 1, 2, 3, 3, 3}; + BREAK_HERE; + dummyStatement(&set); + } + void testStdMap() { testStdMapStringFoo(); @@ -3274,6 +3300,8 @@ namespace stdmap { testStdMapStringFloat(); testStdMapIntString(); testStdMapStringPointer(); + testStdMultiMapUIntFloat(); + testStdMultiSetInt(); } } // namespace stdmap