2
0

tcg.py 1.4 KB

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