bump product version to 6.3.0.0.beta1
[LibreOffice.git] / solenv / gdb / libreoffice / vcl.py
blob6a99c9f21f7cf5b972f899adc60c398c68bd6574
1 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 import six
11 import gdb
12 from libreoffice.util import printing
14 class ImplSchedulerDataPrinter(object):
15 '''Prints the ImplSchedulerData linked list.
17 This can be used to dump the current state of the scheduler via:
18 p *ImplGetSVData()->maSchedCtx.mpFirstSchedulerData
20 This doesn't include currently invoked tasks AKA the stack.
22 To dump the scheduler stack of invoked tasks use:
23 p *ImplGetSVData()->maSchedCtx.mpSchedulerStack
24 '''
26 def __init__(self, typename, value):
27 self.typename = typename
28 self.value = value
29 self.timer_type_ptr = gdb.lookup_type("Timer").pointer()
30 self.idle_type_ptr = gdb.lookup_type("Idle").pointer()
32 def as_string(self, gdbobj):
33 if gdbobj['mpTask']:
34 task = gdbobj['mpTask'].dereference()
35 timer = gdbobj['mpTask'].dynamic_cast( self.timer_type_ptr )
36 idle = gdbobj['mpTask'].dynamic_cast( self.idle_type_ptr )
37 if idle:
38 task_type = "Idle"
39 elif timer:
40 task_type = "Timer"
41 else:
42 task_type = "Task"
43 res = "{:7s}{:10s} active: {:6s}".format( task_type, str(task['mePriority']), str(task['mbActive']) )
44 name = task['mpDebugName']
45 if not name:
46 res = res + " (task debug name not set)"
47 else:
48 res = "{} '{}' ({})".format(res, str(name.string()), str(task.dynamic_type))
49 val_type = gdb.lookup_type(str( task.dynamic_type )).pointer()
50 timer = gdbobj['mpTask'].cast( val_type )
51 if (task_type == "Timer"):
52 res = "{}: {}ms".format(res, timer['mnTimeout'])
53 else:
54 assert 0 == timer['mnTimeout'], "Idle with timeout == {}".format( timer['mnTimeout'] )
55 return res
56 else:
57 return "(no task)"
59 def to_string(self):
60 return self.typename
62 def children(self):
63 return self._iterator(self)
65 def display_hint(self):
66 return 'array'
68 class _iterator(six.Iterator):
70 def __init__(self, printer):
71 self.pos = 0
72 self.printer = printer
73 self.value = printer.value
75 def __iter__(self):
76 return self
78 def __next__(self):
79 if not self.value['mpNext']:
80 raise StopIteration()
82 pos = str(self.pos)
83 name = "\n " + self.printer.as_string(self.value)
84 self.value = self.value['mpNext']
85 self.pos += 1
87 return (pos, name)
89 printer = None
91 def build_pretty_printers():
92 global printer
94 printer = printing.Printer("libreoffice/vcl")
95 printer.add('ImplSchedulerData', ImplSchedulerDataPrinter)
97 def register_pretty_printers(obj):
98 printing.register_pretty_printer(printer, obj)
100 build_pretty_printers()
102 # vim:set shiftwidth=4 softtabstop=4 expandtab: