[icinga-checkins] icinga.org: icinga2/master: Implement GDB pretty printers for some Icinga types.

git at icinga.org git at icinga.org
Tue Feb 26 10:14:19 CET 2013


Module: icinga2
Branch: master
Commit: d705ff648e4e46eb3518045782426dbe6f8140f9
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=d705ff648e4e46eb3518045782426dbe6f8140f9

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Tue Feb 26 10:14:10 2013 +0100

Implement GDB pretty printers for some Icinga types.

---

 contrib/gdb/gdbinit      |    6 +++++
 contrib/gdb/icingadbg.py |   56 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 62 insertions(+), 0 deletions(-)

diff --git a/contrib/gdb/gdbinit b/contrib/gdb/gdbinit
new file mode 100644
index 0000000..f4fe791
--- /dev/null
+++ b/contrib/gdb/gdbinit
@@ -0,0 +1,6 @@
+python
+import sys
+sys.path.insert(0, '/home/gbeutner/strawberry/contrib/gdb')
+from icingadbg import register_icinga_printers
+register_icinga_printers()
+end
diff --git a/contrib/gdb/icingadbg.py b/contrib/gdb/icingadbg.py
new file mode 100644
index 0000000..fc0e8a0
--- /dev/null
+++ b/contrib/gdb/icingadbg.py
@@ -0,0 +1,56 @@
+import gdb
+import re
+
+class IcingaStringPrinter:
+    def __init__(self, val):
+        self.val = val
+
+    def to_string(self):
+        return '"' + self.val['m_Data']['_M_dataplus']['_M_p'].string() + '"'
+
+class IcingaValuePrinter:
+    def __init__(self, val):
+        self.val = val
+
+    def to_string(self):
+        which = self.val['m_Value']['which_']
+
+        if which == 0:
+            return 'Empty'
+        elif which == 1:
+            return self.val['m_Value']['storage_']['data_']['buf'].cast(gdb.lookup_type('double').pointer()).dereference()
+        elif which == 2:
+            return self.val['m_Value']['storage_']['data_']['buf'].cast(gdb.lookup_type('icinga::String').pointer()).dereference()
+        elif which == 3:
+            return self.val['m_Value']['storage_']['data_']['buf'].cast(gdb.lookup_type('icinga::Object').pointer()).dereference()
+        else:
+            return '<INVALID>'
+
+class IcingaAttributePrinter:
+    def __init__(self, val):
+        self.val = val
+
+    def to_string(self):
+        return self.val['m_Value']
+
+class IcingaSignalPrinter:
+    def __init__(self, val):
+        self.val = val
+
+    def to_string(self):
+        return '<SIGNAL>'
+
+def lookup_icinga_type(val):
+    if str(val.type) == 'icinga::String':
+        return IcingaStringPrinter(val)
+    elif str(val.type) == 'icinga::Value':
+        return IcingaValuePrinter(val)
+    elif str(val.type) == 'icinga::AttributeBase' or re.match('^icinga::Attribute<.*>$', str(val.type)):
+        return IcingaAttributePrinter(val)
+    elif re.match('^boost::signals2::signal.*<.*>$', str(val.type)):
+        return IcingaSignalPrinter(val)
+
+    return None
+
+def register_icinga_printers():
+    gdb.pretty_printers.append(lookup_icinga_type)





More information about the icinga-checkins mailing list