From patchwork Fri Oct 5 15:49:02 2018 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: 148195 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp612083lji; Fri, 5 Oct 2018 08:50:12 -0700 (PDT) X-Google-Smtp-Source: ACcGV61FdmrAt/S9pgsms7ayQpFIA52jyNKOu9H3p3Y+51EVoi587D4o/YSccMRDOBudMrtKwubA X-Received: by 2002:a37:35c8:: with SMTP id c191-v6mr9743528qka.100.1538754612810; Fri, 05 Oct 2018 08:50:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538754612; cv=none; d=google.com; s=arc-20160816; b=exB3FS/spzVkZCI7BK41Z8XaZ2ItmRi2p2MEvxF3g4A55o4U9JZlW8ByVswnJWrg/p oodQBWEF37/E3yW00Sjm+XKoTtR0JxIxaXDWE/NKsGuYzwfaG7tceqC0L8N15vHTMf22 IgR/81AAmI5Y12O3Vg6x/mIHvPMvxrkxF7xmZs0K7hQVY/e/iJm9JzaxS7qxxPhiFElf tFanSxezN6qoa1PcxEZyH/jb6E172FCURlqx0syLSRKUPsmmV5iuXUCx1sCoeJs9VIGN 7peGzsMok2brNuAlJ1MYhaint8yforxP5sn/Ip/BrdIl2rRNJ1FU+l8wd4+EDFnVIwjZ +RfQ== 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; bh=TsGSCPz+9y3BaOaOAhZuWXwgcuTe85acFE8FkD79Zcs=; b=i1vJunQw7MNq50ByKJBr61IK9UuEhy5zaG0SGPvH7PNfDz7gqmu4jZwym7r77w2U+v 9SYYNcZQU5YLeweaC5f2iew7AJaw+lh0V3ZYjKlbp6LJgmJxdaZjrASHMgc2SNdYjqPe UsI8kTRAz4XHultkh1EWRp5Cq0qFknzzHmcD6gNQnZiaJA02mqoKjAotiNak+/vDGyut BHAQGg8+oaTBoXVSq1SbScq7kCR1IZ8YSkDZDteu7f/1acYpQ6tVbbqzR8GMGYDJJRlZ PDogfT5SVtCixUoesqBdPm0ga4a2ivjBuPuhiwfie8lUEVefuVDruKHwGyJdcd0QgF4f x6dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SYRxlTRo; 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 z127-v6si5722963qke.342.2018.10.05.08.50.12 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 05 Oct 2018 08:50:12 -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 header.s=google header.b=SYRxlTRo; 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]:35697 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SMm-0006m1-7i for patch@linaro.org; Fri, 05 Oct 2018 11:50:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56965) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SMB-0006b4-8W for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8SM9-0006E4-Bj for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:35 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:41147) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g8SM8-00067X-No for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:33 -0400 Received: by mail-wr1-x431.google.com with SMTP id x12-v6so14041395wru.8 for ; Fri, 05 Oct 2018 08:49:27 -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=TsGSCPz+9y3BaOaOAhZuWXwgcuTe85acFE8FkD79Zcs=; b=SYRxlTRoK/I3rjb2TR75agKeR83w4siHPLDgff4Qr+W95LcCHTWM9FYNe9JHSMjOEj p9JHxjf7kbUCkBUJb487jdETG25FqSytUBsn2DrAc5iM5ynMU1JU+PY9itbcyxT0N8dF KtqjxdGtm9FuMVET19SQ/tX1+bh2h6bwrq8Dw= 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=TsGSCPz+9y3BaOaOAhZuWXwgcuTe85acFE8FkD79Zcs=; b=SrudnCgG9R3T5kWX9uAbLmHVwwTTn1ymy3AgX1iKMbmSBZ6H6Vlhg+Fig1fjV5M90+ 759Lu4cdYPYnfyGGAHIfmnaudhu6/Q39aucJGDozhNlTsaXh6hZSQZsv2hN1b0pnM6xd 0HtOgTPHtrKeFxj/BZykoFVaaWxFRbVdwD3wxxmQR7EOQdiDRlerXHYUTSAGBx99i8nc z+gU2Km7WTFKpu0GjO0RwQ7czfaFivdybT/ZPgMrzWyccmRSgMTTMrm26XdDJ4608iZD MED95NKK8eTCkAFSnh3lUEVTLrC4JHMHqdFf+gIHsRWTdNZBnLNrfvfnroyg/bOVQXAO 7s0g== X-Gm-Message-State: ABuFfogg4vEA02MP8TaLBnBlSyrusNc0K5QPp+lCaqitcWYH9mYHOWNJ iP3PM35mNK5F4pq0ABGMz0gJug== X-Received: by 2002:adf:f50b:: with SMTP id q11-v6mr8848542wro.246.1538754566687; Fri, 05 Oct 2018 08:49:26 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id w4-v6sm15206221wra.83.2018.10.05.08.49.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Oct 2018 08:49:22 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id B9CB23E06DC; Fri, 5 Oct 2018 16:49:11 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 5 Oct 2018 16:49:02 +0100 Message-Id: <20181005154910.3099-14-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181005154910.3099-1-alex.bennee@linaro.org> References: <20181005154910.3099-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:4864:20::431 Subject: [Qemu-devel] [RFC PATCH 13/21] tracetool: generate plugin snippets 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: Stefan Hajnoczi , cota@braap.org, =?utf-8?q?Alex_?= =?utf-8?q?Benn=C3=A9e?= , vilanova@ac.upc.edu, Pavel.Dovgaluk@ispras.ru Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alex Bennée --- scripts/tracetool/backend/plugin.py | 79 +++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 scripts/tracetool/backend/plugin.py -- 2.17.1 diff --git a/scripts/tracetool/backend/plugin.py b/scripts/tracetool/backend/plugin.py new file mode 100644 index 0000000000..d96b2df00a --- /dev/null +++ b/scripts/tracetool/backend/plugin.py @@ -0,0 +1,79 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +Plugin backend. +""" + +__author__ = "Alex Bennée " +__copyright__ = "Copyright 2018, Alex Bennée " +__license__ = "GPL version 2 or (at your option) any later version" + +__maintainer__ = "Alex Bennée" +__email__ = "alex.bennee@linaro.org" + + +from tracetool import out + + +PUBLIC = True + + +def generate_h_begin(events, group): + for event in events: + # prototype for plugin event + out('bool _plugin_%(api)s(%(args)s);', + api=event.api(), + args=event.args) + # prototype for plugin fn + out("typedef bool (* _plugin_%(api)s_fn)(%(args)s);", + api=event.api(), + args=event.args) + + +def generate_h(event, group): + out(' if (!_plugin_%(api)s(%(args)s)) {', + ' return;', + ' };', + api=event.api(), + args=", ".join(event.args.names())) + +def generate_c_begin(events, group): + out('#include "qemu/osdep.h"', + '#include "trace/control.h"', + '') + +def generate_c(event, group): + out('bool _plugin_%(api)s(%(args)s)', + '{', + api=event.api(), + args=event.args) + + event_id = 'TRACE_' + event.name.upper() + cond = "trace_event_get_state(%s)" % event_id + + # Forst the pre-amble, bail early if the event is not enabled and + # if it is but no plugin is enabled let the reset of the events proceed. + + out('', + ' if (!%(cond)s) {', + ' return false;', + ' }', + '', + ' uintptr_t fp = trace_event_get_plugin(&_%(event)s_EVENT);', + ' if (!fp) {', + ' return true;', + ' }', + '', + cond=cond, + event=event_id) + + # We need to construct cast to the correct fn pointer to now call the plugin + + out('', + ' _plugin_%(api)s_fn plug_fn = (_plugin_%(api)s_fn) fp;', + ' return plug_fn(%(names)s);', + '}', + '', + api=event.api(), + names=", ".join(event.args.names()))