From patchwork Tue Oct 31 11:08:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pavel Dovgalyuk X-Patchwork-Id: 117583 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3775515qgn; Tue, 31 Oct 2017 04:24:58 -0700 (PDT) X-Google-Smtp-Source: ABhQp+QDxRuaDmBBepgppNOGbkuy0Lubmqb2nxkIZkUspGn37AFtq0Fa6AD9cPkoNZd4bNEX5b0t X-Received: by 10.37.115.136 with SMTP id o130mr900265ybc.35.1509449098145; Tue, 31 Oct 2017 04:24:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509449098; cv=none; d=google.com; s=arc-20160816; b=b4z3tIm25rAtZyTLkAj0V0q1fZFhIeYCM/EN77CHXtFZufoR02It9ySfnmCh5LAn/p flRAoCjoL8tpPbqpxgUHj2M5bws7P/n28nZTJUcTr4bMpjwYb8wZKMSx3bg8I6opyVvG bn4yBoT3vxRIBKKU1RJn/rHjTxKKQiI8ty2vPFM9mjKhGIDAgNa+psV6fnTi+pQ+rk/C f38Kogw9nPZyoktU/DeFeBsQmbLpjFaV/9j7gsVKFNCTylAAK8JRzyi7Q3OdrQMmNb8a 6PsG95KKU7JLaziY/HSTvMMR1dD2c2QRJ/6d63e6sBiAZyP/Ae/U5gmZuQsf092QKVOm dvDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:to:from:arc-authentication-results; bh=8/Vw8eOcmoeZm82a8jz9Lqv6EaUsIFnni1lghWpg+Ng=; b=aWHQ/SiS9/goIJVhCZrdEtvqC7HS2LqV7nwPXLEMW7DXtz1Yie6o+VA1/1oW0xs9m9 A0OjkmhBTKEQLq6Oel1jvEghlFHmKDl2aZfbTQGJDwIKtdItIvFndG6Rnb/RgOZKp0mR QCn2b5tjkn+1yz0EPd2TJ8Uvb8nAiIO50MxNQwJQdZnW2KsijkwsS1ttWCSNWaFcy3t8 R/BAbPImK9gXqLv8tI4ViYhUvk2lrpnur4KGNizVv4N80/p3B6KWqbxhNHtNz41hdgCy kmKius7AZWEOQj0cXSyw7tibJW2Wnp/jK1u4yk2QkHDSmHe/RvQ+YcFkyckruEH83P9j Cmcw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id l14si323589ybm.757.2017.10.31.04.24.58 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 31 Oct 2017 04:24:58 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:44864 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e9UfB-0002Ov-O6 for patch@linaro.org; Tue, 31 Oct 2017 07:24:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40415) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e9UPR-0005QF-CA for qemu-devel@nongnu.org; Tue, 31 Oct 2017 07:08:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e9UPQ-0007iy-7E for qemu-devel@nongnu.org; Tue, 31 Oct 2017 07:08:41 -0400 Received: from mail.ispras.ru ([83.149.199.45]:42446) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e9UPP-0007id-WF for qemu-devel@nongnu.org; Tue, 31 Oct 2017 07:08:40 -0400 Received: from [127.0.1.1] (unknown [85.142.117.226]) by mail.ispras.ru (Postfix) with ESMTPSA id 572BE54006A; Tue, 31 Oct 2017 14:08:39 +0300 (MSK) From: Pavel Dovgalyuk To: qemu-devel@nongnu.org Date: Tue, 31 Oct 2017 14:08:40 +0300 Message-ID: <20171031110840.5836.82943.stgit@pasha-VirtualBox> In-Reply-To: <20171031110641.5836.43266.stgit@pasha-VirtualBox> References: <20171031110641.5836.43266.stgit@pasha-VirtualBox> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 83.149.199.45 Subject: [Qemu-devel] [RFC PATCH 22/26] scripts/qemu-gdb: add simple tcg lock status helper X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dovgaluk@ispras.ru Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Alex Bennée Add a simple helper to dump lock state. Signed-off-by: Alex Bennée --- scripts/qemu-gdb.py | 3 ++- scripts/qemugdb/tcg.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 scripts/qemugdb/tcg.py diff --git a/scripts/qemu-gdb.py b/scripts/qemu-gdb.py index b3f8e04..d58213e 100644 --- a/scripts/qemu-gdb.py +++ b/scripts/qemu-gdb.py @@ -26,7 +26,7 @@ import os, sys sys.path.append(os.path.dirname(__file__)) -from qemugdb import aio, mtree, coroutine +from qemugdb import aio, mtree, coroutine, tcg class QemuCommand(gdb.Command): '''Prefix for QEMU debug support commands''' @@ -38,6 +38,7 @@ QemuCommand() coroutine.CoroutineCommand() mtree.MtreeCommand() aio.HandlersCommand() +tcg.TCGLockStatusCommand() coroutine.CoroutineSPFunction() coroutine.CoroutinePCFunction() diff --git a/scripts/qemugdb/tcg.py b/scripts/qemugdb/tcg.py new file mode 100644 index 0000000..8c7f1d7 --- /dev/null +++ b/scripts/qemugdb/tcg.py @@ -0,0 +1,46 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# GDB debugging support, TCG status +# +# Copyright 2016 Linaro Ltd +# +# Authors: +# Alex Bennée +# +# This work is licensed under the terms of the GNU GPL, version 2. See +# the COPYING file in the top-level directory. +# +# Contributions after 2012-01-13 are licensed under the terms of the +# GNU GPL, version 2 or (at your option) any later version. + +# 'qemu tcg-lock-status' -- display the TCG lock status across threads + +import gdb + +class TCGLockStatusCommand(gdb.Command): + '''Display TCG Execution Status''' + def __init__(self): + gdb.Command.__init__(self, 'qemu tcg-lock-status', gdb.COMMAND_DATA, + gdb.COMPLETE_NONE) + + def invoke(self, arg, from_tty): + gdb.write("Thread, BQL (iothread_mutex), Replay, Blocked?\n") + for thread in gdb.inferiors()[0].threads(): + thread.switch() + + iothread = gdb.parse_and_eval("iothread_locked") + replay = gdb.parse_and_eval("replay_locked") + + frame = gdb.selected_frame() + if frame.name() == "__lll_lock_wait": + frame.older().select() + mutex = gdb.parse_and_eval("mutex") + owner = gdb.parse_and_eval("mutex->__data.__owner") + blocked = ("__lll_lock_wait waiting on %s from %d" % + (mutex, owner)) + else: + blocked = "not blocked" + + gdb.write("%d/%d, %s, %s, %s\n" % (thread.num, thread.ptid[1], + iothread, replay, blocked))