From patchwork Tue Jan 16 14:17:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 861669 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="LZj1UfJ3"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zLYRF65xkz9s7v for ; Wed, 17 Jan 2018 02:04:41 +1100 (AEDT) Received: from localhost ([::1]:39565 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebSn1-0007x1-PG for incoming@patchwork.ozlabs.org; Tue, 16 Jan 2018 10:04:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50600) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebS4J-0003IM-LM for qemu-devel@nongnu.org; Tue, 16 Jan 2018 09:18:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ebS4G-00051y-Ao for qemu-devel@nongnu.org; Tue, 16 Jan 2018 09:18:27 -0500 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:45406) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ebS4G-000501-3o for qemu-devel@nongnu.org; Tue, 16 Jan 2018 09:18:24 -0500 Received: by mail-wr0-x241.google.com with SMTP id 16so15333055wry.12 for ; Tue, 16 Jan 2018 06:18:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jQ0zev7HbBd4Se78/C004unL1JvTQkF6pSVZna7txHs=; b=LZj1UfJ3Exnuh21rfgf0SmGxg0c1lMZmF/4LT3PHiGHQrRy4KXleIQdpWM+Nf3exqJ N+ElMqF3OVz5h3higYHCcBCmT6i49GJr3QyPUZjCITrYZYJf8uTEpwnaNz765IeEb5my 4Uf7A8ST9lz0BDyhAbLZ5GM1hR24aZ9I5pRTpXo4Vp9148YTAhQCx09jMVG680126yRC gX01GOhkE1EfybvM/QnwpmR/6h9dzAk7AtYBIg1QcYjvk/STDdcUUEpRsCyKBDJtNpPy Dd9xgCy5w86xPI+MFeB8XviO49GRt273K8G+iP5NPBzOXcFXwATAhR8kUUpl2YWVLdrX TI/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=jQ0zev7HbBd4Se78/C004unL1JvTQkF6pSVZna7txHs=; b=aL1lInle1H77a1+V9k5xDb69pwgQztRpwcpfRkiHoo1O9dJ+yT/ALwtQnLaLnR44iF O1zGyFUSKX8Hqpnh32Szv9jpVa6i/2z6J0fBm6l3y4NwpaviQ+0ZYwhlGWdr0R/NL5Vt akuisCi9nIUpZPwqjJwYZ608wYesL/NKS1NBWwaDBC9BUvKlGYAN0tHI9dqHX1Z7fB7n x6BKcQ63Tf5ixEZ71SEi82/yxxEUoXmxFJRMI+WnaMlW3PX3Wc6quB3aKmvr/gns1485 lK5RxdNH+V9t/SZ8BeIR7AzDFWEf1nS6pHEQRDkZdxmmsunUYbnPoDbHMmTLO6l5eQV1 xUhw== X-Gm-Message-State: AKwxytcrNUD8QHeZgJ55CJmDehne4haq7Slxh8mypu0lHkVrbgzN9oQy KQQq8bhLRX8T8l540Et5lc5/73R3 X-Google-Smtp-Source: ACJfBovrTeBh5eMeTyI55hOqZ+B7xG3BEAdPZ2wfhjMxsKXsz+IwlfUNwqA87HkqVxg1JjcY8K9tXg== X-Received: by 10.223.134.58 with SMTP id 55mr15229967wrv.262.1516112302793; Tue, 16 Jan 2018 06:18:22 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id u10sm1537758wrg.6.2018.01.16.06.18.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Jan 2018 06:18:21 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 16 Jan 2018 15:17:15 +0100 Message-Id: <1516112253-14480-34-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1516112253-14480-1-git-send-email-pbonzini@redhat.com> References: <1516112253-14480-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::241 Subject: [Qemu-devel] [PULL 33/51] 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: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Alex Bennée Add a simple helper to dump lock state. Signed-off-by: Alex Bennée Signed-off-by: Paolo Bonzini --- 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))