Merge tag 'qemu-macppc-20230206' of https://github.com/mcayland/qemu into staging
[qemu.git] / scripts / qemugdb / timers.py
blob46537b27cf058ecbebb8d55f958548e274261073
1 # -*- coding: utf-8 -*-
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 or later.
9 # See the COPYING file in the top-level directory.
11 # SPDX-License-Identifier: GPL-2.0-or-later
13 # 'qemu timers' -- display the current timerlists
15 import gdb
17 class TimersCommand(gdb.Command):
18 '''Display the current QEMU timers'''
20 def __init__(self):
21 'Register the class as a gdb command'
22 gdb.Command.__init__(self, 'qemu timers', gdb.COMMAND_DATA,
23 gdb.COMPLETE_NONE)
25 def dump_timers(self, timer):
26 "Follow a timer and recursively dump each one in the list."
27 # timer should be of type QemuTimer
28 gdb.write(" timer %s/%s (cb:%s,opq:%s)\n" % (
29 timer['expire_time'],
30 timer['scale'],
31 timer['cb'],
32 timer['opaque']))
34 if int(timer['next']) > 0:
35 self.dump_timers(timer['next'])
38 def process_timerlist(self, tlist, ttype):
39 gdb.write("Processing %s timers\n" % (ttype))
40 gdb.write(" clock %s is enabled:%s, last:%s\n" % (
41 tlist['clock']['type'],
42 tlist['clock']['enabled'],
43 tlist['clock']['last']))
44 if int(tlist['active_timers']) > 0:
45 self.dump_timers(tlist['active_timers'])
48 def invoke(self, arg, from_tty):
49 'Run the command'
50 main_timers = gdb.parse_and_eval("main_loop_tlg")
52 # This will break if QEMUClockType in timer.h is redfined
53 self.process_timerlist(main_timers['tl'][0], "Realtime")
54 self.process_timerlist(main_timers['tl'][1], "Virtual")
55 self.process_timerlist(main_timers['tl'][2], "Host")
56 self.process_timerlist(main_timers['tl'][3], "Virtual RT")