From patchwork Fri May 30 12:11:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Llu=C3=ADs_Vilanova?= X-Patchwork-Id: 354114 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 9B833140076 for ; Fri, 30 May 2014 22:17:42 +1000 (EST) Received: from localhost ([::1]:53820 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WqLki-0000po-GY for incoming@patchwork.ozlabs.org; Fri, 30 May 2014 08:17:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41462) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WqLfb-00087C-JH for qemu-devel@nongnu.org; Fri, 30 May 2014 08:12:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WqLfU-0003Ry-Vu for qemu-devel@nongnu.org; Fri, 30 May 2014 08:12:23 -0400 Received: from roura.ac.upc.es ([147.83.33.10]:53067) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WqLfU-0003Rp-KS for qemu-devel@nongnu.org; Fri, 30 May 2014 08:12:16 -0400 Received: from gw-3.ac.upc.es (gw-3.ac.upc.es [147.83.30.9]) by roura.ac.upc.es (8.13.8/8.13.8) with ESMTP id s4UCBpYK003676; Fri, 30 May 2014 14:11:51 +0200 Received: from localhost (unknown [84.88.51.85]) by gw-3.ac.upc.es (Postfix) with ESMTPSA id ECBB079A; Fri, 30 May 2014 14:11:50 +0200 (CEST) From: =?utf-8?b?TGx1w61z?= Vilanova To: qemu-devel@nongnu.org Date: Fri, 30 May 2014 14:11:50 +0200 Message-Id: <20140530121150.6581.63581.stgit@fimbulvetr.bsc.es> X-Mailer: git-send-email 2.0.0.rc2 In-Reply-To: <20140530121117.6581.71271.stgit@fimbulvetr.bsc.es> References: <20140530121117.6581.71271.stgit@fimbulvetr.bsc.es> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-MIME-Autoconverted: from 8bit to quoted-printable by roura.ac.upc.es id s4UCBpYK003676 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 147.83.33.10 Cc: Peter Maydell , Stefan Hajnoczi , Richard Henderson Subject: [Qemu-devel] [PATCH v5 05/11] trace: [tcg] Declare TCG tracing helper routines X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Generates file "trace/generated-helpers.h" with TCG helper declarations to trace events in guest code at execution time ('trace_${event}_exec_proxy'). Signed-off-by: Lluís Vilanova --- .gitignore | 1 + Makefile | 2 + scripts/tracetool/__init__.py | 1 + scripts/tracetool/format/tcg_helper_h.py | 50 ++++++++++++++++++++++++++++++ trace/Makefile.objs | 24 +++++++++++--- 5 files changed, 73 insertions(+), 5 deletions(-) create mode 100644 scripts/tracetool/format/tcg_helper_h.py diff --git a/.gitignore b/.gitignore index c658613..cc6f6c4 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ /trace/generated-tracers.dtrace /trace/generated-events.h /trace/generated-events.c +/trace/generated-helpers.h /trace/generated-ust-provider.h /trace/generated-ust.c /libcacard/trace/generated-tracers.c diff --git a/Makefile b/Makefile index 3c8f19c..e3ac3fd 100644 --- a/Makefile +++ b/Makefile @@ -57,6 +57,8 @@ GENERATED_HEADERS += trace/generated-tracers-dtrace.h endif GENERATED_SOURCES += trace/generated-tracers.c +GENERATED_HEADERS += trace/generated-helpers.h + ifeq ($(findstring ust,$(TRACE_BACKENDS)),ust) GENERATED_HEADERS += trace/generated-ust-provider.h GENERATED_SOURCES += trace/generated-ust.c diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py index de48c80..a51e0f2 100644 --- a/scripts/tracetool/__init__.py +++ b/scripts/tracetool/__init__.py @@ -227,6 +227,7 @@ class Event(object): fmt) QEMU_TRACE = "trace_%(name)s" + QEMU_TRACE_TCG = QEMU_TRACE + "_tcg" def api(self, fmt=None): if fmt is None: diff --git a/scripts/tracetool/format/tcg_helper_h.py b/scripts/tracetool/format/tcg_helper_h.py new file mode 100644 index 0000000..a8ba7ba --- /dev/null +++ b/scripts/tracetool/format/tcg_helper_h.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +Generate trace/generated-helpers.h. +""" + +__author__ = "Lluís Vilanova " +__copyright__ = "Copyright 2012-2014, Lluís Vilanova " +__license__ = "GPL version 2 or (at your option) any later version" + +__maintainer__ = "Stefan Hajnoczi" +__email__ = "stefanha@linux.vnet.ibm.com" + + +from tracetool import out +from tracetool.transform import * + + +def generate(events, backend): + events = [e for e in events + if "disable" not in e.properties] + + out('/* This file is autogenerated by tracetool, do not edit. */', + '', + ) + + for e in events: + if "tcg-exec" not in e.properties: + continue + + # tracetool.generate always transforms types to host + e_args = e.original.args + + # TCG helper proxy declaration + fmt = "DEF_HELPER_FLAGS_%(argc)d(%(name)s, %(flags)svoid%(types)s)" + args = e_args.transform(HOST_2_TCG_COMPAT, HOST_2_TCG, + TCG_2_TCG_HELPER_DECL) + types = ", ".join(args.types()) + if types != "": + types = ", " + types + + flags = "TCG_CALL_NO_RWG, " + + out(fmt, + flags=flags, + argc=len(args), + name=e.api() + "_proxy", + types=types, + ) diff --git a/trace/Makefile.objs b/trace/Makefile.objs index d7a8696..0a2e6cd 100644 --- a/trace/Makefile.objs +++ b/trace/Makefile.objs @@ -49,6 +49,9 @@ util-obj-y += generated-events.o ###################################################################### # Auto-generated tracing routines +################################################## +# Execution level + $(obj)/generated-tracers.h: $(obj)/generated-tracers.h-timestamp @cmp -s $< $@ || cp $< $@ $(obj)/generated-tracers.h-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config-host.mak @@ -57,8 +60,8 @@ $(obj)/generated-tracers.h-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/conf --backends=$(TRACE_BACKENDS) \ < $< > $@," GEN $(patsubst %-timestamp,%,$@)") -###################################################################### -# Auto-generated tracing routines (non-DTrace) +############################## +# non-DTrace $(obj)/generated-tracers.c: $(obj)/generated-tracers.c-timestamp @cmp -s $< $@ || cp $< $@ @@ -70,9 +73,8 @@ $(obj)/generated-tracers.c-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/conf $(obj)/generated-tracers.o: $(obj)/generated-tracers.c $(obj)/generated-tracers.h - -###################################################################### -# Auto-generated DTrace code +############################## +# DTrace # Normal practice is to name DTrace probe file with a '.d' extension # but that gets picked up by QEMU's Makefile as an external dependency @@ -94,6 +96,18 @@ $(obj)/generated-tracers-dtrace.o: $(obj)/generated-tracers-dtrace.dtrace util-obj-y += generated-tracers-dtrace.o endif +################################################## +# Translation level + +$(obj)/generated-helpers.h: $(obj)/generated-helpers.h-timestamp +$(obj)/generated-helpers.h-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config-host.mak + $(call quiet-command,$(TRACETOOL) \ + --format=tcg-helper-h \ + --backend=$(TRACE_BACKENDS) \ + < $< > $@," GEN $(patsubst %-timestamp,%,$@)") + @cmp -s $@ $(patsubst %-timestamp,%,$@) || cp $@ $(patsubst %-timestamp,%,$@) + + ###################################################################### # Backend code