qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

scripts/qemu-gdb: add simple tcg lock status helper

Add a simple helper to dump lock state.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

authored by

Alex Bennée and committed by
Paolo Bonzini
f1cd52d8 809092f3

+48 -1
+2 -1
scripts/qemu-gdb.py
··· 26 26 27 27 sys.path.append(os.path.dirname(__file__)) 28 28 29 - from qemugdb import aio, mtree, coroutine 29 + from qemugdb import aio, mtree, coroutine, tcg 30 30 31 31 class QemuCommand(gdb.Command): 32 32 '''Prefix for QEMU debug support commands''' ··· 38 38 coroutine.CoroutineCommand() 39 39 mtree.MtreeCommand() 40 40 aio.HandlersCommand() 41 + tcg.TCGLockStatusCommand() 41 42 42 43 coroutine.CoroutineSPFunction() 43 44 coroutine.CoroutinePCFunction()
+46
scripts/qemugdb/tcg.py
··· 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. See 12 + # the COPYING file in the top-level directory. 13 + # 14 + # Contributions after 2012-01-13 are licensed under the terms of the 15 + # GNU GPL, version 2 or (at your option) any later version. 16 + 17 + # 'qemu tcg-lock-status' -- display the TCG lock status across threads 18 + 19 + import gdb 20 + 21 + class TCGLockStatusCommand(gdb.Command): 22 + '''Display TCG Execution Status''' 23 + def __init__(self): 24 + gdb.Command.__init__(self, 'qemu tcg-lock-status', gdb.COMMAND_DATA, 25 + gdb.COMPLETE_NONE) 26 + 27 + def invoke(self, arg, from_tty): 28 + gdb.write("Thread, BQL (iothread_mutex), Replay, Blocked?\n") 29 + for thread in gdb.inferiors()[0].threads(): 30 + thread.switch() 31 + 32 + iothread = gdb.parse_and_eval("iothread_locked") 33 + replay = gdb.parse_and_eval("replay_locked") 34 + 35 + frame = gdb.selected_frame() 36 + if frame.name() == "__lll_lock_wait": 37 + frame.older().select() 38 + mutex = gdb.parse_and_eval("mutex") 39 + owner = gdb.parse_and_eval("mutex->__data.__owner") 40 + blocked = ("__lll_lock_wait waiting on %s from %d" % 41 + (mutex, owner)) 42 + else: 43 + blocked = "not blocked" 44 + 45 + gdb.write("%d/%d, %s, %s, %s\n" % (thread.num, thread.ptid[1], 46 + iothread, replay, blocked))