2
0

timers.py 1.8 KB

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