2
0

timers.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. See
  10. # the COPYING file in the top-level directory.
  11. # 'qemu timers' -- display the current timerlists
  12. import gdb
  13. class TimersCommand(gdb.Command):
  14. '''Display the current QEMU timers'''
  15. def __init__(self):
  16. 'Register the class as a gdb command'
  17. gdb.Command.__init__(self, 'qemu timers', gdb.COMMAND_DATA,
  18. gdb.COMPLETE_NONE)
  19. def dump_timers(self, timer):
  20. "Follow a timer and recursively dump each one in the list."
  21. # timer should be of type QemuTimer
  22. gdb.write(" timer %s/%s (cb:%s,opq:%s)\n" % (
  23. timer['expire_time'],
  24. timer['scale'],
  25. timer['cb'],
  26. timer['opaque']))
  27. if int(timer['next']) > 0:
  28. self.dump_timers(timer['next'])
  29. def process_timerlist(self, tlist, ttype):
  30. gdb.write("Processing %s timers\n" % (ttype))
  31. gdb.write(" clock %s is enabled:%s, last:%s\n" % (
  32. tlist['clock']['type'],
  33. tlist['clock']['enabled'],
  34. tlist['clock']['last']))
  35. if int(tlist['active_timers']) > 0:
  36. self.dump_timers(tlist['active_timers'])
  37. def invoke(self, arg, from_tty):
  38. 'Run the command'
  39. main_timers = gdb.parse_and_eval("main_loop_tlg")
  40. # This will break if QEMUClockType in timer.h is redfined
  41. self.process_timerlist(main_timers['tl'][0], "Realtime")
  42. self.process_timerlist(main_timers['tl'][1], "Virtual")
  43. self.process_timerlist(main_timers['tl'][2], "Host")
  44. self.process_timerlist(main_timers['tl'][3], "Virtual RT")