From 19ece94246741b1547ba2ebdb131501e6c89c52b Mon Sep 17 00:00:00 2001
From: hjk <qtc-committer@nokia.com>
Date: Wed, 5 May 2010 11:46:03 +0200
Subject: [PATCH] debugger: add example for non-alphabetically sorted struct
 members

---
 share/qtcreator/gdbmacros/gdbmacros.py  | 31 +++++++++++++++++++++++++
 tests/manual/gdbdebugger/simple/app.cpp | 14 +++++++++++
 2 files changed, 45 insertions(+)

diff --git a/share/qtcreator/gdbmacros/gdbmacros.py b/share/qtcreator/gdbmacros/gdbmacros.py
index d8517218ba6..600e99477d2 100644
--- a/share/qtcreator/gdbmacros/gdbmacros.py
+++ b/share/qtcreator/gdbmacros/gdbmacros.py
@@ -1950,6 +1950,37 @@ def qdump__TLitC(d, item):
 #######################################################################
 
 if False:
+
+    # FIXME: Make that work
+    def qdump__Color(d, item):
+        v = item.value
+        d.putValue("(%s, %s, %s; %s)" % (v["r"], v["g"], v["b"], v["a"]))
+        if d.isExpanded(item):
+            with Children(d):
+                d.putItem(Item(v["r"], item.iname, "0", "r"))
+                d.putItem(Item(v["g"], item.iname, "1", "g"))
+                d.putItem(Item(v["b"], item.iname, "2", "b"))
+                d.putItem(Item(v["a"], item.iname, "3", "a"))
+
+    def qdump__Color_(d, item):
+        v = item.value
+        d.putValue("(%s, %s, %s; %s)" % (v["r"], v["g"], v["b"], v["a"]))
+        if d.isExpanded(item):
+            with Children(d):
+                with SubItem(d):
+                    d.putField("iname", item.iname + ".0")
+                    d.putItemHelper(Item(v["r"], item.iname, "0", "r"))
+                with SubItem(d):
+                    d.putField("iname", item.iname + ".1")
+                    d.putItemHelper(Item(v["g"], item.iname, "1", "g"))
+                with SubItem(d):
+                    d.putField("iname", item.iname + ".2")
+                    d.putItemHelper(Item(v["b"], item.iname, "2", "b"))
+                with SubItem(d):
+                    d.putField("iname", item.iname + ".3")
+                    d.putItemHelper(Item(v["a"], item.iname, "3", "a"))
+
+
     def qdump__Function(d, item):
         min = item.value["min"]
         max = item.value["max"]
diff --git a/tests/manual/gdbdebugger/simple/app.cpp b/tests/manual/gdbdebugger/simple/app.cpp
index 8d700848c7f..eb4e338aff0 100644
--- a/tests/manual/gdbdebugger/simple/app.cpp
+++ b/tests/manual/gdbdebugger/simple/app.cpp
@@ -1593,8 +1593,22 @@ int testReference()
     return a.size() + b.size() + c.size();
 }
 
+struct Color
+{
+    int r,g,b,a;
+    Color() { r = 1, g = 2, b = 3, a = 4; }
+};
+
+void testColor()
+{
+    Color c;
+    c.r = 5;
+}
+
 int main(int argc, char *argv[])
 {
+    testColor();
+
     testPeekAndPoke3();
     testFunctionPointer();
     testAnonymous();
-- 
GitLab