From patchwork Mon Apr 3 12:45:17 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: 96633 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp83605qgd; Mon, 3 Apr 2017 05:50:25 -0700 (PDT) X-Received: by 10.237.45.198 with SMTP id i64mr17610662qtd.238.1491223825163; Mon, 03 Apr 2017 05:50:25 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id x23si11810035qtb.140.2017.04.03.05.50.25 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 03 Apr 2017 05:50:25 -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]:59148 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cv1RA-0004rD-Ot for patch@linaro.org; Mon, 03 Apr 2017 08:50:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52370) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cv1MT-0001LJ-PU for qemu-devel@nongnu.org; Mon, 03 Apr 2017 08:45:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cv1MP-00011j-41 for qemu-devel@nongnu.org; Mon, 03 Apr 2017 08:45:33 -0400 Received: from mail-wr0-x232.google.com ([2a00:1450:400c:c0c::232]:36715) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cv1MO-00011O-TK for qemu-devel@nongnu.org; Mon, 03 Apr 2017 08:45:29 -0400 Received: by mail-wr0-x232.google.com with SMTP id w11so166918693wrc.3 for ; Mon, 03 Apr 2017 05:45:28 -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=ReyCmMwO6NiXfsHmDJfGOyNqKRuYr9BSMGPiukUOzDw=; b=e2vIdM3kiB/g/c3NIiuyBubegCxuuLbyVwhGDKvcGruOSB1zqY3liJU9GLaOhj6zlu rZ8RuZ+Cv8Om7mHI4UTUL+f2jiy2CZVXxjhcorOdUt25Dn7+ZZE5+v8800ygVbqVEtt0 S9lB3PRjK+fm/AdbfW6a3lpe089PJ//vo5RAQ= 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=ReyCmMwO6NiXfsHmDJfGOyNqKRuYr9BSMGPiukUOzDw=; b=UAXdgyAF0f4/D0cIGTAWZXPUtPHt2Ro4uRzQcLsHylb22RTP1W/v+GHaNQ14It3iov xGlZfi2UYBdpYg6dEPuy3AqgUUhUQ29vIKUUlSPu9CNq/mtZgbIpm0gypqnItXIqGEoL oS/vSnhMb/ML9tAoEp/poYH7DwovHpNMoegjfF6Y9Cy6viayiuYfF+ZbEH8esI59cCzG lncMgX/cS8yGx3N4MJEWZunxyVJhiDiJF9s4bOrmOZKdOF/F/6jCsGVjOf3JVZdt/l8u fxWfgaXShd8m98oo/gLl8ed+pzlxlY31rnxaL8Pyqih+eO09ZPy7KeKWaRG2Jzv7zaEg 78bw== X-Gm-Message-State: AFeK/H22CzYq0DvQc1tsuL/mUQmkHzcR/vH5plMFapve/ftHNJ6fYZPEUIRjk7TWVbwWvSnZ X-Received: by 10.223.136.125 with SMTP id e58mr15716006wre.14.1491223527556; Mon, 03 Apr 2017 05:45:27 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id z79sm18112158wrc.2.2017.04.03.05.45.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Apr 2017 05:45:26 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id DFFAA3E1055; Mon, 3 Apr 2017 13:45:24 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: dovgaluk@ispras.ru, rth@twiddle.net, pbonzini@redhat.com Date: Mon, 3 Apr 2017 13:45:17 +0100 Message-Id: <20170403124524.10824-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170403124524.10824-1-alex.bennee@linaro.org> References: <20170403124524.10824-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::232 Subject: [Qemu-devel] [RFC PATCH v1 2/9] 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 --- 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 Reviewed-by: Philippe Mathieu-Daudé 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")