]> Git Repo - qemu.git/blob - scripts/qemugdb/timers.py
scripts/qemugdb: re-license timers.py to GPLv2 or later
[qemu.git] / scripts / qemugdb / timers.py
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 # GDB debugging support
4 #
5 # Copyright 2017 Linaro Ltd
6 #
7 # Author: Alex BennĂ©e <[email protected]>
8 #
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.
11 #
12 # SPDX-License-Identifier: GPL-2.0-or-later
13
14 # 'qemu timers' -- display the current timerlists
15
16 import gdb
17
18 class TimersCommand(gdb.Command):
19     '''Display the current QEMU timers'''
20
21     def __init__(self):
22         'Register the class as a gdb command'
23         gdb.Command.__init__(self, 'qemu timers', gdb.COMMAND_DATA,
24                              gdb.COMPLETE_NONE)
25
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" % (
30             timer['expire_time'],
31             timer['scale'],
32             timer['cb'],
33             timer['opaque']))
34
35         if int(timer['next']) > 0:
36             self.dump_timers(timer['next'])
37
38
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'])
47
48
49     def invoke(self, arg, from_tty):
50         'Run the command'
51         main_timers = gdb.parse_and_eval("main_loop_tlg")
52
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")
This page took 0.03049 seconds and 4 git commands to generate.