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 or later.
10 # See the COPYING file in the top-level directory.
12 # SPDX-License-Identifier: GPL-2.0-or-later
14 # 'qemu timers' -- display the current timerlists
18 class TimersCommand(gdb
.Command
):
19 '''Display the current QEMU timers'''
22 'Register the class as a gdb command'
23 gdb
.Command
.__init
__(self
, 'qemu timers', gdb
.COMMAND_DATA
,
26 def dump_timers(self
, timer
):
27 "Follow a timer and recursively dump each one in the list."
28 # timer should be of type QemuTimer
29 gdb
.write(" timer %s/%s (cb:%s,opq:%s)\n" % (
35 if int(timer
['next']) > 0:
36 self
.dump_timers(timer
['next'])
39 def process_timerlist(self
, tlist
, ttype
):
40 gdb
.write("Processing %s timers\n" % (ttype
))
41 gdb
.write(" clock %s is enabled:%s, last:%s\n" % (
42 tlist
['clock']['type'],
43 tlist
['clock']['enabled'],
44 tlist
['clock']['last']))
45 if int(tlist
['active_timers']) > 0:
46 self
.dump_timers(tlist
['active_timers'])
49 def invoke(self
, arg
, from_tty
):
51 main_timers
= gdb
.parse_and_eval("main_loop_tlg")
53 # This will break if QEMUClockType in timer.h is redfined
54 self
.process_timerlist(main_timers
['tl'][0], "Realtime")
55 self
.process_timerlist(main_timers
['tl'][1], "Virtual")
56 self
.process_timerlist(main_timers
['tl'][2], "Host")
57 self
.process_timerlist(main_timers
['tl'][3], "Virtual RT")