From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40086) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XHCHX-0000nA-7B for qemu-devel@nongnu.org; Tue, 12 Aug 2014 09:38:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XHCHS-00085m-61 for qemu-devel@nongnu.org; Tue, 12 Aug 2014 09:38:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52845) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XHCHR-00085V-Um for qemu-devel@nongnu.org; Tue, 12 Aug 2014 09:38:26 -0400 From: Stefan Hajnoczi Date: Tue, 12 Aug 2014 14:37:47 +0100 Message-Id: <1407850675-11890-11-git-send-email-stefanha@redhat.com> In-Reply-To: <1407850675-11890-1-git-send-email-stefanha@redhat.com> References: <1407850675-11890-1-git-send-email-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 10/18] trace: [tcg] Define TCG tracing helper routines List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Llu=C3=ADs=20Vilanova?= , Stefan Hajnoczi From: Llu=C3=ADs Vilanova Generates file "trace/generated-helpers.c" with TCG helper definitions to= trace events in guest code at execution time. The helpers ('helper_trace_${event}_exec_proxy') cast the TCG-compatible = native argument types to their original types (as defined in "trace-events") and= call the tracing routine ('trace_${event}_exec'). Signed-off-by: Llu=C3=ADs Vilanova Signed-off-by: Stefan Hajnoczi --- .gitignore | 1 + Makefile | 1 + Makefile.objs | 7 ++++- Makefile.target | 5 ++++ scripts/tracetool/format/tcg_helper_c.py | 50 ++++++++++++++++++++++++++= ++++++ trace/Makefile.objs | 12 ++++++++ 6 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 scripts/tracetool/format/tcg_helper_c.py diff --git a/.gitignore b/.gitignore index da56d70..643b34b 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ /trace/generated-events.h /trace/generated-events.c /trace/generated-helpers.h +/trace/generated-helpers.c /trace/generated-ust-provider.h /trace/generated-ust.c /libcacard/trace/generated-tracers.c diff --git a/Makefile b/Makefile index 84e9ad4..09601f7 100644 --- a/Makefile +++ b/Makefile @@ -58,6 +58,7 @@ endif GENERATED_SOURCES +=3D trace/generated-tracers.c =20 GENERATED_HEADERS +=3D trace/generated-helpers.h +GENERATED_SOURCES +=3D trace/generated-helpers.c =20 ifeq ($(findstring ust,$(TRACE_BACKENDS)),ust) GENERATED_HEADERS +=3D trace/generated-ust-provider.h diff --git a/Makefile.objs b/Makefile.objs index 1f76cea..84b86af 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -1,7 +1,7 @@ ####################################################################### # Common libraries for tools and emulators stub-obj-y =3D stubs/ -util-obj-y =3D util/ qobject/ qapi/ trace/ +util-obj-y =3D util/ qobject/ qapi/ =20 ####################################################################### # block-obj-y is code used by both qemu system emulation and qemu-img @@ -107,6 +107,11 @@ version-obj-$(CONFIG_WIN32) +=3D $(BUILD_DIR)/versio= n.o version-lobj-$(CONFIG_WIN32) +=3D $(BUILD_DIR)/version.lo =20 ###################################################################### +# tracing +util-obj-y +=3D trace/ +target-obj-y +=3D trace/ + +###################################################################### # guest agent =20 # FIXME: a few definitions from qapi-types.o/qapi-visit.o are needed diff --git a/Makefile.target b/Makefile.target index 44fa6a2..1e8d7ab 100644 --- a/Makefile.target +++ b/Makefile.target @@ -159,15 +159,20 @@ endif # CONFIG_SOFTMMU dummy :=3D $(call unnest-vars,,obj-y) all-obj-y :=3D $(obj-y) =20 +target-obj-y :=3D block-obj-y :=3D common-obj-y :=3D include $(SRC_PATH)/Makefile.objs +dummy :=3D $(call unnest-vars,,target-obj-y) +target-obj-y-save :=3D $(target-obj-y) dummy :=3D $(call unnest-vars,.., \ block-obj-y \ block-obj-m \ common-obj-y \ common-obj-m) +target-obj-y :=3D $(target-obj-y-save) all-obj-y +=3D $(common-obj-y) +all-obj-y +=3D $(target-obj-y) all-obj-$(CONFIG_SOFTMMU) +=3D $(block-obj-y) =20 # build either PROG or PROGW diff --git a/scripts/tracetool/format/tcg_helper_c.py b/scripts/tracetool= /format/tcg_helper_c.py new file mode 100644 index 0000000..96655a0 --- /dev/null +++ b/scripts/tracetool/format/tcg_helper_c.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +Generate trace/generated-helpers.c. +""" + +__author__ =3D "Llu=C3=ADs Vilanova " +__copyright__ =3D "Copyright 2012-2014, Llu=C3=ADs Vilanova " +__license__ =3D "GPL version 2 or (at your option) any later version" + +__maintainer__ =3D "Stefan Hajnoczi" +__email__ =3D "stefanha@linux.vnet.ibm.com" + + +from tracetool import out +from tracetool.transform import * + + +def generate(events, backend): + events =3D [e for e in events + if "disable" not in e.properties] + + out('/* This file is autogenerated by tracetool, do not edit. */', + '', + '#include "qemu-common.h"', + '#include "trace.h"', + '#include "exec/helper-proto.h"', + '', + ) + + for e in events: + if "tcg-exec" not in e.properties: + continue + + # tracetool.generate always transforms types to host + e_args =3D e.original.args + + values =3D ["(%s)%s" % (t, n) + for t, n in e.args.transform(TCG_2_TCG_HELPER_DEF)] + + out('void %(name_tcg)s(%(args)s)', + '{', + ' %(name)s(%(values)s);', + '}', + name_tcg=3D"helper_%s_proxy" % e.api(), + name=3De.api(), + args=3De_args.transform(HOST_2_TCG_COMPAT, TCG_2_TCG_HELPER_= DEF), + values=3D", ".join(values), + ) diff --git a/trace/Makefile.objs b/trace/Makefile.objs index 0a2e6cd..2d36142 100644 --- a/trace/Makefile.objs +++ b/trace/Makefile.objs @@ -107,6 +107,18 @@ $(obj)/generated-helpers.h-timestamp: $(SRC_PATH)/tr= ace-events $(BUILD_DIR)/conf < $< > $@," GEN $(patsubst %-timestamp,%,$@)") @cmp -s $@ $(patsubst %-timestamp,%,$@) || cp $@ $(patsubst %-timestamp= ,%,$@) =20 +$(obj)/generated-helpers.c: $(obj)/generated-helpers.c-timestamp +$(obj)/generated-helpers.c-timestamp: $(SRC_PATH)/trace-events $(BUILD_D= IR)/config-host.mak + $(call quiet-command,$(TRACETOOL) \ + --format=3Dtcg-helper-c \ + --backend=3D$(TRACE_BACKENDS) \ + < $< > $@," GEN $(patsubst %-timestamp,%,$@)") + @cmp -s $@ $(patsubst %-timestamp,%,$@) || cp $@ $(patsubst %-timestamp= ,%,$@) + +$(obj)/generated-helpers.o: $(obj)/generated-helpers.c + +target-obj-y +=3D generated-helpers.o + =20 ###################################################################### # Backend code --=20 1.9.3