2 # GDB debugging support
4 # Copyright 2017 Linaro Ltd
6 # Author: Alex Bennée <alex.bennee@linaro.org>
8 # This work is licensed under the terms of the GNU GPL, version 2. See
9 # the COPYING file in the top-level directory.
11 # 'qemu timers' -- display the current timerlists
15 class TimersCommand(gdb
.Command
):
16 '''Display the current QEMU timers'''
19 'Register the class as a gdb command'
20 gdb
.Command
.__init
__(self
, 'qemu timers', gdb
.COMMAND_DATA
,
23 def dump_timers(self
, timer
):
24 "Follow a timer and recursively dump each one in the list."
25 # timer should be of type QemuTimer
26 gdb
.write(" timer %s/%s (cb:%s,opq:%s)\n" % (
32 if int(timer
['next']) > 0:
33 self
.dump_timers(timer
['next'])
36 def process_timerlist(self
, tlist
, ttype
):
37 gdb
.write("Processing %s timers\n" % (ttype
))
38 gdb
.write(" clock %s is enabled:%s, last:%s\n" % (
39 tlist
['clock']['type'],
40 tlist
['clock']['enabled'],
41 tlist
['clock']['last']))
42 if int(tlist
['active_timers']) > 0:
43 self
.dump_timers(tlist
['active_timers'])
46 def invoke(self
, arg
, from_tty
):
48 main_timers
= gdb
.parse_and_eval("main_loop_tlg")
50 # This will break if QEMUClockType in timer.h is redfined
51 self
.process_timerlist(main_timers
['tl'][0], "Realtime")
52 self
.process_timerlist(main_timers
['tl'][1], "Virtual")
53 self
.process_timerlist(main_timers
['tl'][2], "Host")
54 self
.process_timerlist(main_timers
['tl'][3], "Virtual RT")