From patchwork Fri Jun 17 15:59:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 637189 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 3rWQjK3HNLz9t17 for ; Sat, 18 Jun 2016 02:30:45 +1000 (AEST) Received: from localhost ([::1]:58891 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDwfL-0002dl-3o for incoming@patchwork.ozlabs.org; Fri, 17 Jun 2016 12:30:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54652) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDwBm-00040n-Kl for qemu-devel@nongnu.org; Fri, 17 Jun 2016 12:00:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDwBf-0002Vj-Rv for qemu-devel@nongnu.org; Fri, 17 Jun 2016 12:00:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56911) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDwBf-0002Vd-Jd for qemu-devel@nongnu.org; Fri, 17 Jun 2016 12:00:03 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1BFC571093; Fri, 17 Jun 2016 16:00:03 +0000 (UTC) Received: from localhost (ovpn-112-65.ams2.redhat.com [10.36.112.65]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u5HG01nr008927; Fri, 17 Jun 2016 12:00:02 -0400 From: Stefan Hajnoczi To: Date: Fri, 17 Jun 2016 16:59:14 +0100 Message-Id: <1466179193-11232-4-git-send-email-stefanha@redhat.com> In-Reply-To: <1466179193-11232-1-git-send-email-stefanha@redhat.com> References: <1466179193-11232-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 17 Jun 2016 16:00:03 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 03/42] trace: add build framework for merging trace-events files X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Stefan Hajnoczi Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: "Daniel P. Berrange" Switch make rules over to use trace-events-all as the master trace events input file. Add rule that will construct trace-events-all from $(trace-events-y). Signed-off-by: Daniel P. Berrange Message-id: 1466066426-16657-2-git-send-email-berrange@redhat.com Signed-off-by: Stefan Hajnoczi --- .gitignore | 1 + Makefile | 2 +- Makefile.objs | 4 ++++ Makefile.target | 6 +++--- docs/tracing.txt | 32 ++++++++++++++++++-------------- qemu-options.hx | 8 ++++---- trace/Makefile.objs | 25 ++++++++++++++----------- 7 files changed, 45 insertions(+), 33 deletions(-) diff --git a/.gitignore b/.gitignore index 38ee1c5..9b6a968 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ /config-target.* /config.status /config-temp +/trace-events-all /trace/generated-tracers.h /trace/generated-tracers.c /trace/generated-tracers-dtrace.h diff --git a/Makefile b/Makefile index 53e4119..7087fc2 100644 --- a/Makefile +++ b/Makefile @@ -487,7 +487,7 @@ endif set -e; for x in $(KEYMAPS); do \ $(INSTALL_DATA) $(SRC_PATH)/pc-bios/keymaps/$$x "$(DESTDIR)$(qemu_datadir)/keymaps"; \ done - $(INSTALL_DATA) $(SRC_PATH)/trace-events "$(DESTDIR)$(qemu_datadir)/trace-events" + $(INSTALL_DATA) $(BUILD_DIR)/trace-events-all "$(DESTDIR)$(qemu_datadir)/trace-events-all" for d in $(TARGET_DIRS); do \ $(MAKE) $(SUBDIR_MAKEFLAGS) TARGET_DIR=$$d/ -C $$d $@ || exit 1 ; \ done diff --git a/Makefile.objs b/Makefile.objs index da49b71..697fc66 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -115,3 +115,7 @@ qga-vss-dll-obj-y = qga/ # contrib ivshmem-client-obj-y = contrib/ivshmem-client/ ivshmem-server-obj-y = contrib/ivshmem-server/ + + +###################################################################### +trace-events-y = trace-events diff --git a/Makefile.target b/Makefile.target index 495b474..d720b3e 100644 --- a/Makefile.target +++ b/Makefile.target @@ -48,7 +48,7 @@ else TARGET_TYPE=system endif -$(QEMU_PROG).stp-installed: $(SRC_PATH)/trace-events +$(QEMU_PROG).stp-installed: $(BUILD_DIR)/trace-events-all $(call quiet-command,$(TRACETOOL) \ --format=stap \ --backends=$(TRACE_BACKENDS) \ @@ -57,7 +57,7 @@ $(QEMU_PROG).stp-installed: $(SRC_PATH)/trace-events --target-type=$(TARGET_TYPE) \ < $< > $@," GEN $(TARGET_DIR)$(QEMU_PROG).stp-installed") -$(QEMU_PROG).stp: $(SRC_PATH)/trace-events +$(QEMU_PROG).stp: $(BUILD_DIR)/trace-events-all $(call quiet-command,$(TRACETOOL) \ --format=stap \ --backends=$(TRACE_BACKENDS) \ @@ -66,7 +66,7 @@ $(QEMU_PROG).stp: $(SRC_PATH)/trace-events --target-type=$(TARGET_TYPE) \ < $< > $@," GEN $(TARGET_DIR)$(QEMU_PROG).stp") -$(QEMU_PROG)-simpletrace.stp: $(SRC_PATH)/trace-events +$(QEMU_PROG)-simpletrace.stp: $(BUILD_DIR)/trace-events-all $(call quiet-command,$(TRACETOOL) \ --format=simpletrace-stap \ --backends=$(TRACE_BACKENDS) \ diff --git a/docs/tracing.txt b/docs/tracing.txt index 0bd6b9c..29f2f9a 100644 --- a/docs/tracing.txt +++ b/docs/tracing.txt @@ -23,20 +23,24 @@ for debugging, profiling, and observing execution. 4. Pretty-print the binary trace file: - ./scripts/simpletrace.py trace-events trace-* # Override * with QEMU + ./scripts/simpletrace.py trace-events-all trace-* # Override * with QEMU == Trace events == -There is a set of static trace events declared in the "trace-events" source -file. Each trace event declaration names the event, its arguments, and the -format string which can be used for pretty-printing: +Each directory in the source tree can declare a set of static trace events +in a "trace-events" file. Each trace event declaration names the event, its +arguments, and the format string which can be used for pretty-printing: qemu_vmalloc(size_t size, void *ptr) "size %zu ptr %p" qemu_vfree(void *ptr) "ptr %p" -The "trace-events" file is processed by the "tracetool" script during build to -generate code for the trace events. Trace events are invoked directly from -source code like this: +All "trace-events" files must be listed in the "trace-event-y" make variable +in the top level Makefile.objs. During build the individual files are combined +to create a "trace-events-all" file, which is processed by the "tracetool" +script during build to generate code for the trace events. The +"trace-events-all" file is also installed into "/usr/share/qemu". + +Trace events are invoked directly from source code like this: #include "trace.h" /* needed for trace event prototype */ @@ -196,12 +200,12 @@ Restriction: "ftrace" backend is restricted to Linux only. ==== Analyzing trace files ==== The "simple" backend produces binary trace files that can be formatted with the -simpletrace.py script. The script takes the "trace-events" file and the binary -trace: +simpletrace.py script. The script takes the "trace-events-all" file and the +binary trace: - ./scripts/simpletrace.py trace-events trace-12345 + ./scripts/simpletrace.py trace-events-all trace-12345 -You must ensure that the same "trace-events" file was used to build QEMU, +You must ensure that the same "trace-events-all" file was used to build QEMU, otherwise trace event declarations may have changed and output will not be consistent. @@ -259,11 +263,11 @@ probes: --binary path/to/qemu-binary \ --target-type system \ --target-name x86_64 \ - qemu.stp + qemu.stp == Trace event properties == -Each event in the "trace-events" file can be prefixed with a space-separated +Each event in the "trace-events-all" file can be prefixed with a space-separated list of zero or more of the following event properties. === "disable" === @@ -275,7 +279,7 @@ programmatically disabled. In this case you should declare such event with the "disable" property. This will effectively disable the event at compile time (by using the "nop" backend), thus having no performance impact at all on regular builds (i.e., unless you -edit the "trace-events" file). +edit the "trace-events-all" file). In addition, there might be cases where relatively complex computations must be performed to generate values that are only used as arguments for a trace diff --git a/qemu-options.hx b/qemu-options.hx index 17f15ad..44c658f 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -3677,8 +3677,8 @@ Specify tracing options. @table @option @item [enable=]@var{pattern} Immediately enable events matching @var{pattern}. -The file must contain one event name (as listed in the @file{trace-events} file) -per line; globbing patterns are accepted too. This option is only +The file must contain one event name (as listed in the @file{trace-events-all} +file) per line; globbing patterns are accepted too. This option is only available if QEMU has been compiled with the @var{simple}, @var{stderr} or @var{ftrace} tracing backend. To specify multiple events or patterns, specify the @option{-trace} option multiple times. @@ -3687,8 +3687,8 @@ Use @code{-trace help} to print a list of names of trace points. @item events=@var{file} Immediately enable events listed in @var{file}. -The file must contain one event name (as listed in the @file{trace-events} file) -per line; globbing patterns are accepted too. This option is only +The file must contain one event name (as listed in the @file{trace-events-all} +file) per line; globbing patterns are accepted too. This option is only available if QEMU has been compiled with the @var{simple}, @var{stderr} or @var{ftrace} tracing backend. diff --git a/trace/Makefile.objs b/trace/Makefile.objs index 5145b34..cbe188e 100644 --- a/trace/Makefile.objs +++ b/trace/Makefile.objs @@ -8,13 +8,16 @@ tracetool-y = $(SRC_PATH)/scripts/tracetool.py tracetool-y += $(shell find $(SRC_PATH)/scripts/tracetool -name "*.py") +$(BUILD_DIR)/trace-events-all: $(trace-events-y:%=$(SRC_PATH)/%) + $(call quiet-command,cat $^ > $@) + ###################################################################### # Auto-generated event descriptions for LTTng ust code ifeq ($(findstring ust,$(TRACE_BACKENDS)),ust) $(obj)/generated-ust-provider.h: $(obj)/generated-ust-provider.h-timestamp @cmp $< $@ >/dev/null 2>&1 || cp $< $@ -$(obj)/generated-ust-provider.h-timestamp: $(SRC_PATH)/trace-events $(tracetool-y) +$(obj)/generated-ust-provider.h-timestamp: $(BUILD_DIR)/trace-events-all $(tracetool-y) $(call quiet-command,$(TRACETOOL) \ --format=ust-events-h \ --backends=$(TRACE_BACKENDS) \ @@ -22,7 +25,7 @@ $(obj)/generated-ust-provider.h-timestamp: $(SRC_PATH)/trace-events $(tracetool- $(obj)/generated-ust.c: $(obj)/generated-ust.c-timestamp $(BUILD_DIR)/config-host.mak @cmp $< $@ >/dev/null 2>&1 || cp $< $@ -$(obj)/generated-ust.c-timestamp: $(SRC_PATH)/trace-events $(tracetool-y) +$(obj)/generated-ust.c-timestamp: $(BUILD_DIR)/trace-events-all $(tracetool-y) $(call quiet-command,$(TRACETOOL) \ --format=ust-events-c \ --backends=$(TRACE_BACKENDS) \ @@ -37,7 +40,7 @@ endif $(obj)/generated-events.h: $(obj)/generated-events.h-timestamp @cmp $< $@ >/dev/null 2>&1 || cp $< $@ -$(obj)/generated-events.h-timestamp: $(SRC_PATH)/trace-events $(tracetool-y) +$(obj)/generated-events.h-timestamp: $(BUILD_DIR)/trace-events-all $(tracetool-y) $(call quiet-command,$(TRACETOOL) \ --format=events-h \ --backends=$(TRACE_BACKENDS) \ @@ -45,7 +48,7 @@ $(obj)/generated-events.h-timestamp: $(SRC_PATH)/trace-events $(tracetool-y) $(obj)/generated-events.c: $(obj)/generated-events.c-timestamp $(BUILD_DIR)/config-host.mak @cmp $< $@ >/dev/null 2>&1 || cp $< $@ -$(obj)/generated-events.c-timestamp: $(SRC_PATH)/trace-events $(tracetool-y) +$(obj)/generated-events.c-timestamp: $(BUILD_DIR)/trace-events-all $(tracetool-y) $(call quiet-command,$(TRACETOOL) \ --format=events-c \ --backends=$(TRACE_BACKENDS) \ @@ -62,7 +65,7 @@ util-obj-y += generated-events.o $(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 $(tracetool-y) +$(obj)/generated-tracers.h-timestamp: $(BUILD_DIR)/trace-events-all $(BUILD_DIR)/config-host.mak $(tracetool-y) $(call quiet-command,$(TRACETOOL) \ --format=h \ --backends=$(TRACE_BACKENDS) \ @@ -73,7 +76,7 @@ $(obj)/generated-tracers.h-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/conf $(obj)/generated-tracers.c: $(obj)/generated-tracers.c-timestamp @cmp -s $< $@ || cp $< $@ -$(obj)/generated-tracers.c-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config-host.mak $(tracetool-y) +$(obj)/generated-tracers.c-timestamp: $(BUILD_DIR)/trace-events-all $(BUILD_DIR)/config-host.mak $(tracetool-y) $(call quiet-command,$(TRACETOOL) \ --format=c \ --backends=$(TRACE_BACKENDS) \ @@ -90,7 +93,7 @@ $(obj)/generated-tracers.o: $(obj)/generated-tracers.c $(obj)/generated-tracers. ifeq ($(findstring dtrace,$(TRACE_BACKENDS)),dtrace) $(obj)/generated-tracers-dtrace.dtrace: $(obj)/generated-tracers-dtrace.dtrace-timestamp @cmp $< $@ >/dev/null 2>&1 || cp $< $@ -$(obj)/generated-tracers-dtrace.dtrace-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config-host.mak $(tracetool-y) +$(obj)/generated-tracers-dtrace.dtrace-timestamp: $(BUILD_DIR)/trace-events-all $(BUILD_DIR)/config-host.mak $(tracetool-y) $(call quiet-command,$(TRACETOOL) \ --format=d \ --backends=$(TRACE_BACKENDS) \ @@ -109,7 +112,7 @@ endif $(obj)/generated-helpers-wrappers.h: $(obj)/generated-helpers-wrappers.h-timestamp @cmp $< $@ >/dev/null 2>&1 || cp $< $@ -$(obj)/generated-helpers-wrappers.h-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config-host.mak $(tracetool-y) +$(obj)/generated-helpers-wrappers.h-timestamp: $(BUILD_DIR)/trace-events-all $(BUILD_DIR)/config-host.mak $(tracetool-y) $(call quiet-command,$(TRACETOOL) \ --format=tcg-helper-wrapper-h \ --backend=$(TRACE_BACKENDS) \ @@ -117,7 +120,7 @@ $(obj)/generated-helpers-wrappers.h-timestamp: $(SRC_PATH)/trace-events $(BUILD_ $(obj)/generated-helpers.h: $(obj)/generated-helpers.h-timestamp @cmp $< $@ >/dev/null 2>&1 || cp $< $@ -$(obj)/generated-helpers.h-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config-host.mak $(tracetool-y) +$(obj)/generated-helpers.h-timestamp: $(BUILD_DIR)/trace-events-all $(BUILD_DIR)/config-host.mak $(tracetool-y) $(call quiet-command,$(TRACETOOL) \ --format=tcg-helper-h \ --backend=$(TRACE_BACKENDS) \ @@ -125,7 +128,7 @@ $(obj)/generated-helpers.h-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/conf $(obj)/generated-helpers.c: $(obj)/generated-helpers.c-timestamp @cmp $< $@ >/dev/null 2>&1 || cp $< $@ -$(obj)/generated-helpers.c-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config-host.mak $(tracetool-y) +$(obj)/generated-helpers.c-timestamp: $(BUILD_DIR)/trace-events-all $(BUILD_DIR)/config-host.mak $(tracetool-y) $(call quiet-command,$(TRACETOOL) \ --format=tcg-helper-c \ --backend=$(TRACE_BACKENDS) \ @@ -138,7 +141,7 @@ target-obj-y += generated-helpers.o $(obj)/generated-tcg-tracers.h: $(obj)/generated-tcg-tracers.h-timestamp @cmp $< $@ >/dev/null 2>&1 || cp $< $@ -$(obj)/generated-tcg-tracers.h-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config-host.mak $(tracetool-y) +$(obj)/generated-tcg-tracers.h-timestamp: $(BUILD_DIR)/trace-events-all $(BUILD_DIR)/config-host.mak $(tracetool-y) $(call quiet-command,$(TRACETOOL) \ --format=tcg-h \ --backend=$(TRACE_BACKENDS) \