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