diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2016-07-20 10:54:30 +0200 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2017-01-17 16:08:46 +0100 |
commit | 9e51007039770370182839846676b205f5c34c57 (patch) | |
tree | 0f00a1fc0b26a39b9bbf33e413cfba6d93c7596c /solenv | |
parent | 9235c5a3c2c7038b75606235859057f13824d5a1 (diff) |
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')
-rwxr-xr-x | solenv/bin/install-gdb-printers | 3 | ||||
-rw-r--r-- | solenv/gdb/libreoffice/vcl.py | 90 |
2 files changed, 92 insertions, 1 deletions
diff --git a/solenv/bin/install-gdb-printers b/solenv/bin/install-gdb-printers index 0362a5c04a06..4d5be9247087 100755 --- a/solenv/bin/install-gdb-printers +++ b/solenv/bin/install-gdb-printers @@ -123,7 +123,7 @@ if [[ ${DESTDIR}${pythondir} != ${GDBDIR} ]]; then fi if [[ -n "${MERGELIBS}" ]]; then - make_autoload merged program libmergedlo."$DYLIB" merge svl tl basegfx + make_autoload merged program libmergedlo."$DYLIB" merge svl tl basegfx vcl make_autoload cppu program libuno_cppu."$DYLIB".3 make_autoload sal program libuno_sal."$DYLIB".3 make_autoload sw program libswlo."$DYLIB" @@ -134,6 +134,7 @@ else make_autoload svl program libsvllo."$DYLIB" make_autoload sw program libswlo."$DYLIB" make_autoload tl program libtllo."$DYLIB" + make_autoload vcl program libvcllo."$DYLIB" fi make_autoload writerfilter program libwriterfilterlo."$DYLIB" 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: |