From patchwork Wed Apr 5 13:24:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 96850 Delivered-To: patch@linaro.org Received: by 10.182.246.10 with SMTP id xs10csp258898obc; Wed, 5 Apr 2017 06:26:48 -0700 (PDT) X-Received: by 10.200.42.13 with SMTP id k13mr27801908qtk.230.1491398808191; Wed, 05 Apr 2017 06:26:48 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id g31si17789643qtd.131.2017.04.05.06.26.48 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 05 Apr 2017 06:26:48 -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; dkim=fail header.i=@linaro.org; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:40555 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cvkxT-0005W4-KO for patch@linaro.org; Wed, 05 Apr 2017 09:26:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54525) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cvkvr-0004Wg-Rc for qemu-devel@nongnu.org; Wed, 05 Apr 2017 09:25:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cvkvq-0000E7-C7 for qemu-devel@nongnu.org; Wed, 05 Apr 2017 09:25:07 -0400 Received: from mail-wr0-x234.google.com ([2a00:1450:400c:c0c::234]:35396) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cvkvq-0000DH-5n for qemu-devel@nongnu.org; Wed, 05 Apr 2017 09:25:06 -0400 Received: by mail-wr0-x234.google.com with SMTP id k6so14519350wre.2 for ; Wed, 05 Apr 2017 06:25:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=f9S/5vQAaqH5p1VznmOtF2yJj3YXgg3ABa33JNSOsG0=; b=dqm0p3fBblP3NviOnx9dzMAn5ZnWe1DoDJzoj3QJw9dnERt4t+mahrd9Eykdegy3VC SEDdGNtIPcMOYkLvz4FPMFvmn29EsfR7/QmlMN97byQw1dgVxZKIkLyI8gJLzrcXp0of 7yx8NHRHuSbVMbxXDhplnK/PEnYy9tpUO3wXQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=f9S/5vQAaqH5p1VznmOtF2yJj3YXgg3ABa33JNSOsG0=; b=A4ecPbSwF5HGDy50xxuARR/IE3KK5aeT7+i+ZjTjMWig+Js3YO4+BKUYQtA+5wJK7n ROVxrEmBdlCfOYc+hSH2rBTpqmdmsaYC/AktXF4nrDVfevGT5JmB6rbcdngM/R/Ef97W UP0uuVYuV89SInVOkeXeLyZIW05MZdDz2YeZBNulQI4vDCBAzENlMIjfMpVs69X/N7cV Aqv9retGJfxDbLC5opNkDUcVR15YsnXnk1ufxeKgTrcz1Cpx+gS/I+8+FGAERJXkT6Wn onhW67Md2LRXCXO8kn7TGhd7F8fgw14NpOY8Qmka6KS2L0ZKAv8XXs8JWfNIpq5sHnlF 5C2w== X-Gm-Message-State: AFeK/H3jpKTxr/tdPQR8RAsWtU5GcA0OCXqGUlvpWSzAvLC4aUdSvH2M83QtKRPIZd8j7sfy X-Received: by 10.223.151.193 with SMTP id t1mr26802882wrb.149.1491398704925; Wed, 05 Apr 2017 06:25:04 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id g41sm26170462wrg.53.2017.04.05.06.25.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Apr 2017 06:25:02 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 407513E031F; Wed, 5 Apr 2017 14:25:03 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: dovgaluk@ispras.ru, rth@twiddle.net, pbonzini@redhat.com Date: Wed, 5 Apr 2017 14:24:53 +0100 Message-Id: <20170405132503.32125-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170405132503.32125-1-alex.bennee@linaro.org> References: <20170405132503.32125-1-alex.bennee@linaro.org> 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::234 Subject: [Qemu-devel] [PATCH v2 02/12] scripts/qemu-gdb/timers.py: new helper to dump timer state 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: mttcg@listserver.greensocs.com, peter.maydell@linaro.org, nikunj@linux.vnet.ibm.com, a.rigo@virtualopensystems.com, qemu-devel@nongnu.org, cota@braap.org, bobby.prani@gmail.com, =?utf-8?q?Alex_Benn=C3=A9e?= , fred.konrad@greensocs.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This introduces the qemu-gdb command "qemu timers" which will dump the state of the main timers in the system. Signed-off-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé --- scripts/qemu-gdb.py | 3 ++- scripts/qemugdb/timers.py | 54 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 scripts/qemugdb/timers.py -- 2.11.0 diff --git a/scripts/qemu-gdb.py b/scripts/qemu-gdb.py index b3f8e04f77..3e7adb87dc 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, timers class QemuCommand(gdb.Command): '''Prefix for QEMU debug support commands''' @@ -38,6 +38,7 @@ QemuCommand() coroutine.CoroutineCommand() mtree.MtreeCommand() aio.HandlersCommand() +timers.TimersCommand() coroutine.CoroutineSPFunction() coroutine.CoroutinePCFunction() diff --git a/scripts/qemugdb/timers.py b/scripts/qemugdb/timers.py new file mode 100644 index 0000000000..be71a001e3 --- /dev/null +++ b/scripts/qemugdb/timers.py @@ -0,0 +1,54 @@ +#!/usr/bin/python +# GDB debugging support +# +# Copyright 2017 Linaro Ltd +# +# Author: 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. + +# 'qemu timers' -- display the current timerlists + +import gdb + +class TimersCommand(gdb.Command): + '''Display the current QEMU timers''' + + def __init__(self): + 'Register the class as a gdb command' + gdb.Command.__init__(self, 'qemu timers', gdb.COMMAND_DATA, + gdb.COMPLETE_NONE) + + def dump_timers(self, timer): + "Follow a timer and recursively dump each one in the list." + # timer should be of type QemuTimer + gdb.write(" timer %s/%s (cb:%s,opq:%s)\n" % ( + timer['expire_time'], + timer['scale'], + timer['cb'], + timer['opaque'])) + + if int(timer['next']) > 0: + self.dump_timers(timer['next']) + + + def process_timerlist(self, tlist, ttype): + gdb.write("Processing %s timers\n" % (ttype)) + gdb.write(" clock %s is enabled:%s, last:%s\n" % ( + tlist['clock']['type'], + tlist['clock']['enabled'], + tlist['clock']['last'])) + if int(tlist['active_timers']) > 0: + self.dump_timers(tlist['active_timers']) + + + def invoke(self, arg, from_tty): + 'Run the command' + main_timers = gdb.parse_and_eval("main_loop_tlg") + + # This will break if QEMUClockType in timer.h is redfined + self.process_timerlist(main_timers['tl'][0], "Realtime") + self.process_timerlist(main_timers['tl'][1], "Virtual") + self.process_timerlist(main_timers['tl'][2], "Host") + self.process_timerlist(main_timers['tl'][3], "Virtual RT")