From patchwork Fri Jan 12 11:30:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 859828 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="Gu6WeHjI"; 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 3zJ1ss6y6gz9sNw for ; Fri, 12 Jan 2018 23:15:29 +1100 (AEDT) Received: from localhost ([::1]:36462 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZyF6-0004yR-39 for incoming@patchwork.ozlabs.org; Fri, 12 Jan 2018 07:15:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41915) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxZ4-0007ja-KV for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxZ3-0005m8-Ka for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:02 -0500 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:37003) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxZ3-0005lV-DS for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:01 -0500 Received: by mail-wr0-x241.google.com with SMTP id f8so5037331wre.4 for ; Fri, 12 Jan 2018 03:32:01 -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=8uK7m+aJMARg3nM8RYFYCYedyXZ6erON3h2snC7pldM=; b=Gu6WeHjIKfSmDdb6oRzZdNG0zr6iEeEwyXbmc8jEfSzcFo0D+zNEUdzLezD3OSbVsk P6zONynhs3/y5mYRlUgb/2U8Uyvdgx0rQqSAz4RNdvHe3xmOwtUllEb54WULPyBMW1ps zJUkMoEA4KgASR0OeJrjPNrRumpLSaTKrw9E25UyBwbwAqkfimzF1u/Gy1U7fMQ10URH HC2qnTuQH/A7j+6jnPiGATtn+zRJVRi5Fgc27Tqu9tp3ZCfybvu7SoDrobPUCOm1X0fb eGB1SSdtrrwxN4o6G2/r9xo0OTmhHnZGAHp7PYDVLrp0nUsgvQ6FMWlyh816qWq3HBLN aJ8g== 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=8uK7m+aJMARg3nM8RYFYCYedyXZ6erON3h2snC7pldM=; b=OGS1klkty4Qdu/V1rt+NgWg3qzKgf1pi330eJu+bihD/GJ9c5ppSmQ51ofzVQdWZDG 8M2df9xq/zVuUXnexk5gGfI0B9BQnLZGNyHB4FwSRH4+wZ7Utd1v9U97XuzBgsh6X0hP /fAyUrwhyyC4PvGhQ0gSkwJl2yRtzyv/ulpFNhO+N9/eEI98iL64GqGY0wY6n3GbLvM8 ycW6FxnUVTFGt7z3yBkMjVU3x3e86Hgvga0SEjiZsnS24GAapT1oJ0mYNxEqGvTJ6Id2 C5dLlWdZt6X/WTWd0weTtfUJdmfuQauyVnq3jnPbJyM9KqkQMjFSRmL6BRksgF6YyEte ulvg== X-Gm-Message-State: AKGB3mIC9esHTZSsjB2a/hIzgXD+nf02TJRsXg6pQqahbNE0fJaZiKCu Vt33ZdPhXf3dar42EZ7WrIxwVr6v X-Google-Smtp-Source: ACJfBouVSaoQNrlfqy2MSB1FiKEZ6wu0diN8e5a9wgjP0QMzd4pUUUiU2U9qx8kHpw8pZYWCRamt8A== X-Received: by 10.223.183.23 with SMTP id l23mr14776005wre.33.1515756720039; Fri, 12 Jan 2018 03:32:00 -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 l8sm2732271wmg.46.2018.01.12.03.31.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:31:59 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:30:59 +0100 Message-Id: <1515756676-3860-36-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-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 35/52] 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..88d042e --- /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))