trace: switch to modular code generation for sub-directories

Introduce rules in the top level Makefile that are able to generate
trace.[ch] files in every subdirectory which has a trace-events file.

The top level directory is handled specially, so instead of creating
trace.h, it creates trace-root.h. This allows sub-directories to
include the top level trace-root.h file, without ambiguity wrt to
the trace.g file in the current sub-dir.

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-id: 20170125161417.31949-7-berrange@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Daniel P. Berrange 2017-01-25 16:14:15 +00:00 committed by Stefan Hajnoczi
parent 2098c56a9b
commit 0ab8ed18a6
44 changed files with 283 additions and 209 deletions

22
.gitignore vendored
View File

@ -6,18 +6,12 @@
/config.status /config.status
/config-temp /config-temp
/trace-events-all /trace-events-all
/trace/generated-tracers.h
/trace/generated-tracers.c
/trace/generated-tracers-dtrace.h
/trace/generated-tracers.dtrace
/trace/generated-events.h /trace/generated-events.h
/trace/generated-events.c /trace/generated-events.c
/trace/generated-helpers-wrappers.h /trace/generated-helpers-wrappers.h
/trace/generated-helpers.h /trace/generated-helpers.h
/trace/generated-helpers.c /trace/generated-helpers.c
/trace/generated-tcg-tracers.h /trace/generated-tcg-tracers.h
/trace/generated-ust-provider.h
/trace/generated-ust.c
/ui/shader/texture-blit-frag.h /ui/shader/texture-blit-frag.h
/ui/shader/texture-blit-vert.h /ui/shader/texture-blit-vert.h
*-timestamp *-timestamp
@ -120,3 +114,19 @@ tags
TAGS TAGS
docker-src.* docker-src.*
*~ *~
trace.h
trace.c
trace-ust.h
trace-ust.h
trace-dtrace.h
trace-dtrace.dtrace
trace-root.h
trace-root.c
trace-ust-root.h
trace-ust-root.h
trace-ust-all.h
trace-ust-all.c
trace-dtrace-root.h
trace-dtrace-root.dtrace
trace-ust-all.h
trace-ust-all.c

156
Makefile
View File

@ -56,25 +56,136 @@ GENERATED_SOURCES += qmp-marshal.c qapi-types.c qapi-visit.c qapi-event.c
GENERATED_HEADERS += qmp-introspect.h GENERATED_HEADERS += qmp-introspect.h
GENERATED_SOURCES += qmp-introspect.c GENERATED_SOURCES += qmp-introspect.c
GENERATED_HEADERS += trace/generated-tracers.h
ifeq ($(findstring dtrace,$(TRACE_BACKENDS)),dtrace)
GENERATED_HEADERS += trace/generated-tracers-dtrace.h
endif
GENERATED_SOURCES += trace/generated-tracers.c
GENERATED_HEADERS += trace/generated-tcg-tracers.h GENERATED_HEADERS += trace/generated-tcg-tracers.h
GENERATED_HEADERS += trace/generated-helpers-wrappers.h GENERATED_HEADERS += trace/generated-helpers-wrappers.h
GENERATED_HEADERS += trace/generated-helpers.h GENERATED_HEADERS += trace/generated-helpers.h
GENERATED_SOURCES += trace/generated-helpers.c GENERATED_SOURCES += trace/generated-helpers.c
ifeq ($(findstring ust,$(TRACE_BACKENDS)),ust) ifdef CONFIG_TRACE_UST
GENERATED_HEADERS += trace/generated-ust-provider.h GENERATED_HEADERS += trace-ust-all.h
GENERATED_SOURCES += trace/generated-ust.c GENERATED_SOURCES += trace-ust-all.c
endif endif
GENERATED_HEADERS += module_block.h GENERATED_HEADERS += module_block.h
TRACE_HEADERS = trace-root.h $(trace-events-subdirs:%=%/trace.h)
TRACE_SOURCES = trace-root.c $(trace-events-subdirs:%=%/trace.c)
TRACE_DTRACE =
ifdef CONFIG_TRACE_DTRACE
TRACE_HEADERS += trace-dtrace-root.h $(trace-events-subdirs:%=%/trace-dtrace.h)
TRACE_DTRACE += trace-dtrace-root.dtrace $(trace-events-subdirs:%=%/trace-dtrace.dtrace)
endif
ifdef CONFIG_TRACE_UST
TRACE_HEADERS += trace-ust-root.h $(trace-events-subdirs:%=%/trace-ust.h)
endif
GENERATED_HEADERS += $(TRACE_HEADERS)
GENERATED_SOURCES += $(TRACE_SOURCES)
trace-group-name = $(shell dirname $1 | sed -e 's/[^a-zA-Z0-9]/_/g')
%/trace.h: %/trace.h-timestamp
@cmp $< $@ >/dev/null 2>&1 || cp $< $@
%/trace.h-timestamp: $(SRC_PATH)/%/trace-events $(tracetool-y)
$(call quiet-command,$(TRACETOOL) \
--group=$(call trace-group-name,$@) \
--format=h \
--backends=$(TRACE_BACKENDS) \
$< > $@,"GEN","$(@:%-timestamp=%)")
%/trace.c: %/trace.c-timestamp
@cmp $< $@ >/dev/null 2>&1 || cp $< $@
%/trace.c-timestamp: $(SRC_PATH)/%/trace-events $(tracetool-y)
$(call quiet-command,$(TRACETOOL) \
--group=$(call trace-group-name,$@) \
--format=c \
--backends=$(TRACE_BACKENDS) \
$< > $@,"GEN","$(@:%-timestamp=%)")
%/trace-ust.h: %/trace-ust.h-timestamp
@cmp $< $@ >/dev/null 2>&1 || cp $< $@
%/trace-ust.h-timestamp: $(SRC_PATH)/%/trace-events $(tracetool-y)
$(call quiet-command,$(TRACETOOL) \
--group=$(call trace-group-name,$@) \
--format=ust-events-h \
--backends=$(TRACE_BACKENDS) \
$< > $@,"GEN","$(@:%-timestamp=%)")
%/trace-dtrace.dtrace: %/trace-dtrace.dtrace-timestamp
@cmp $< $@ >/dev/null 2>&1 || cp $< $@
%/trace-dtrace.dtrace-timestamp: $(SRC_PATH)/%/trace-events $(BUILD_DIR)/config-host.mak $(tracetool-y)
$(call quiet-command,$(TRACETOOL) \
--group=$(call trace-group-name,$@) \
--format=d \
--backends=$(TRACE_BACKENDS) \
$< > $@,"GEN","$(@:%-timestamp=%)")
%/trace-dtrace.h: %/trace-dtrace.dtrace $(tracetool-y)
$(call quiet-command,dtrace -o $@ -h -s $<, "GEN","$@")
%/trace-dtrace.o: %/trace-dtrace.dtrace $(tracetool-y)
trace-root.h: trace-root.h-timestamp
@cmp $< $@ >/dev/null 2>&1 || cp $< $@
trace-root.h-timestamp: $(SRC_PATH)/trace-events $(tracetool-y)
$(call quiet-command,$(TRACETOOL) \
--group=root \
--format=h \
--backends=$(TRACE_BACKENDS) \
$< > $@,"GEN","$(@:%-timestamp=%)")
trace-root.c: trace-root.c-timestamp
@cmp $< $@ >/dev/null 2>&1 || cp $< $@
trace-root.c-timestamp: $(SRC_PATH)/trace-events $(tracetool-y)
$(call quiet-command,$(TRACETOOL) \
--group=root \
--format=c \
--backends=$(TRACE_BACKENDS) \
$< > $@,"GEN","$(@:%-timestamp=%)")
trace-ust-root.h: trace-ust-root.h-timestamp
@cmp $< $@ >/dev/null 2>&1 || cp $< $@
trace-ust-root.h-timestamp: $(SRC_PATH)/trace-events $(tracetool-y)
$(call quiet-command,$(TRACETOOL) \
--group=root \
--format=ust-events-h \
--backends=$(TRACE_BACKENDS) \
$< > $@,"GEN","$(@:%-timestamp=%)")
trace-ust-all.h: trace-ust-all.h-timestamp
@cmp $< $@ >/dev/null 2>&1 || cp $< $@
trace-ust-all.h-timestamp: $(trace-events-files) $(tracetool-y)
$(call quiet-command,$(TRACETOOL) \
--group=all \
--format=ust-events-h \
--backends=$(TRACE_BACKENDS) \
$(trace-events-files) > $@,"GEN","$(@:%-timestamp=%)")
trace-ust-all.c: trace-ust-all.c-timestamp
@cmp $< $@ >/dev/null 2>&1 || cp $< $@
trace-ust-all.c-timestamp: $(trace-events-files) $(tracetool-y)
$(call quiet-command,$(TRACETOOL) \
--group=all \
--format=ust-events-c \
--backends=$(TRACE_BACKENDS) \
$(trace-events-files) > $@,"GEN","$(@:%-timestamp=%)")
trace-dtrace-root.dtrace: trace-dtrace-root.dtrace-timestamp
@cmp $< $@ >/dev/null 2>&1 || cp $< $@
trace-dtrace-root.dtrace-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config-host.mak $(tracetool-y)
$(call quiet-command,$(TRACETOOL) \
--group=root \
--format=d \
--backends=$(TRACE_BACKENDS) \
$< > $@,"GEN","$(@:%-timestamp=%)")
trace-dtrace-root.h: trace-dtrace-root.dtrace
$(call quiet-command,dtrace -o $@ -h -s $<, "GEN","$@")
trace-dtrace-root.o: trace-dtrace-root.dtrace
# Don't try to regenerate Makefile or configure # Don't try to regenerate Makefile or configure
# We don't generate any of them # We don't generate any of them
Makefile: ; Makefile: ;
@ -160,7 +271,8 @@ dummy := $(call unnest-vars,, \
qom-obj-y \ qom-obj-y \
io-obj-y \ io-obj-y \
common-obj-y \ common-obj-y \
common-obj-m) common-obj-m \
trace-obj-y)
ifneq ($(wildcard config-host.mak),) ifneq ($(wildcard config-host.mak),)
include $(SRC_PATH)/tests/Makefile.include include $(SRC_PATH)/tests/Makefile.include
@ -223,7 +335,7 @@ subdir-dtc:dtc/libfdt dtc/tests
dtc/%: dtc/%:
mkdir -p $@ mkdir -p $@
$(SUBDIR_RULES): libqemuutil.a libqemustub.a $(common-obj-y) $(qom-obj-y) $(crypto-aes-obj-$(CONFIG_USER_ONLY)) $(SUBDIR_RULES): libqemuutil.a libqemustub.a $(common-obj-y) $(qom-obj-y) $(crypto-aes-obj-$(CONFIG_USER_ONLY)) $(trace-obj-y)
ROMSUBDIR_RULES=$(patsubst %,romsubdir-%, $(ROMS)) ROMSUBDIR_RULES=$(patsubst %,romsubdir-%, $(ROMS))
# Only keep -O and -g cflags # Only keep -O and -g cflags
@ -247,15 +359,17 @@ libqemuutil.a: $(util-obj-y)
###################################################################### ######################################################################
COMMON_LDADDS = $(trace-obj-y) libqemuutil.a libqemustub.a
qemu-img.o: qemu-img-cmds.h qemu-img.o: qemu-img-cmds.h
qemu-img$(EXESUF): qemu-img.o $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) libqemuutil.a libqemustub.a qemu-img$(EXESUF): qemu-img.o $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
qemu-nbd$(EXESUF): qemu-nbd.o $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) libqemuutil.a libqemustub.a qemu-nbd$(EXESUF): qemu-nbd.o $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
qemu-io$(EXESUF): qemu-io.o $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) libqemuutil.a libqemustub.a qemu-io$(EXESUF): qemu-io.o $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o libqemuutil.a libqemustub.a qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o $(COMMON_LDADDS)
fsdev/virtfs-proxy-helper$(EXESUF): fsdev/virtfs-proxy-helper.o fsdev/9p-marshal.o fsdev/9p-iov-marshal.o libqemuutil.a libqemustub.a fsdev/virtfs-proxy-helper$(EXESUF): fsdev/virtfs-proxy-helper.o fsdev/9p-marshal.o fsdev/9p-iov-marshal.o $(COMMON_LDADDS)
fsdev/virtfs-proxy-helper$(EXESUF): LIBS += -lcap fsdev/virtfs-proxy-helper$(EXESUF): LIBS += -lcap
qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/scripts/hxtool qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/scripts/hxtool
@ -320,7 +434,7 @@ $(qapi-modules) $(SRC_PATH)/scripts/qapi-introspect.py $(qapi-py)
QGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qmp-commands.h) QGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qmp-commands.h)
$(qga-obj-y) qemu-ga.o: $(QGALIB_GEN) $(qga-obj-y) qemu-ga.o: $(QGALIB_GEN)
qemu-ga$(EXESUF): $(qga-obj-y) libqemuutil.a libqemustub.a qemu-ga$(EXESUF): $(qga-obj-y) $(COMMON_LDADDS)
$(call LINK, $^) $(call LINK, $^)
ifdef QEMU_GA_MSI_ENABLED ifdef QEMU_GA_MSI_ENABLED
@ -345,9 +459,9 @@ ifneq ($(EXESUF),)
qemu-ga: qemu-ga$(EXESUF) $(QGA_VSS_PROVIDER) $(QEMU_GA_MSI) qemu-ga: qemu-ga$(EXESUF) $(QGA_VSS_PROVIDER) $(QEMU_GA_MSI)
endif endif
ivshmem-client$(EXESUF): $(ivshmem-client-obj-y) libqemuutil.a libqemustub.a ivshmem-client$(EXESUF): $(ivshmem-client-obj-y) $(COMMON_LDADDS)
$(call LINK, $^) $(call LINK, $^)
ivshmem-server$(EXESUF): $(ivshmem-server-obj-y) libqemuutil.a libqemustub.a ivshmem-server$(EXESUF): $(ivshmem-server-obj-y) $(COMMON_LDADDS)
$(call LINK, $^) $(call LINK, $^)
module_block.h: $(SRC_PATH)/scripts/modules/module_block.py config-host.mak module_block.h: $(SRC_PATH)/scripts/modules/module_block.py config-host.mak
@ -664,6 +778,10 @@ ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fa
Makefile: $(GENERATED_HEADERS) Makefile: $(GENERATED_HEADERS)
endif endif
.SECONDARY: $(TRACE_HEADERS) $(TRACE_HEADERS:%=%-timestamp) \
$(TRACE_SOURCES) $(TRACE_SOURCES:%=%-timestamp) \
$(TRACE_DTRACE) $(TRACE_DTRACE:%=%-timestamp)
# Include automatically generated dependency files # Include automatically generated dependency files
# Dependencies in Makefile.objs files come from our recursive subdir rules # Dependencies in Makefile.objs files come from our recursive subdir rules
-include $(wildcard *.d tests/*.d) -include $(wildcard *.d tests/*.d)

View File

@ -118,50 +118,58 @@ ivshmem-server-obj-y = contrib/ivshmem-server/
libvhost-user-obj-y = contrib/libvhost-user/ libvhost-user-obj-y = contrib/libvhost-user/
###################################################################### ######################################################################
trace-events-y = trace-events trace-events-subdirs =
trace-events-y += util/trace-events trace-events-subdirs += util
trace-events-y += crypto/trace-events trace-events-subdirs += crypto
trace-events-y += io/trace-events trace-events-subdirs += io
trace-events-y += migration/trace-events trace-events-subdirs += migration
trace-events-y += block/trace-events trace-events-subdirs += block
trace-events-y += hw/block/trace-events trace-events-subdirs += hw/block
trace-events-y += hw/block/dataplane/trace-events trace-events-subdirs += hw/block/dataplane
trace-events-y += hw/char/trace-events trace-events-subdirs += hw/char
trace-events-y += hw/intc/trace-events trace-events-subdirs += hw/intc
trace-events-y += hw/net/trace-events trace-events-subdirs += hw/net
trace-events-y += hw/virtio/trace-events trace-events-subdirs += hw/virtio
trace-events-y += hw/audio/trace-events trace-events-subdirs += hw/audio
trace-events-y += hw/misc/trace-events trace-events-subdirs += hw/misc
trace-events-y += hw/usb/trace-events trace-events-subdirs += hw/usb
trace-events-y += hw/scsi/trace-events trace-events-subdirs += hw/scsi
trace-events-y += hw/nvram/trace-events trace-events-subdirs += hw/nvram
trace-events-y += hw/display/trace-events trace-events-subdirs += hw/display
trace-events-y += hw/input/trace-events trace-events-subdirs += hw/input
trace-events-y += hw/timer/trace-events trace-events-subdirs += hw/timer
trace-events-y += hw/dma/trace-events trace-events-subdirs += hw/dma
trace-events-y += hw/sparc/trace-events trace-events-subdirs += hw/sparc
trace-events-y += hw/sd/trace-events trace-events-subdirs += hw/sd
trace-events-y += hw/isa/trace-events trace-events-subdirs += hw/isa
trace-events-y += hw/mem/trace-events trace-events-subdirs += hw/mem
trace-events-y += hw/i386/trace-events trace-events-subdirs += hw/i386
trace-events-y += hw/i386/xen/trace-events trace-events-subdirs += hw/i386/xen
trace-events-y += hw/9pfs/trace-events trace-events-subdirs += hw/9pfs
trace-events-y += hw/ppc/trace-events trace-events-subdirs += hw/ppc
trace-events-y += hw/pci/trace-events trace-events-subdirs += hw/pci
trace-events-y += hw/s390x/trace-events trace-events-subdirs += hw/s390x
trace-events-y += hw/vfio/trace-events trace-events-subdirs += hw/vfio
trace-events-y += hw/acpi/trace-events trace-events-subdirs += hw/acpi
trace-events-y += hw/arm/trace-events trace-events-subdirs += hw/arm
trace-events-y += hw/alpha/trace-events trace-events-subdirs += hw/alpha
trace-events-y += hw/xen/trace-events trace-events-subdirs += hw/xen
trace-events-y += ui/trace-events trace-events-subdirs += ui
trace-events-y += audio/trace-events trace-events-subdirs += audio
trace-events-y += net/trace-events trace-events-subdirs += net
trace-events-y += target/arm/trace-events trace-events-subdirs += target/arm
trace-events-y += target/i386/trace-events trace-events-subdirs += target/i386
trace-events-y += target/sparc/trace-events trace-events-subdirs += target/sparc
trace-events-y += target/s390x/trace-events trace-events-subdirs += target/s390x
trace-events-y += target/ppc/trace-events trace-events-subdirs += target/ppc
trace-events-y += qom/trace-events trace-events-subdirs += qom
trace-events-y += linux-user/trace-events trace-events-subdirs += linux-user
trace-events-y += qapi/trace-events trace-events-subdirs += qapi
trace-events-files = $(SRC_PATH)/trace-events $(trace-events-subdirs:%=$(SRC_PATH)/%/trace-events)
trace-obj-y = trace-root.o
trace-obj-y += $(trace-events-subdirs:%=%/trace.o)
trace-obj-$(CONFIG_TRACE_UST) += trace-ust-all.o
trace-obj-$(CONFIG_TRACE_DTRACE) += trace-dtrace-root.o
trace-obj-$(CONFIG_TRACE_DTRACE) += $(trace-events-subdirs:%=%/trace-dtrace.o)

View File

@ -186,7 +186,8 @@ dummy := $(call unnest-vars,.., \
qom-obj-y \ qom-obj-y \
io-obj-y \ io-obj-y \
common-obj-y \ common-obj-y \
common-obj-m) common-obj-m \
trace-obj-y)
target-obj-y := $(target-obj-y-save) target-obj-y := $(target-obj-y-save)
all-obj-y += $(common-obj-y) all-obj-y += $(common-obj-y)
all-obj-y += $(target-obj-y) all-obj-y += $(target-obj-y)
@ -198,8 +199,10 @@ all-obj-$(CONFIG_SOFTMMU) += $(io-obj-y)
$(QEMU_PROG_BUILD): config-devices.mak $(QEMU_PROG_BUILD): config-devices.mak
COMMON_LDADDS = $(trace-obj-y) ../libqemuutil.a ../libqemustub.a
# build either PROG or PROGW # build either PROG or PROGW
$(QEMU_PROG_BUILD): $(all-obj-y) ../libqemuutil.a ../libqemustub.a $(QEMU_PROG_BUILD): $(all-obj-y) $(COMMON_LDADDS)
$(call LINK, $(filter-out %.mak, $^)) $(call LINK, $(filter-out %.mak, $^))
ifdef CONFIG_DARWIN ifdef CONFIG_DARWIN
$(call quiet-command,Rez -append $(SRC_PATH)/pc-bios/qemu.rsrc -o $@,"REZ","$(TARGET_DIR)$@") $(call quiet-command,Rez -append $(SRC_PATH)/pc-bios/qemu.rsrc -o $@,"REZ","$(TARGET_DIR)$@")

View File

@ -19,7 +19,7 @@
#include "qemu/rcu_queue.h" #include "qemu/rcu_queue.h"
#include "qemu/sockets.h" #include "qemu/sockets.h"
#include "qemu/cutils.h" #include "qemu/cutils.h"
#include "trace.h" #include "trace-root.h"
#ifdef CONFIG_EPOLL_CREATE1 #ifdef CONFIG_EPOLL_CREATE1
#include <sys/epoll.h> #include <sys/epoll.h>
#endif #endif

View File

@ -29,7 +29,7 @@
#include "exec/cpu-common.h" #include "exec/cpu-common.h"
#include "sysemu/kvm.h" #include "sysemu/kvm.h"
#include "sysemu/balloon.h" #include "sysemu/balloon.h"
#include "trace.h" #include "trace-root.h"
#include "qmp-commands.h" #include "qmp-commands.h"
#include "qapi/qmp/qerror.h" #include "qapi/qmp/qerror.h"
#include "qapi/qmp/qjson.h" #include "qapi/qmp/qjson.h"

View File

@ -22,7 +22,7 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#include "qemu/osdep.h" #include "qemu/osdep.h"
#include "trace.h" #include "block/trace.h"
#include "block/block_int.h" #include "block/block_int.h"
#include "block/blockjob.h" #include "block/blockjob.h"
#include "block/nbd.h" #include "block/nbd.h"

View File

@ -16,7 +16,6 @@
#include "qapi/qmp/qerror.h" #include "qapi/qmp/qerror.h"
#include "sysemu/sysemu.h" #include "sysemu/sysemu.h"
#include "qmp-commands.h" #include "qmp-commands.h"
#include "trace.h"
#include "block/nbd.h" #include "block/nbd.h"
#include "io/channel-socket.h" #include "io/channel-socket.h"

View File

@ -48,7 +48,7 @@
#include "sysemu/sysemu.h" #include "sysemu/sysemu.h"
#include "block/block_int.h" #include "block/block_int.h"
#include "qmp-commands.h" #include "qmp-commands.h"
#include "trace.h" #include "block/trace.h"
#include "sysemu/arch_init.h" #include "sysemu/arch_init.h"
#include "qemu/cutils.h" #include "qemu/cutils.h"
#include "qemu/help_option.h" #include "qemu/help_option.h"

View File

@ -25,7 +25,6 @@
#include "qemu/osdep.h" #include "qemu/osdep.h"
#include "qemu-common.h" #include "qemu-common.h"
#include "trace.h"
#include "block/block.h" #include "block/block.h"
#include "block/blockjob_int.h" #include "block/blockjob_int.h"
#include "block/block_int.h" #include "block/block_int.h"

View File

@ -18,7 +18,7 @@
*/ */
#include "qemu/osdep.h" #include "qemu/osdep.h"
#include "cpu.h" #include "cpu.h"
#include "trace.h" #include "trace-root.h"
#include "disas/disas.h" #include "disas/disas.h"
#include "exec/exec-all.h" #include "exec/exec-all.h"
#include "tcg.h" #include "tcg.h"

View File

@ -10,7 +10,7 @@
#include "qemu/osdep.h" #include "qemu/osdep.h"
#include "sysemu/block-backend.h" #include "sysemu/block-backend.h"
#include "sysemu/dma.h" #include "sysemu/dma.h"
#include "trace.h" #include "trace-root.h"
#include "qemu/thread.h" #include "qemu/thread.h"
#include "qemu/main-loop.h" #include "qemu/main-loop.h"

2
exec.c
View File

@ -44,7 +44,7 @@
#include "sysemu/dma.h" #include "sysemu/dma.h"
#include "exec/address-spaces.h" #include "exec/address-spaces.h"
#include "sysemu/xen-mapcache.h" #include "sysemu/xen-mapcache.h"
#include "trace.h" #include "trace-root.h"
#endif #endif
#include "exec/cpu-all.h" #include "exec/cpu-all.h"
#include "qemu/rcu_queue.h" #include "qemu/rcu_queue.h"

View File

@ -29,7 +29,6 @@
#include "qemu/osdep.h" #include "qemu/osdep.h"
#include "sysemu/sysemu.h" #include "sysemu/sysemu.h"
#include "hw/sysbus.h" #include "hw/sysbus.h"
#include "trace.h"
#include "hw/ptimer.h" #include "hw/ptimer.h"
#include "etsec.h" #include "etsec.h"
#include "registers.h" #include "registers.h"

View File

@ -25,7 +25,7 @@
*/ */
#if !defined(SOFTMMU_CODE_ACCESS) #if !defined(SOFTMMU_CODE_ACCESS)
#include "trace.h" #include "trace-root.h"
#endif #endif
#include "trace/mem.h" #include "trace/mem.h"

View File

@ -24,7 +24,7 @@
*/ */
#if !defined(CODE_ACCESS) #if !defined(CODE_ACCESS)
#include "trace.h" #include "trace-root.h"
#endif #endif
#include "trace/mem.h" #include "trace/mem.h"

View File

@ -18,7 +18,7 @@
#include "hw/xen/xen.h" #include "hw/xen/xen.h"
#include "hw/pci/pci.h" #include "hw/pci/pci.h"
#include "qemu/queue.h" #include "qemu/queue.h"
#include "trace.h" #include "hw/xen/trace.h"
/* /*
* We don't support Xen prior to 4.2.0. * We don't support Xen prior to 4.2.0.

View File

@ -1,6 +0,0 @@
#ifndef TRACE_H
#define TRACE_H
#include "trace/generated-tracers.h"
#endif /* TRACE_H */

View File

@ -29,7 +29,7 @@
#include "qemu-common.h" #include "qemu-common.h"
#include "cpu.h" #include "cpu.h"
#include "exec/ioport.h" #include "exec/ioport.h"
#include "trace.h" #include "trace-root.h"
#include "exec/memory.h" #include "exec/memory.h"
#include "exec/address-spaces.h" #include "exec/address-spaces.h"

View File

@ -34,7 +34,7 @@
#include "exec/ram_addr.h" #include "exec/ram_addr.h"
#include "exec/address-spaces.h" #include "exec/address-spaces.h"
#include "qemu/event_notifier.h" #include "qemu/event_notifier.h"
#include "trace.h" #include "trace-root.h"
#include "hw/irq.h" #include "hw/irq.h"
#include "hw/boards.h" #include "hw/boards.h"

View File

@ -24,7 +24,7 @@
#include "qemu/bitops.h" #include "qemu/bitops.h"
#include "qemu/error-report.h" #include "qemu/error-report.h"
#include "qom/object.h" #include "qom/object.h"
#include "trace.h" #include "trace-root.h"
#include "exec/memory-internal.h" #include "exec/memory-internal.h"
#include "exec/ram_addr.h" #include "exec/ram_addr.h"

View File

@ -59,7 +59,7 @@
#include "qapi/qmp/json-streamer.h" #include "qapi/qmp/json-streamer.h"
#include "qapi/qmp/json-parser.h" #include "qapi/qmp/json-parser.h"
#include "qom/object_interfaces.h" #include "qom/object_interfaces.h"
#include "trace.h" #include "trace-root.h"
#include "trace/control.h" #include "trace/control.h"
#include "monitor/hmp-target.h" #include "monitor/hmp-target.h"
#ifdef CONFIG_TRACE_SIMPLE #ifdef CONFIG_TRACE_SIMPLE

View File

@ -29,7 +29,7 @@
#include "qemu/error-report.h" #include "qemu/error-report.h"
#include "sysemu/sysemu.h" #include "sysemu/sysemu.h"
#include "hw/qdev-properties.h" #include "hw/qdev-properties.h"
#include "trace.h" #include "trace-root.h"
bool cpu_exists(int64_t id) bool cpu_exists(int64_t id)
{ {

View File

@ -137,10 +137,12 @@ def main(args):
if probe_prefix is None: if probe_prefix is None:
probe_prefix = ".".join(["qemu", target_type, target_name]) probe_prefix = ".".join(["qemu", target_type, target_name])
if len(args) != 1: if len(args) < 1:
error_opt("missing trace-events filepath") error_opt("missing trace-events filepath")
with open(args[0], "r") as fh: events = []
events = tracetool.read_events(fh) for arg in args:
with open(arg, "r") as fh:
events.extend(tracetool.read_events(fh))
try: try:
tracetool.generate(events, arg_group, arg_format, arg_backends, tracetool.generate(events, arg_group, arg_format, arg_backends,

View File

@ -36,7 +36,12 @@ def binary():
def generate_h_begin(events, group): def generate_h_begin(events, group):
out('#include "trace/generated-tracers-dtrace.h"', if group == "root":
header = "trace-dtrace-root.h"
else:
header = "trace-dtrace.h"
out('#include "%s"' % header,
'') '')

View File

@ -44,7 +44,6 @@ def generate_h(event, group):
def generate_c_begin(events, group): def generate_c_begin(events, group):
out('#include "qemu/osdep.h"', out('#include "qemu/osdep.h"',
'#include "trace.h"',
'#include "trace/control.h"', '#include "trace/control.h"',
'#include "trace/simple.h"', '#include "trace/simple.h"',
'') '')

View File

@ -20,8 +20,13 @@ PUBLIC = True
def generate_h_begin(events, group): def generate_h_begin(events, group):
if group == "root":
header = "trace-ust-root.h"
else:
header = "trace-ust.h"
out('#include <lttng/tracepoint.h>', out('#include <lttng/tracepoint.h>',
'#include "trace/generated-ust-provider.h"', '#include "%s"' % header,
'') '')

View File

@ -20,10 +20,15 @@ def generate(events, backend, group):
active_events = [e for e in events active_events = [e for e in events
if "disable" not in e.properties] if "disable" not in e.properties]
if group == "root":
header = "trace-root.h"
else:
header = "trace.h"
out('/* This file is autogenerated by tracetool, do not edit. */', out('/* This file is autogenerated by tracetool, do not edit. */',
'', '',
'#include "qemu/osdep.h"', '#include "qemu/osdep.h"',
'#include "trace.h"', '#include "%s"' % header,
'') '')
for e in events: for e in events:

View File

@ -28,13 +28,17 @@ def vcpu_transform_args(args):
def generate(events, backend, group): def generate(events, backend, group):
if group == "root":
header = "trace-root.h"
else:
header = "trace.h"
out('/* This file is autogenerated by tracetool, do not edit. */', out('/* This file is autogenerated by tracetool, do not edit. */',
'/* You must include this file after the inclusion of helper.h */', '/* You must include this file after the inclusion of helper.h */',
'', '',
'#ifndef TRACE_%s_GENERATED_TCG_TRACERS_H' % group.upper(), '#ifndef TRACE_%s_GENERATED_TCG_TRACERS_H' % group.upper(),
'#define TRACE_%s_GENERATED_TCG_TRACERS_H' % group.upper(), '#define TRACE_%s_GENERATED_TCG_TRACERS_H' % group.upper(),
'', '',
'#include "trace.h"',
'#include "exec/helper-proto.h"', '#include "exec/helper-proto.h"',
'', '',
) )

View File

@ -41,6 +41,11 @@ def vcpu_transform_args(args, mode):
def generate(events, backend, group): def generate(events, backend, group):
if group == "root":
header = "trace-root.h"
else:
header = "trace.h"
events = [e for e in events events = [e for e in events
if "disable" not in e.properties] if "disable" not in e.properties]
@ -49,7 +54,6 @@ def generate(events, backend, group):
'#include "qemu/osdep.h"', '#include "qemu/osdep.h"',
'#include "qemu-common.h"', '#include "qemu-common.h"',
'#include "cpu.h"', '#include "cpu.h"',
'#include "trace.h"',
'#include "exec/helper-proto.h"', '#include "exec/helper-proto.h"',
'', '',
) )

View File

@ -32,4 +32,4 @@ def generate(events, backend, group):
' */', ' */',
'#pragma GCC diagnostic ignored "-Wredundant-decls"', '#pragma GCC diagnostic ignored "-Wredundant-decls"',
'', '',
'#include "generated-ust-provider.h"') '#include "trace-ust-all.h"')

View File

@ -20,13 +20,18 @@ def generate(events, backend, group):
events = [e for e in events events = [e for e in events
if "disabled" not in e.properties] if "disabled" not in e.properties]
if group == "all":
include = "trace-ust-all.h"
else:
include = "trace-ust.h"
out('/* This file is autogenerated by tracetool, do not edit. */', out('/* This file is autogenerated by tracetool, do not edit. */',
'', '',
'#undef TRACEPOINT_PROVIDER', '#undef TRACEPOINT_PROVIDER',
'#define TRACEPOINT_PROVIDER qemu', '#define TRACEPOINT_PROVIDER qemu',
'', '',
'#undef TRACEPOINT_INCLUDE_FILE', '#undef TRACEPOINT_INCLUDE_FILE',
'#define TRACEPOINT_INCLUDE_FILE ./generated-ust-provider.h', '#define TRACEPOINT_INCLUDE_FILE ./%s' % include,
'', '',
'#if !defined (TRACE_%s_GENERATED_UST_H) || \\' % group.upper(), '#if !defined (TRACE_%s_GENERATED_UST_H) || \\' % group.upper(),
' defined(TRACEPOINT_HEADER_MULTI_READ)', ' defined(TRACEPOINT_HEADER_MULTI_READ)',

View File

@ -1,5 +1,5 @@
#include "qemu/osdep.h" #include "qemu/osdep.h"
#include "trace.h" #include "trace-root.h"
#include "ui/qemu-spice.h" #include "ui/qemu-spice.h"
#include "sysemu/char.h" #include "sysemu/char.h"
#include "qemu/error-report.h" #include "qemu/error-report.h"

View File

@ -491,7 +491,7 @@ QEMU_CFLAGS += -I$(SRC_PATH)/tests
# Deps that are common to various different sets of tests below # Deps that are common to various different sets of tests below
test-util-obj-y = libqemuutil.a libqemustub.a test-util-obj-y = $(trace-obj-y) libqemuutil.a libqemustub.a
test-qom-obj-y = $(qom-obj-y) $(test-util-obj-y) test-qom-obj-y = $(qom-obj-y) $(test-util-obj-y)
test-qapi-obj-y = tests/test-qapi-visit.o tests/test-qapi-types.o \ test-qapi-obj-y = tests/test-qapi-visit.o tests/test-qapi-types.o \
tests/test-qapi-event.o tests/test-qmp-introspect.o \ tests/test-qapi-event.o tests/test-qmp-introspect.o \

View File

@ -19,7 +19,7 @@
#include "qemu/queue.h" #include "qemu/queue.h"
#include "qemu/thread.h" #include "qemu/thread.h"
#include "qemu/coroutine.h" #include "qemu/coroutine.h"
#include "trace.h" #include "trace-root.h"
#include "block/thread-pool.h" #include "block/thread-pool.h"
#include "qemu/main-loop.h" #include "qemu/main-loop.h"

View File

@ -8,98 +8,16 @@
tracetool-y = $(SRC_PATH)/scripts/tracetool.py tracetool-y = $(SRC_PATH)/scripts/tracetool.py
tracetool-y += $(shell find $(SRC_PATH)/scripts/tracetool -name "*.py") tracetool-y += $(shell find $(SRC_PATH)/scripts/tracetool -name "*.py")
$(BUILD_DIR)/trace-events-all: $(trace-events-y:%=$(SRC_PATH)/%) $(BUILD_DIR)/trace-events-all: $(trace-events-files)
$(call quiet-command,cat $^ > $@) $(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: $(BUILD_DIR)/trace-events-all $(tracetool-y)
$(call quiet-command,$(TRACETOOL) \
--group=all \
--format=ust-events-h \
--backends=$(TRACE_BACKENDS) \
$< > $@,"GEN","$(patsubst %-timestamp,%,$@)")
$(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: $(BUILD_DIR)/trace-events-all $(tracetool-y)
$(call quiet-command,$(TRACETOOL) \
--group=all \
--format=ust-events-c \
--backends=$(TRACE_BACKENDS) \
$< > $@,"GEN","$(patsubst %-timestamp,%,$@)")
$(obj)/generated-tracers.h: $(obj)/generated-ust-provider.h
$(obj)/generated-tracers.c: $(obj)/generated-ust.c
endif
######################################################################
# Auto-generated tracing routines
##################################################
# Execution level
$(obj)/generated-tracers.h: $(obj)/generated-tracers.h-timestamp
@cmp -s $< $@ || cp $< $@
$(obj)/generated-tracers.h-timestamp: $(BUILD_DIR)/trace-events-all $(BUILD_DIR)/config-host.mak $(tracetool-y)
$(call quiet-command,$(TRACETOOL) \
--group=all \
--format=h \
--backends=$(TRACE_BACKENDS) \
$< > $@,"GEN","$(patsubst %-timestamp,%,$@)")
##############################
# non-DTrace
$(obj)/generated-tracers.c: $(obj)/generated-tracers.c-timestamp
@cmp -s $< $@ || cp $< $@
$(obj)/generated-tracers.c-timestamp: $(BUILD_DIR)/trace-events-all $(BUILD_DIR)/config-host.mak $(tracetool-y)
$(call quiet-command,$(TRACETOOL) \
--group=all \
--format=c \
--backends=$(TRACE_BACKENDS) \
$< > $@,"GEN","$(patsubst %-timestamp,%,$@)")
$(obj)/generated-tracers.o: $(obj)/generated-tracers.c $(obj)/generated-tracers.h
##############################
# DTrace
# Normal practice is to name DTrace probe file with a '.d' extension
# but that gets picked up by QEMU's Makefile as an external dependency
# rule file. So we use '.dtrace' instead
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: $(BUILD_DIR)/trace-events-all $(BUILD_DIR)/config-host.mak $(tracetool-y)
$(call quiet-command,$(TRACETOOL) \
--group=all \
--format=d \
--backends=$(TRACE_BACKENDS) \
$< > $@,"GEN","$(patsubst %-timestamp,%,$@)")
$(obj)/generated-tracers-dtrace.h: $(obj)/generated-tracers-dtrace.dtrace
$(call quiet-command,dtrace -o $@ -h -s $<,"GEN","$@")
$(obj)/generated-tracers-dtrace.o: $(obj)/generated-tracers-dtrace.dtrace
util-obj-y += generated-tracers-dtrace.o
endif
################################################## ##################################################
# Translation level # Translation level
$(obj)/generated-helpers-wrappers.h: $(obj)/generated-helpers-wrappers.h-timestamp $(obj)/generated-helpers-wrappers.h: $(obj)/generated-helpers-wrappers.h-timestamp
@cmp $< $@ >/dev/null 2>&1 || cp $< $@ @cmp $< $@ >/dev/null 2>&1 || cp $< $@
$(obj)/generated-helpers-wrappers.h-timestamp: $(BUILD_DIR)/trace-events-all $(BUILD_DIR)/config-host.mak $(tracetool-y) $(obj)/generated-helpers-wrappers.h-timestamp: $(trace-events-files) $(BUILD_DIR)/config-host.mak $(tracetool-y)
$(call quiet-command,$(TRACETOOL) \ $(call quiet-command,$(TRACETOOL) \
--group=all \ --group=all \
--format=tcg-helper-wrapper-h \ --format=tcg-helper-wrapper-h \
@ -108,7 +26,7 @@ $(obj)/generated-helpers-wrappers.h-timestamp: $(BUILD_DIR)/trace-events-all $(B
$(obj)/generated-helpers.h: $(obj)/generated-helpers.h-timestamp $(obj)/generated-helpers.h: $(obj)/generated-helpers.h-timestamp
@cmp $< $@ >/dev/null 2>&1 || cp $< $@ @cmp $< $@ >/dev/null 2>&1 || cp $< $@
$(obj)/generated-helpers.h-timestamp: $(BUILD_DIR)/trace-events-all $(BUILD_DIR)/config-host.mak $(tracetool-y) $(obj)/generated-helpers.h-timestamp: $(trace-events-files) $(BUILD_DIR)/config-host.mak $(tracetool-y)
$(call quiet-command,$(TRACETOOL) \ $(call quiet-command,$(TRACETOOL) \
--group=all \ --group=all \
--format=tcg-helper-h \ --format=tcg-helper-h \
@ -117,7 +35,7 @@ $(obj)/generated-helpers.h-timestamp: $(BUILD_DIR)/trace-events-all $(BUILD_DIR)
$(obj)/generated-helpers.c: $(obj)/generated-helpers.c-timestamp $(obj)/generated-helpers.c: $(obj)/generated-helpers.c-timestamp
@cmp $< $@ >/dev/null 2>&1 || cp $< $@ @cmp $< $@ >/dev/null 2>&1 || cp $< $@
$(obj)/generated-helpers.c-timestamp: $(BUILD_DIR)/trace-events-all $(BUILD_DIR)/config-host.mak $(tracetool-y) $(obj)/generated-helpers.c-timestamp: $(trace-events-files) $(BUILD_DIR)/config-host.mak $(tracetool-y)
$(call quiet-command,$(TRACETOOL) \ $(call quiet-command,$(TRACETOOL) \
--group=all \ --group=all \
--format=tcg-helper-c \ --format=tcg-helper-c \
@ -131,7 +49,7 @@ target-obj-y += generated-helpers.o
$(obj)/generated-tcg-tracers.h: $(obj)/generated-tcg-tracers.h-timestamp $(obj)/generated-tcg-tracers.h: $(obj)/generated-tcg-tracers.h-timestamp
@cmp $< $@ >/dev/null 2>&1 || cp $< $@ @cmp $< $@ >/dev/null 2>&1 || cp $< $@
$(obj)/generated-tcg-tracers.h-timestamp: $(BUILD_DIR)/trace-events-all $(BUILD_DIR)/config-host.mak $(tracetool-y) $(obj)/generated-tcg-tracers.h-timestamp: $(trace-events-files) $(BUILD_DIR)/config-host.mak $(tracetool-y)
$(call quiet-command,$(TRACETOOL) \ $(call quiet-command,$(TRACETOOL) \
--group=all \ --group=all \
--format=tcg-h \ --format=tcg-h \
@ -142,10 +60,8 @@ $(obj)/generated-tcg-tracers.h-timestamp: $(BUILD_DIR)/trace-events-all $(BUILD_
###################################################################### ######################################################################
# Backend code # Backend code
util-obj-y += generated-tracers.o
util-obj-$(CONFIG_TRACE_SIMPLE) += simple.o util-obj-$(CONFIG_TRACE_SIMPLE) += simple.o
util-obj-$(CONFIG_TRACE_FTRACE) += ftrace.o util-obj-$(CONFIG_TRACE_FTRACE) += ftrace.o
util-obj-$(CONFIG_TRACE_UST) += generated-ust.o
util-obj-y += control.o util-obj-y += control.o
target-obj-y += control-target.o target-obj-y += control-target.o
util-obj-y += qmp.o util-obj-y += qmp.o

View File

@ -9,7 +9,7 @@
#include "qemu/osdep.h" #include "qemu/osdep.h"
#include "cpu.h" #include "cpu.h"
#include "trace.h" #include "trace-root.h"
#include "trace/control.h" #include "trace/control.h"
#include "translate-all.h" #include "translate-all.h"

View File

@ -26,7 +26,7 @@
#include "qemu/error-report.h" #include "qemu/error-report.h"
#include "qemu/config-file.h" #include "qemu/config-file.h"
#include "monitor/monitor.h" #include "monitor/monitor.h"
#include "trace.h" #include "trace-root.h"
int trace_events_enabled_count; int trace_events_enabled_count;

View File

@ -10,8 +10,8 @@
*/ */
#include "qemu/osdep.h" #include "qemu/osdep.h"
#include "trace.h"
#include "trace/control.h" #include "trace/control.h"
#include "trace/ftrace.h"
int trace_marker_fd; int trace_marker_fd;

View File

@ -13,7 +13,6 @@
#include <pthread.h> #include <pthread.h>
#endif #endif
#include "qemu/timer.h" #include "qemu/timer.h"
#include "trace.h"
#include "trace/control.h" #include "trace/control.h"
#include "trace/simple.h" #include "trace/simple.h"

View File

@ -25,7 +25,7 @@
#include "qemu-common.h" #include "qemu-common.h"
#define NO_CPU_IO_DEFS #define NO_CPU_IO_DEFS
#include "cpu.h" #include "cpu.h"
#include "trace.h" #include "trace-root.h"
#include "disas/disas.h" #include "disas/disas.h"
#include "exec/exec-all.h" #include "exec/exec-all.h"
#include "tcg.h" #include "tcg.h"

2
vl.c
View File

@ -110,7 +110,7 @@ int main(int argc, char **argv)
#include "slirp/libslirp.h" #include "slirp/libslirp.h"
#include "trace.h" #include "trace-root.h"
#include "trace/control.h" #include "trace/control.h"
#include "qemu/queue.h" #include "qemu/queue.h"
#include "sysemu/arch_init.h" #include "sysemu/arch_init.h"

View File

@ -22,7 +22,7 @@
#include "qemu/error-report.h" #include "qemu/error-report.h"
#include "qemu/range.h" #include "qemu/range.h"
#include "sysemu/xen-mapcache.h" #include "sysemu/xen-mapcache.h"
#include "trace.h" #include "trace-root.h"
#include "exec/address-spaces.h" #include "exec/address-spaces.h"
#include <xen/hvm/ioreq.h> #include <xen/hvm/ioreq.h>

View File

@ -19,7 +19,7 @@
#include <xen/hvm/params.h> #include <xen/hvm/params.h>
#include "sysemu/xen-mapcache.h" #include "sysemu/xen-mapcache.h"
#include "trace.h" #include "trace-root.h"
//#define MAPCACHE_DEBUG //#define MAPCACHE_DEBUG