From patchwork Tue Nov 14 08:18:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pavel Dovgalyuk X-Patchwork-Id: 118851 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp2772074qgn; Tue, 14 Nov 2017 00:36:24 -0800 (PST) X-Google-Smtp-Source: AGs4zMaxmFcU763R1y3lZccBb3q/MS4yleFqHBeq4zu1aMe1VF4/VwZN7gKRmgPMuiCnG2G75nJk X-Received: by 10.37.2.140 with SMTP id 134mr2512840ybc.327.1510648584940; Tue, 14 Nov 2017 00:36:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510648584; cv=none; d=google.com; s=arc-20160816; b=iHRk4SWBP6qJgft0i0QGIXP/LJ9zxWsGO8K83PYpm4RQ01FlEWk0iyAFnu50r8/4lD 1jvckRjg+5r8dt/50AnbdPcw0TSRCm2Boh2viNr9NTpOWkNBogr9wiDYH+KdpyVTd/mK pMGr5l22fZdGUNmqcolhq+YnN5kpA4mfOd6NQVNFYMozrYe/t70L5mK0HhC6J44GFlMk Kis+JNM76XsNvncYodvsrLvmMQQYmcI6p/ookgW+/6vc0lcuaEs4SvNBKmTVX4R7Smoq EFVNZ6g2v7wK6Q13dQ7VWu3u6bW5HhVwU6JgbOr7+aTi3FstUnYIlI4AF4uApKqD3hfg iiDg== 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=bcW77ajVaeXnMUJpltG0YXKbg6+gDd4QVwklz8/P/AnMOQfpswsBeQNWfsopBGrpfg YOgNYwV2ZLaUM0JGqyROyywwrIwHzX0zA+lCTrrxtWwPyMvLcBva1zqJU2hi1c3joLus FadCkffT08m4g80nPeQciDeULqWAHdOxECDr2RtwlsjuAi8IOm2kwqv4S8QMU/iiEXTQ J8S9KM0yRS2OH3PM1ZK2yKg3QWDK1eNK0pgJEsI8qk8wWgpiVPewARy1D6nFCp22pD/1 b5q/50DUZFUy9iAmaqWKbvhCVawBICktVBsJ3rZI7RaU1oE19FcoycY7B9xapIiDchmA tbHw== 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 j13si3888913ybl.208.2017.11.14.00.36.24 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 14 Nov 2017 00:36:24 -0800 (PST) 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]:58263 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eEWhk-00010f-Fi for patch@linaro.org; Tue, 14 Nov 2017 03:36:24 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41080) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eEWQO-0000ff-Sr for qemu-devel@nongnu.org; Tue, 14 Nov 2017 03:18:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eEWQN-0007B5-Pi for qemu-devel@nongnu.org; Tue, 14 Nov 2017 03:18:28 -0500 Received: from mail.ispras.ru ([83.149.199.45]:52842) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eEWQN-0007Al-Hn for qemu-devel@nongnu.org; Tue, 14 Nov 2017 03:18:27 -0500 Received: from [127.0.1.1] (unknown [85.142.117.226]) by mail.ispras.ru (Postfix) with ESMTPSA id B5ED054006A; Tue, 14 Nov 2017 11:18:26 +0300 (MSK) From: Pavel Dovgalyuk To: qemu-devel@nongnu.org Date: Tue, 14 Nov 2017 11:18:35 +0300 Message-ID: <20171114081835.27640.75770.stgit@pasha-VirtualBox> In-Reply-To: <20171114081630.27640.53933.stgit@pasha-VirtualBox> References: <20171114081630.27640.53933.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 v2 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: kwolf@redhat.com, peter.maydell@linaro.org, pavel.dovgaluk@ispras.ru, mst@redhat.com, jasowang@redhat.com, quintela@redhat.com, zuban32s@gmail.com, maria.klimushenkova@ispras.ru, dovgaluk@ispras.ru, kraxel@redhat.com, boost.lists@gmail.com, pbonzini@redhat.com, alex.bennee@linaro.org 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))