timers.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. # GDB debugging support
  4. #
  5. # Copyright 2017 Linaro Ltd
  6. #
  7. # Author: Alex Bennée <alex.bennee@linaro.org>
  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. # 'qemu timers' -- display the current timerlists
  14. import gdb
  15. class TimersCommand(gdb.Command):
  16. '''Display the current QEMU timers'''
  17. def __init__(self):
  18. 'Register the class as a gdb command'
  19. gdb.Command.__init__(self, 'qemu timers', gdb.COMMAND_DATA,
  20. gdb.COMPLETE_NONE)
  21. def dump_timers(self, timer):
  22. "Follow a timer and recursively dump each one in the list."
  23. # timer should be of type QemuTimer
  24. gdb.write(" timer %s/%s (cb:%s,opq:%s)\n" % (
  25. timer['expire_time'],
  26. timer['scale'],
  27. timer['cb'],
  28. timer['opaque']))
  29. if int(timer['next']) > 0:
  30. self.dump_timers(timer['next'])
  31. def process_timerlist(self, tlist, ttype):
  32. gdb.write("Processing %s timers\n" % (ttype))
  33. gdb.write(" clock %s is enabled:%s, last:%s\n" % (
  34. tlist['clock']['type'],
  35. tlist['clock']['enabled'],
  36. tlist['clock']['last']))
  37. if int(tlist['active_timers']) > 0:
  38. self.dump_timers(tlist['active_timers'])
  39. def invoke(self, arg, from_tty):
  40. 'Run the command'
  41. main_timers = gdb.parse_and_eval("main_loop_tlg")
  42. # This will break if QEMUClockType in timer.h is redfined
  43. self.process_timerlist(main_timers['tl'][0], "Realtime")
  44. self.process_timerlist(main_timers['tl'][1], "Virtual")
  45. self.process_timerlist(main_timers['tl'][2], "Host")
  46. self.process_timerlist(main_timers['tl'][3], "Virtual RT")