tcg.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # GDB debugging support, TCG status
  5. #
  6. # Copyright 2016 Linaro Ltd
  7. #
  8. # Authors:
  9. # Alex Bennée <alex.bennee@linaro.org>
  10. #
  11. # This work is licensed under the terms of the GNU GPL, version 2 or
  12. # later. See the COPYING file in the top-level directory.
  13. # 'qemu tcg-lock-status' -- display the TCG lock status across threads
  14. import gdb
  15. class TCGLockStatusCommand(gdb.Command):
  16. '''Display TCG Execution Status'''
  17. def __init__(self):
  18. gdb.Command.__init__(self, 'qemu tcg-lock-status', gdb.COMMAND_DATA,
  19. gdb.COMPLETE_NONE)
  20. def invoke(self, arg, from_tty):
  21. gdb.write("Thread, BQL (iothread_mutex), Replay, Blocked?\n")
  22. for thread in gdb.inferiors()[0].threads():
  23. thread.switch()
  24. iothread = gdb.parse_and_eval("iothread_locked")
  25. replay = gdb.parse_and_eval("replay_locked")
  26. frame = gdb.selected_frame()
  27. if frame.name() == "__lll_lock_wait":
  28. frame.older().select()
  29. mutex = gdb.parse_and_eval("mutex")
  30. owner = gdb.parse_and_eval("mutex->__data.__owner")
  31. blocked = ("__lll_lock_wait waiting on %s from %d" %
  32. (mutex, owner))
  33. else:
  34. blocked = "not blocked"
  35. gdb.write("%d/%d, %s, %s, %s\n" % (thread.num, thread.ptid[1],
  36. iothread, replay, blocked))