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/.
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
26 def __init__(self
, typename
, value
):
27 self
.typename
= typename
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
):
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
)
43 res
= "{:7s}{:10s} active: {:6s}".format( task_type
, str(task
['mePriority']), str(task
['mbActive']) )
44 name
= task
['mpDebugName']
46 res
= res
+ " (task debug name not set)"
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'])
54 assert 0 == timer
['mnTimeout'], "Idle with timeout == {}".format( timer
['mnTimeout'] )
63 return self
._iterator
(self
)
65 def display_hint(self
):
68 class _iterator(six
.Iterator
):
70 def __init__(self
, printer
):
72 self
.printer
= printer
73 self
.value
= printer
.value
79 if not self
.value
['mpNext']:
83 name
= "\n " + self
.printer
.as_string(self
.value
)
84 self
.value
= self
.value
['mpNext']
91 def build_pretty_printers():
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: