summaryrefslogtreecommitdiffstats
path: root/solenv/gdb/libreoffice/vcl.py
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2016-07-20 10:54:30 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2017-01-17 16:08:46 +0100
commit9e51007039770370182839846676b205f5c34c57 (patch)
tree0f00a1fc0b26a39b9bbf33e413cfba6d93c7596c /solenv/gdb/libreoffice/vcl.py
parentMM change listener from friend to a nested class (diff)
downloadcore-9e51007039770370182839846676b205f5c34c57.tar.gz
core-9e51007039770370182839846676b205f5c34c57.zip
tdf#97087 GDB pretty print the Scheduler task list
In addition to the GDB pretty printer, this annotates a lot more Timers and Idles. Change-Id: I5b93fab02161b23bb753e65ef92643a04fb0789c
Diffstat (limited to 'solenv/gdb/libreoffice/vcl.py')
-rw-r--r--solenv/gdb/libreoffice/vcl.py90
1 files changed, 90 insertions, 0 deletions
diff --git a/solenv/gdb/libreoffice/vcl.py b/solenv/gdb/libreoffice/vcl.py
new file mode 100644
index 000000000000..83f405758216
--- /dev/null
+++ b/solenv/gdb/libreoffice/vcl.py
@@ -0,0 +1,90 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+import six
+import gdb
+from libreoffice.util import printing
+
+class ImplSchedulerDataPrinter(object):
+ '''Prints the ImplSchedulerData linked list.
+
+ This can be used to dump the current state of the scheduler via:
+ p *ImplGetSVData()->mpFirstSchedulerData
+ '''
+
+ def __init__(self, typename, value):
+ self.typename = typename
+ self.value = value
+ self.timer_type_ptr = gdb.lookup_type("Timer").pointer()
+ self.idle_type_ptr = gdb.lookup_type("Idle").pointer()
+
+ def as_string(self, gdbobj):
+ if gdbobj['mpScheduler']:
+ sched = gdbobj['mpScheduler'].dereference()
+ if gdbobj['mpScheduler'].dynamic_cast( self.timer_type_ptr ):
+ sched_type = "Timer"
+ elif gdbobj['mpScheduler'].dynamic_cast( self.idle_type_ptr ):
+ sched_type = "Idle"
+ else:
+ assert sched_type, "Scheduler object neither Timer nor Idle"
+ res = "{:7s}{:10s} active: {:6s}".format( sched_type, str(sched['mePriority']), str(sched['mbActive']) )
+ name = sched['mpDebugName']
+ if not name:
+ res = res + " (scheduler debug name not set)"
+ else:
+ res = "{} '{}' ({})".format(res, str(name.string()), str(sched.dynamic_type))
+ return res
+ else:
+ assert gdbobj['mbDelete'], "No scheduler set and not marked for deletion!"
+ return "(no scheduler)"
+
+ def to_string(self):
+ return self.typename
+
+ def children(self):
+ return self._iterator(self)
+
+ def display_hint(self):
+ return 'array'
+
+ class _iterator(six.Iterator):
+
+ def __init__(self, printer):
+ self.pos = 0
+ self.printer = printer
+ self.value = printer.value
+
+ def __iter__(self):
+ return self
+
+ def __next__(self):
+ if not self.value['mpNext']:
+ raise StopIteration()
+
+ pos = str(self.pos)
+ name = "\n " + self.printer.as_string(self.value)
+ self.value = self.value['mpNext']
+ self.pos += 1
+
+ return (pos, name)
+
+printer = None
+
+def build_pretty_printers():
+ global printer
+
+ printer = printing.Printer("libreoffice/vcl")
+ printer.add('ImplSchedulerData', ImplSchedulerDataPrinter)
+
+def register_pretty_printers(obj):
+ printing.register_pretty_printer(printer, obj)
+
+build_pretty_printers()
+
+# vim:set shiftwidth=4 softtabstop=4 expandtab: