xref: /openbmc/qemu/scripts/qemugdb/tcg.py (revision 8acf8650)
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
13# 'qemu tcg-lock-status' -- display the TCG lock status across threads
14
15import gdb
16
17class TCGLockStatusCommand(gdb.Command):
18    '''Display TCG Execution Status'''
19    def __init__(self):
20        gdb.Command.__init__(self, 'qemu tcg-lock-status', gdb.COMMAND_DATA,
21                             gdb.COMPLETE_NONE)
22
23    def invoke(self, arg, from_tty):
24        gdb.write("Thread, BQL (iothread_mutex), Replay, Blocked?\n")
25        for thread in gdb.inferiors()[0].threads():
26            thread.switch()
27
28            iothread = gdb.parse_and_eval("iothread_locked")
29            replay = gdb.parse_and_eval("replay_locked")
30
31            frame = gdb.selected_frame()
32            if frame.name() == "__lll_lock_wait":
33                frame.older().select()
34                mutex = gdb.parse_and_eval("mutex")
35                owner = gdb.parse_and_eval("mutex->__data.__owner")
36                blocked = ("__lll_lock_wait waiting on %s from %d" %
37                           (mutex, owner))
38            else:
39                blocked = "not blocked"
40
41            gdb.write("%d/%d, %s, %s, %s\n" % (thread.num, thread.ptid[1],
42                                               iothread, replay, blocked))
43