From patchwork Tue Oct 31 11:27:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pavel Dovgalyuk X-Patchwork-Id: 117594 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3791387qgn; Tue, 31 Oct 2017 04:40:09 -0700 (PDT) X-Google-Smtp-Source: ABhQp+RmyWAOMQBvXqaj9GE52wQZrjfRIAOmpXX7f4kliYBdTOMVz9ksfAZJxiuAbxmxiKKoperF X-Received: by 10.37.187.69 with SMTP id b5mr935921ybk.191.1509450009123; Tue, 31 Oct 2017 04:40:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509450009; cv=none; d=google.com; s=arc-20160816; b=rhAhvhJr09sHirp5UrkRB3bwUhCdVcoTZ3Ih4h8OLhkdpRFtRtE06s8K7yK9/3RZs/ ai95mzokYqnALGU2ciDfZS0haKGUBgtpSwVG+gzTSMJM9FBF/M7xUIZfSq6NNxKWTbri TSOyDty1JDKs++qBr8lZZ/CjRUuGhH81soWAPmRztdA9mcNM5dxdC9U649EpSG3sDgyU xRfAyjiaSpLbdiRbvXv/x/Q+PbTL47Np90u4ufbSBfBSaWGTKbnS5c2uzHGWYp1X7/x8 whnQ5oUOeKfGSMqTLkJJ6HjguV+PqI8fafTei06wvL4prddeEc6fnZwxalYX0AqYamVJ tCxQ== 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=ilTIRs8LBHlOSNzRHriLWZQRr2exhMMoUbJIj+EQrDPGIAih86A8Kv1F/tVHoMb/Jo 0W/kMvg+32eTKN/lFQmF97BgSAB5AvVSQhwUt8o2rU42uDBOvfIax9vLFU2FQGzqJPLF sb4r0zWsa4VwO7w4nDOFW4JJSy3QUimwh2ghfZ0l40siylUUJwnZPXRYrzz7cN8edXf+ l7d5VQyTFaP95wxF/F4IAGGKfbhU7n2cjCF5p6Jxgm1bwKsXVIsUH3fYaqz+M1V3PZJF YFheK+FsDwwYgzG4Zp6Ey0ijFuLx7l/W7XuZYi+28jwKw5BoVbBYVi6iz7xo2ye66vA0 pYgA== 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 h204si345969ywh.800.2017.10.31.04.40.09 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 31 Oct 2017 04:40:09 -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]:44933 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e9Uts-0006bv-JY for patch@linaro.org; Tue, 31 Oct 2017 07:40:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51213) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e9UhC-0004GT-CZ for qemu-devel@nongnu.org; Tue, 31 Oct 2017 07:27:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e9UhB-0000pN-12 for qemu-devel@nongnu.org; Tue, 31 Oct 2017 07:27:02 -0400 Received: from mail.ispras.ru ([83.149.199.45]:45432) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e9UhA-0000oc-Pj for qemu-devel@nongnu.org; Tue, 31 Oct 2017 07:27:00 -0400 Received: from [127.0.1.1] (unknown [85.142.117.226]) by mail.ispras.ru (Postfix) with ESMTPSA id EBE8754006A; Tue, 31 Oct 2017 14:26:59 +0300 (MSK) From: Pavel Dovgalyuk To: qemu-devel@nongnu.org Date: Tue, 31 Oct 2017 14:27:00 +0300 Message-ID: <20171031112700.10516.76192.stgit@pasha-VirtualBox> In-Reply-To: <20171031112457.10516.8971.stgit@pasha-VirtualBox> References: <20171031112457.10516.8971.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: 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))