target-microblaze: Setup for 64bit addressing
[qemu/ar7.git] / scripts / qemugdb / timers.py
blob51ea04b5e2ec1415074553267df7024cc94167aa
1 #!/usr/bin/python
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
14 import gdb
16 class TimersCommand(gdb.Command):
17 '''Display the current QEMU timers'''
19 def __init__(self):
20 'Register the class as a gdb command'
21 gdb.Command.__init__(self, 'qemu timers', gdb.COMMAND_DATA,
22 gdb.COMPLETE_NONE)
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" % (
28 timer['expire_time'],
29 timer['scale'],
30 timer['cb'],
31 timer['opaque']))
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):
48 'Run the command'
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")