From nobody Fri Nov 7 12:58:04 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1538754720508212.50818688884328; Fri, 5 Oct 2018 08:52:00 -0700 (PDT) Received: from localhost ([::1]:35706 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SOU-0000yp-BK for importer@patchew.org; Fri, 05 Oct 2018 11:51:58 -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) 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) 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-Google-Smtp-Source: ACcGV61JNZYOHhCA1yizaLUBai4+Rl1BKDYGAlNuWLBHdjOLA20kbjDmCd7TRlXenSXeHRjWHr9khA== X-Received: by 2002:adf:f50b:: with SMTP id q11-v6mr8848542wro.246.1538754566687; Fri, 05 Oct 2018 08:49:26 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=20Benn=C3=A9e?= , vilanova@ac.upc.edu, Pavel.Dovgaluk@ispras.ru Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Signed-off-by: Alex Benn=C3=A9e --- scripts/tracetool/backend/plugin.py | 79 +++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 scripts/tracetool/backend/plugin.py diff --git a/scripts/tracetool/backend/plugin.py b/scripts/tracetool/backen= d/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__ =3D "Alex Benn=C3=A9e " +__copyright__ =3D "Copyright 2018, Alex Benn=C3=A9e " +__license__ =3D "GPL version 2 or (at your option) any later version" + +__maintainer__ =3D "Alex Benn=C3=A9e" +__email__ =3D "alex.bennee@linaro.org" + + +from tracetool import out + + +PUBLIC =3D True + + +def generate_h_begin(events, group): + for event in events: + # prototype for plugin event + out('bool _plugin_%(api)s(%(args)s);', + api=3Devent.api(), + args=3Devent.args) + # prototype for plugin fn + out("typedef bool (* _plugin_%(api)s_fn)(%(args)s);", + api=3Devent.api(), + args=3Devent.args) + + +def generate_h(event, group): + out(' if (!_plugin_%(api)s(%(args)s)) {', + ' return;', + ' };', + api=3Devent.api(), + args=3D", ".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=3Devent.api(), + args=3Devent.args) + + event_id =3D 'TRACE_' + event.name.upper() + cond =3D "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 procee= d. + + out('', + ' if (!%(cond)s) {', + ' return false;', + ' }', + '', + ' uintptr_t fp =3D trace_event_get_plugin(&_%(event)s_EVENT);', + ' if (!fp) {', + ' return true;', + ' }', + '', + cond=3Dcond, + event=3Devent_id) + + # We need to construct cast to the correct fn pointer to now call the = plugin + + out('', + ' _plugin_%(api)s_fn plug_fn =3D (_plugin_%(api)s_fn) fp;', + ' return plug_fn(%(names)s);', + '}', + '', + api=3Devent.api(), + names=3D", ".join(event.args.names())) --=20 2.17.1