From patchwork Wed May 17 14:52:55 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: 99997 Delivered-To: patch@linaro.org Received: by 10.182.142.97 with SMTP id rv1csp254291obb; Wed, 17 May 2017 07:54:20 -0700 (PDT) X-Received: by 10.200.34.60 with SMTP id o57mr3346592qto.41.1495032859958; Wed, 17 May 2017 07:54:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495032859; cv=none; d=google.com; s=arc-20160816; b=XlYqJEI+xGUdPoPJbtGLwujzas5wEyjGHyWfOqW70obrPG8DyQ/GMmM+wvYtNcioNG 2/1ASzzh0nhQWTQFkZyLvzhC227vG0+aGgoDQ+Od4WsPD6lUmrxtTxFeKAlscqgUKU6e b0XlDSJESPWEDKN/hyK1rfMhgrNGD083lG7Gke6pcKrn3cxpEI1WSCeK7X+GjJv3irhU 7SNHMzn0xH8Pt8Chk2Ne8sDOzK5ysgKT5cH4NkASHpzsDbuGDh0Cq7MnTq3VqrkSbjfX uPgttgf2ORAUW8MZtGmjDHQJ1WdiDk3cvz9NYpt9Q+YvWgSen0ROJAVJzH4Vgmt2wNfe 5RlA== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=f9S/5vQAaqH5p1VznmOtF2yJj3YXgg3ABa33JNSOsG0=; b=VSK3LzaianIvvhAZ+zJfFCnQmik1sNdeF/LfW6wbsWEQatAwUlrFvffyG6xnEJl9Tv RcQ8xNpddignrUc4RFEdY3Srhre1ylZ2UpBRLTJYA9llEuQ0AqxUGMqZ2+CCX09H6UDD 80cHibEJIgqiSvBiR+svYo51Oa6AkGUnRyDQjTgwO7gpwqP6ZexJDMLfFI6S0/iDnaNC Xr876pNTOCaawsZ1gCL2xo5eFT7cKu428Hooyhxih+vduuwQrt+1+krPOcXT4X+b9S/l GZ5MZ/4YDH5OYg5d5QcX98qJz9M2OXTvsbzQ+RhgzaZ/QVcwkOU+NNCETmjDRIIuXTye V78A== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id q10si2402654qta.105.2017.05.17.07.54.19 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 17 May 2017 07:54:19 -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]:49379 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dB0LD-0002z2-B8 for patch@linaro.org; Wed, 17 May 2017 10:54:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50701) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dB0J8-0001iy-Je for qemu-devel@nongnu.org; Wed, 17 May 2017 10:52:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dB0J6-0004ew-HB for qemu-devel@nongnu.org; Wed, 17 May 2017 10:52:10 -0400 Received: from mail-wm0-x22e.google.com ([2a00:1450:400c:c09::22e]:37469) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dB0J6-0004ec-B9 for qemu-devel@nongnu.org; Wed, 17 May 2017 10:52:08 -0400 Received: by mail-wm0-x22e.google.com with SMTP id d127so19125370wmf.0 for ; Wed, 17 May 2017 07:52:08 -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=HXNECJWpeJnSrNwCgu7Qydu+TyymrNCiFlpJQaEoXLOWsXkiosVuooALkTlrh26ZxH 4tjyEqxFtQf+38vilQndvel1k1Y7qBFMLsEOxnCox8IeYjIvdS5/OM61eiJVfX2mFCWN g0K+2O58UJ+cC6MF6RHdw7stynA5vAVatKKNY= 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=kZSvOhVwIZhZTylBNyODLSGxVKwBfWsmhQjNgytu2NAd4sSxTX6O0lqG2N7FNdIJ/G V+eyIvbCqXMe2El+RHzKAMeCjWbDOWzMdC6dotPnAvWeNqyoTCEpoKhcgxgAfHI0N+HY 4g5fdHWG5UpSrXiJ38Bp9gkLia4BzBdj6ykAEa/IYKL4ArqN4lRjFaN4Pil3H/MGVoy6 iWTyCEkjqeV5mbgneSm1Yya0LgTqzH0RFgL+uTgJqgU84CTkxlt3dqjHKKHyxH75uNp5 jUB+5r1nKOqv/bhJh4dZadGjxRvecLL88AcalFgH8Igp+2JZZE7VXGvEsspO5kfAaLyD nsag== X-Gm-Message-State: AODbwcB5gn9QrHgzhHzMem6cqOjw3VKdwLG56e+yKpKY3XjeYk0U7KAR 9Bxnlzx5kjv8WU6T X-Received: by 10.28.207.207 with SMTP id f198mr11939199wmg.85.1495032727150; Wed, 17 May 2017 07:52:07 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id c37sm2247425wra.16.2017.05.17.07.52.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 May 2017 07:52:04 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id A1E7E3E0662; Wed, 17 May 2017 15:52:59 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: pbonzini@redhat.com, stefanha@redhat.com Date: Wed, 17 May 2017 15:52:55 +0100 Message-Id: <20170517145259.28979-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170517145259.28979-1-alex.bennee@linaro.org> References: <20170517145259.28979-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:c09::22e Subject: [Qemu-devel] [PATCH v2 2/6] 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: cota@braap.org, =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org 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")