From 0c0b430fba0f56f4e086dce091d02ef7abc6bfbd Mon Sep 17 00:00:00 2001
From: hjk <qtc-committer@nokia.com>
Date: Thu, 15 Apr 2010 18:28:58 +0200
Subject: [PATCH] debugger: add python dumper for __gnu_cxx::hash_set

---
 share/qtcreator/gdbmacros/gdbmacros.py  | 24 ++++++++++++++++++++++++
 tests/manual/gdbdebugger/simple/app.cpp | 20 ++++++++++++++++++++
 2 files changed, 44 insertions(+)

diff --git a/share/qtcreator/gdbmacros/gdbmacros.py b/share/qtcreator/gdbmacros/gdbmacros.py
index f4546553d25..2ca413c4b85 100644
--- a/share/qtcreator/gdbmacros/gdbmacros.py
+++ b/share/qtcreator/gdbmacros/gdbmacros.py
@@ -1856,6 +1856,30 @@ def qdump__wstring(d, item):
     qdump__std__string(d, item)
 
 
+def qdump____gnu_cxx__hash_set(d, item):
+    ht = item.value["_M_ht"]
+    size = ht["_M_num_elements"]
+    d.putItemCount(size)
+    d.putNumChild(size)
+    type = item.value.type.template_argument(0)
+    d.putType("__gnu__cxx::hash_set<%s>" % type)
+    if d.isExpanded(item):
+        with Children(d, [size, 1000], type):
+            buckets = ht["_M_buckets"]["_M_impl"]
+            bucketStart = buckets["_M_start"]
+            bucketFinish = buckets["_M_finish"]
+            p = bucketStart
+            itemCount = 0
+            for i in xrange(bucketFinish - bucketStart):
+                if not isNull(p.dereference()):
+                    cur = p.dereference()
+                    while not isNull(cur):
+                        with SubItem(d):
+                            d.putValue(cur["_M_val"])
+                            cur = cur["_M_next"]
+                            itemCount += 1
+                p = p + 1
+
 #######################################################################
 #
 # Symbian
diff --git a/tests/manual/gdbdebugger/simple/app.cpp b/tests/manual/gdbdebugger/simple/app.cpp
index 3e2dca87c58..9bf48786c15 100644
--- a/tests/manual/gdbdebugger/simple/app.cpp
+++ b/tests/manual/gdbdebugger/simple/app.cpp
@@ -71,6 +71,11 @@
 #include <string>
 #include <vector>
 
+#define USE_GCC_EXT 1
+#if USE_GCC_EXT
+#include <hash_set>
+#endif
+
 #ifdef Q_OS_WIN
 #include <windows.h>
 #undef min
@@ -888,6 +893,20 @@ void testStdDeque()
     flist.push_front(2);
 }
 
+void testStdHashSet()
+{
+#if USE_GCC_EXT
+    using namespace __gnu_cxx;
+    hash_set<int> h;
+    h.insert(1);
+    h.insert(194);
+    h.insert(2);
+    h.insert(3);
+    h.insert(4);
+    h.insert(5);
+#endif
+}
+
 void testStdList()
 {
     std::list<int> big;
@@ -1606,6 +1625,7 @@ int main(int argc, char *argv[])
 
     testStdDeque();
     testStdList();
+    testStdHashSet();
     testStdMap();
     testStdSet();
     testStdStack();
-- 
GitLab