From patchwork Thu Nov 4 22:37:01 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?Q?Llu=C3=ADs?= X-Patchwork-Id: 70198 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BA3D1B70D6 for ; Fri, 5 Nov 2010 09:57:51 +1100 (EST) Received: from localhost ([127.0.0.1]:46863 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PE8kf-0005FH-0I for incoming@patchwork.ozlabs.org; Thu, 04 Nov 2010 18:57:49 -0400 Received: from [140.186.70.92] (port=41866 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PE8Qy-0005tg-Sl for qemu-devel@nongnu.org; Thu, 04 Nov 2010 18:38:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PE8QD-0002jG-Ps for qemu-devel@nongnu.org; Thu, 04 Nov 2010 18:36:43 -0400 Received: from mailout-de.gmx.net ([213.165.64.22]:38277 helo=mail.gmx.net) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1PE8QD-0002j2-EB for qemu-devel@nongnu.org; Thu, 04 Nov 2010 18:36:41 -0400 Received: (qmail invoked by alias); 04 Nov 2010 22:36:39 -0000 Received: from unknown (EHLO localhost) [84.88.53.92] by mail.gmx.net (mp008) with SMTP; 04 Nov 2010 23:36:39 +0100 X-Authenticated: #12333383 X-Provags-ID: V01U2FsdGVkX1+30i8UAlm3rjYtldwhdVUOn/x7E7IlaxCek+oWW4 /o47Vnse7+CamR To: qemu-devel@nongnu.org From: =?utf-8?b?TGx1w61z?= Date: Thu, 04 Nov 2010 23:37:01 +0100 Message-ID: <20101104223701.16931.68946.stgit@ginnungagap.bsc.es> In-Reply-To: <20101104223628.16931.21689.stgit@ginnungagap.bsc.es> References: <20101104223628.16931.21689.stgit@ginnungagap.bsc.es> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Y-GMX-Trusted: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Subject: [Qemu-devel] [PATCH v2 2/4] trace-gen: auto-generate TCG helper routines for tracing X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Auto-generates file "trace-helper.h" to provide TCG helpers and "trace-helper.c" to proxy these helpers onto trace event routines. Only trace events with the 'gen' property are affected. Signed-off-by: LluĂ­s Vilanova --- .gitignore | 2 + Makefile | 15 +++++++ Makefile.target | 5 +- simpletrace.py | 2 - trace-events | 5 ++ tracetool | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 135 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index e4a351d..758f457 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,8 @@ config-host.* config-target.* trace.h trace.c +trace-helper.h +trace-helper.c *-timestamp *-softmmu *-darwin-user diff --git a/Makefile b/Makefile index 97cb3b4..4effdcc 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # Makefile for QEMU. -GENERATED_HEADERS = config-host.h trace.h qemu-options.def +GENERATED_HEADERS = config-host.h trace.h trace-helper.h trace-helper.c qemu-options.def ifneq ($(wildcard config-host.mak),) # Put the all: rule here so that config-host.mak can contain dependencies. @@ -120,6 +120,18 @@ trace.c-timestamp: $(SRC_PATH)/trace-events config-host.mak trace.o: trace.c $(GENERATED_HEADERS) +trace-helper.h: trace-helper.h-timestamp +trace-helper.h-timestamp: $(SRC_PATH)/trace-events config-host.mak + $(call quiet-command,sh $(SRC_PATH)/tracetool $(TRACETOOL_EXTRA) --helper --$(TRACE_BACKEND) -h < $< > $@," GEN trace-helper.h") + @cmp -s $@ trace-helper.h || cp $@ trace-helper.h + +trace-helper.c: trace-helper.c-timestamp +trace-helper.c-timestamp: $(SRC_PATH)/trace-events config-host.mak + $(call quiet-command,sh $(SRC_PATH)/tracetool $(TRACETOOL_EXTRA) --helper --$(TRACE_BACKEND) -c < $< > $@," GEN trace-helper.c") + @cmp -s $@ trace-helper.c || cp $@ trace-helper.c + +trace-helper.o: trace-helper.c $(GENERATED_HEADERS) + simpletrace.o: simpletrace.c $(GENERATED_HEADERS) version.o: $(SRC_PATH)/version.rc config-host.mak @@ -157,6 +169,7 @@ clean: rm -f slirp/*.o slirp/*.d audio/*.o audio/*.d block/*.o block/*.d net/*.o net/*.d fsdev/*.o fsdev/*.d ui/*.o ui/*.d rm -f qemu-img-cmds.h rm -f trace.c trace.h trace.c-timestamp trace.h-timestamp + rm -f trace-helper.c trace-helper.h trace-helper.h-timestamp trace-helper.c-timestamp $(MAKE) -C tests clean for d in $(ALL_SUBDIRS) libhw32 libhw64 libuser libdis libdis-user; do \ if test -d $$d; then $(MAKE) -C $$d $@ || exit 1; fi; \ diff --git a/Makefile.target b/Makefile.target index 7a92e02..0c8b0ac 100644 --- a/Makefile.target +++ b/Makefile.target @@ -378,9 +378,8 @@ endif $(QEMU_PROG)-prepare: $(GENERATED_HEADERS) $(LIBBACKDOOR_LIB) $(LIBINSTRUMENT_LIB) $(QEMU_PROG) -$(QEMU_PROG): $(obj-y) $(obj-$(TARGET_BASE_ARCH)-y) $(LIBBACKDOOR_LIB) $(LIBINSTRUMENT_LIB) - $(call LINK,$(obj-y) $(obj-$(TARGET_BASE_ARCH)-y)) $(LIBBACKDOOR_LIB) $(LIBINSTRUMENT_LIB) - +$(QEMU_PROG): trace-helper.o $(obj-y) $(obj-$(TARGET_BASE_ARCH)-y) $(LIBBACKDOOR_LIB) $(LIBINSTRUMENT_LIB) + $(call LINK,trace-helper.o $(obj-y) $(obj-$(TARGET_BASE_ARCH)-y)) $(LIBBACKDOOR_LIB) $(LIBINSTRUMENT_LIB) gdbstub-xml.c: $(TARGET_XML_FILES) $(SRC_PATH)/feature_to_c.sh $(call quiet-command,rm -f $@ && $(SHELL) $(SRC_PATH)/feature_to_c.sh $@ $(TARGET_XML_FILES)," GEN $(TARGET_DIR)$@") diff --git a/simpletrace.py b/simpletrace.py index 6d8100e..1cfc3de 100755 --- a/simpletrace.py +++ b/simpletrace.py @@ -19,7 +19,7 @@ header_version = 0 trace_fmt = '=QQQQQQQQ' trace_len = struct.calcsize(trace_fmt) -event_re = re.compile(r'(disable\s+|instrument\s+)*([a-zA-Z0-9_]+)\(([^)]*)\).*') +event_re = re.compile(r'(disable\s+|instrument\s+|gen\s+)*([a-zA-Z0-9_]+)\(([^)]*)\).*') def err(msg): sys.stderr.write(msg + '\n') diff --git a/trace-events b/trace-events index fefac91..52e4128 100644 --- a/trace-events +++ b/trace-events @@ -38,6 +38,11 @@ # is identified by the '--with-instrument' configure option). # The original backend-specific function is still available under the name # 'trace_##name##_backend'. +# +# - gen +# Provide trace events suitable for using during TCG code generation. +# Generates TCG function helpers reachable through 'helper_trace_gen_##name' +# which proxy their calls onto 'trace_##name'. # qemu-malloc.c disable qemu_malloc(size_t size, void *ptr) "size %zu ptr %p" diff --git a/tracetool b/tracetool index 6f48215..28d434a 100755 --- a/tracetool +++ b/tracetool @@ -237,6 +237,38 @@ native_type() ################################################################################ ### Backend code +### nil -- H +begin_h_nil() +{ + return +} + +line_h_nil() +{ + return +} + +end_h_nil() +{ + return +} + +### nil -- C +begin_c_nil() +{ + return +} + +line_c_nil() +{ + return +} + +end_c_nil() +{ + return +} + ### nop -- H begin_h_nop() { @@ -514,6 +546,83 @@ line_c_regular() return } +### Helper -- H +traceto_h_helper() +{ + echo "/* This file is autogenerated by tracetool, do not edit. */" + convert h $1 nil +} + +helper_h_type() +{ + case "$1" in + "void *"|"TCGv_ptr") echo "ptr";; + "uint32_t"|"TCGv_i64") echo "i32";; + "uint64_t"|"TCGv_i32") echo "i64";; + *) echo "i64";; + esac +} + +line_h_helper() +{ + local gen + gen=$(get_property "$1" "gen") + [ "$gen" = "1" ] || return + + local name argc argtypes + name=$(get_event_name "$1") + argc=$(get_argc "$1") + if [ "$argc" != "0" ]; then + argtypes=$(get_argtypes "$1" helper_h_type) + argtypes=", $argtypes" + fi + echo "DEF_HELPER_$argc(trace_proxy_$name, void$argtypes)" +} + +### Helper -- C +traceto_c_helper() +{ + cat <