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