From patchwork Thu Dec 8 22:49:54 2011 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: 130258 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8101F1007D1 for ; Fri, 9 Dec 2011 09:50:18 +1100 (EST) Received: from localhost ([::1]:39030 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RYmn9-0007b2-S1 for incoming@patchwork.ozlabs.org; Thu, 08 Dec 2011 17:50:15 -0500 Received: from eggs.gnu.org ([140.186.70.92]:33169) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RYmn0-0007Or-Nw for qemu-devel@nongnu.org; Thu, 08 Dec 2011 17:50:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RYmmx-0008Nz-Pv for qemu-devel@nongnu.org; Thu, 08 Dec 2011 17:50:06 -0500 Received: from gw.ac.upc.edu ([147.83.30.3]:37256) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RYmmx-0008Nu-7M for qemu-devel@nongnu.org; Thu, 08 Dec 2011 17:50:03 -0500 Received: from localhost (unknown [84.88.53.92]) by gw.ac.upc.edu (Postfix) with ESMTP id E8F686B02C9 for ; Thu, 8 Dec 2011 23:50:01 +0100 (CET) To: qemu-devel@nongnu.org From: =?utf-8?b?TGx1w61z?= Vilanova Date: Thu, 08 Dec 2011 23:49:54 +0100 Message-ID: <20111208224954.21668.36374.stgit@ginnungagap.bsc.es> In-Reply-To: <20111208224750.21668.26153.stgit@ginnungagap.bsc.es> References: <20111208224750.21668.26153.stgit@ginnungagap.bsc.es> User-Agent: StGit/0.15 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 147.83.30.3 Subject: [Qemu-devel] [PATCH 08/10] trace-tcg: [tracetool] 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 Generate the necessary TCG helper declarations for tracing events in guest code. Signed-off-by: LluĂ­s Vilanova --- .gitignore | 1 Makefile | 2 Makefile.objs | 9 ++ def-helper.h | 9 ++ scripts/simpletrace.py | 2 scripts/tracetool | 202 ++++++++++++++++++++++++++++++++++++++++++++++-- 6 files changed, 214 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 406f75f..d47b586 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ trace.h trace.c trace-dtrace.h trace-dtrace.dtrace +trace-tcg-helper.h *-timestamp *-softmmu *-darwin-user diff --git a/Makefile b/Makefile index 506db1b..516622a 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ BUILD_DIR=$(CURDIR) GENERATED_HEADERS = config-host.h qemu-options.def -GENERATED_HEADERS += trace.h +GENERATED_HEADERS += trace.h trace-tcg-helper.h ifeq ($(TRACE_BACKEND),dtrace) GENERATED_HEADERS += trace-dtrace.h endif diff --git a/Makefile.objs b/Makefile.objs index d7a6539..8f97709 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -398,6 +398,15 @@ trace-obj-y += $(addprefix trace/, $(trace-nested-y)) $(trace-obj-y): $(GENERATED_HEADERS) ###################################################################### +# trace tcg + +trace-tcg-helper.h-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config-host.mak + $(call quiet-command,sh $(SRC_PATH)/scripts/tracetool $(TRACETOOL_EXTRA) --tcg --tcg-h < $< > $@," GEN $(TARGET_DIR)trace-tcg-helper.h") + @cmp -s $@ trace-tcg-helper.h || cp $@ trace-tcg-helper.h + +trace-tcg-helper.h: trace-tcg-helper.h-timestamp + +###################################################################### # smartcard libcacard-y = cac.o event.o vcard.o vreader.o vcard_emul_nss.o vcard_emul_type.o card_7816.o diff --git a/def-helper.h b/def-helper.h index 8a822c7..c4fce2d 100644 --- a/def-helper.h +++ b/def-helper.h @@ -13,6 +13,11 @@ helper.c, defining: GEN_HELPER 1 to produce op generation functions (gen_helper_*) GEN_HELPER 2 to do runtime registration helper functions. + + After including this header the GEN_HELPER_MACRO will have the following + values: + 1 : op generation functions were produced (GEN_HELPER was 1) + -1 : otherwise */ #ifndef DEF_HELPER_H @@ -142,6 +147,7 @@ dh_ctype(ret) HELPER(name) (dh_ctype(t1), dh_ctype(t2), dh_ctype(t3), \ #undef GEN_HELPER #define GEN_HELPER -1 +#define GEN_HELPER_CODE -1 #elif GEN_HELPER == 1 /* Gen functions. */ @@ -205,6 +211,7 @@ static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) dh_arg_decl(t1, 1 #undef GEN_HELPER #define GEN_HELPER -1 +#define GEN_HELPER_CODE 1 #elif GEN_HELPER == 2 /* Register helpers. */ @@ -226,6 +233,7 @@ DEF_HELPER_FLAGS_0(name, flags, ret) #undef GEN_HELPER #define GEN_HELPER -1 +#define GEN_HELPER_CODE -1 #elif GEN_HELPER == -1 /* Undefine macros. */ @@ -236,5 +244,6 @@ DEF_HELPER_FLAGS_0(name, flags, ret) #undef DEF_HELPER_FLAGS_3 #undef DEF_HELPER_FLAGS_4 #undef GEN_HELPER +#undef GEN_HELPER_CODE #endif diff --git a/scripts/simpletrace.py b/scripts/simpletrace.py index f55e5e6..3476d6c 100755 --- a/scripts/simpletrace.py +++ b/scripts/simpletrace.py @@ -20,7 +20,7 @@ dropped_event_id = 0xfffffffffffffffe trace_fmt = '=QQQQQQQQ' trace_len = struct.calcsize(trace_fmt) -event_re = re.compile(r'(disable\s+)?([a-zA-Z0-9_]+)\(([^)]*)\).*') +event_re = re.compile(r'(disable\s+|tcg\s+|tcg-vcpu\s+)*([a-zA-Z0-9_]+)\(([^)]*)\).*') def parse_events(fobj): """Parse a trace-events file into {event_num: (name, arg1, ...)}.""" diff --git a/scripts/tracetool b/scripts/tracetool index 1d8a637..5431f2d 100755 --- a/scripts/tracetool +++ b/scripts/tracetool @@ -13,7 +13,7 @@ set -f usage() { cat >&2 <&2 + exit 1 + ;; + esac +} + +tcg_helper_decl_type() +{ + local type + type=`tcg_type "$1"` + case "$type" in + "TCGv") echo "tl" ;; + "TCGv_ptr") echo "ptr" ;; + "TCGv_i32") echo "i32" ;; + "TCGv_i64") echo "i64" ;; + *) echo "Don't know how to translate type $1 into a TCG helper declaration type" >&2 + exit 1 + ;; + esac +} + # Get the argument name list of a trace event get_argnames() @@ -662,6 +708,127 @@ linetostap_end_dtrace() return } +linetotcg_h_nop() +{ + local has_tcg has_tcg_vcpu + has_property "$1" "tcg" && has_tcg=1 + has_property "$1" "tcg-vcpu" && has_tcg_vcpu=1 + if [ "$has_tcg" != "1" -a "$has_tcg_vcpu" != "1" ]; then + return + fi + + local api + api=$(get_api_name "$1") + + cat <&2 + exit 1 + fi + echo "DEF_HELPER_$argc(${api}_proxy, void$proxy_argtypes)" + else + echo "DEF_HELPER_FLAGS_$argc(${api}_proxy, TCG_CALL_CONST, void$proxy_argtypes)" + fi + + # mixed-type to TCG helper bridge + local argnames argname temps_names + local temps_tcg_new temps_argtypes temps_new + local temps_tcg_free temps_free + if [ $argc -ne 0 ]; then + argnames=$(get_argnames "$1" ",") + temps_names="" + for argname in $argnames; do + temps_names="${temps_names} __${argname}" + done + + temps_tcg_new=$(get_argtypes "$1" tcg_temp_new_type) + temps_new=$(zip_lists "$temps_tcg_new" "$argnames" "%s(%s), ") + temps_new=$(zip_lists "$temps_names" "$temps_new" "%s =%s, ") + temps_argtypes=$(get_argtypes "$1" tcg_type) + temps_new=$(zip_lists "$temps_argtypes" "$temps_new" "%s %s;") + + tcg_temp_free=$(get_argtypes "$1" tcg_temp_free_type) + temps_free=$(zip_lists "$tcg_temp_free" "$temps_names" "%s(%s);") + fi + cat <&2 + exit 1 + fi + convert tcg_h + cat <