From mboxrd@z Thu Jan 1 00:00:00 1970 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) 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> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 08/10] trace-tcg: [tracetool] Declare TCG tracing helper routines List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Generate the necessary TCG helper declarations for tracing events in gues= t code. Signed-off-by: Llu=C3=ADs Vilanova --- .gitignore | 1=20 Makefile | 2=20 Makefile.objs | 9 ++ def-helper.h | 9 ++ scripts/simpletrace.py | 2=20 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=3D$(CURDIR) =20 GENERATED_HEADERS =3D config-host.h qemu-options.def =20 -GENERATED_HEADERS +=3D trace.h +GENERATED_HEADERS +=3D trace.h trace-tcg-helper.h ifeq ($(TRACE_BACKEND),dtrace) GENERATED_HEADERS +=3D 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 +=3D $(addprefix trace/, $(trace-nested-= y)) $(trace-obj-y): $(GENERATED_HEADERS) =20 ###################################################################### +# trace tcg + +trace-tcg-helper.h-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/conf= ig-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 =20 libcacard-y =3D cac.o event.o vcard.o vreader.o vcard_emul_nss.o vcard_e= mul_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 follow= ing + values: + 1 : op generation functions were produced (GEN_HELPER was 1) + -1 : otherwise */ =20 #ifndef DEF_HELPER_H @@ -142,6 +147,7 @@ dh_ctype(ret) HELPER(name) (dh_ctype(t1), dh_ctype(t2= ), dh_ctype(t3), \ =20 #undef GEN_HELPER #define GEN_HELPER -1 +#define GEN_HELPER_CODE -1 =20 #elif GEN_HELPER =3D=3D 1 /* Gen functions. */ @@ -205,6 +211,7 @@ static inline void glue(gen_helper_, name)(dh_retvar_= decl(ret) dh_arg_decl(t1, 1 =20 #undef GEN_HELPER #define GEN_HELPER -1 +#define GEN_HELPER_CODE 1 =20 #elif GEN_HELPER =3D=3D 2 /* Register helpers. */ @@ -226,6 +233,7 @@ DEF_HELPER_FLAGS_0(name, flags, ret) =20 #undef GEN_HELPER #define GEN_HELPER -1 +#define GEN_HELPER_CODE -1 =20 #elif GEN_HELPER =3D=3D -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 =20 #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 =3D 0xfffffffffffffffe =20 trace_fmt =3D '=3DQQQQQQQQ' trace_len =3D struct.calcsize(trace_fmt) -event_re =3D re.compile(r'(disable\s+)?([a-zA-Z0-9_]+)\(([^)]*)\).*') +event_re =3D re.compile(r'(disable\s+|tcg\s+|tcg-vcpu\s+)*([a-zA-Z0-9_]= +)\(([^)]*)\).*') =20 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=3D`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 +} + =20 # Get the argument name list of a trace event get_argnames() @@ -662,6 +708,127 @@ linetostap_end_dtrace() return } =20 +linetotcg_h_nop() +{ + local has_tcg has_tcg_vcpu + has_property "$1" "tcg" && has_tcg=3D1 + has_property "$1" "tcg-vcpu" && has_tcg_vcpu=3D1 + if [ "$has_tcg" !=3D "1" -a "$has_tcg_vcpu" !=3D "1" ]; then + return + fi + + local api + api=3D$(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=3D$(get_argnames "$1" ",") + temps_names=3D"" + for argname in $argnames; do + temps_names=3D"${temps_names} __${argname}" + done + + temps_tcg_new=3D$(get_argtypes "$1" tcg_temp_new_type) + temps_new=3D$(zip_lists "$temps_tcg_new" "$argnames" "%s(%s), ") + temps_new=3D$(zip_lists "$temps_names" "$temps_new" "%s =3D%s, "= ) + temps_argtypes=3D$(get_argtypes "$1" tcg_type) + temps_new=3D$(zip_lists "$temps_argtypes" "$temps_new" "%s %s;") + + tcg_temp_free=3D$(get_argtypes "$1" tcg_temp_free_type) + temps_free=3D$(zip_lists "$tcg_temp_free" "$temps_names" "%s(%s)= ;") + fi + cat <= &2 + exit 1 + fi + convert tcg_h + cat <