@@ -39,40 +39,51 @@ Trace events
3939Sub-directory setup
4040-------------------
4141
42- Each directory in the source tree can declare a set of static trace events
43- in a local "trace-events" file. All directories which contain "trace-events"
44- files must be listed in the "trace-events-subdirs" make variable in the top
45- level Makefile.objs. During build, the "trace-events" file in each listed
46- subdirectory will be processed by the "tracetool" script to generate code for
47- the trace events.
42+ Each directory in the source tree can declare a set of trace events in a local
43+ "trace-events" file. All directories which contain "trace-events" files must be
44+ listed in the "trace_events_subdirs" variable in the top level meson.build
45+ file. During build, the "trace-events" file in each listed subdirectory will be
46+ processed by the "tracetool" script to generate code for the trace events.
4847
4948The individual "trace-events" files are merged into a "trace-events-all" file,
5049which is also installed into "/usr/share/qemu" with the name "trace-events".
5150This merged file is to be used by the "simpletrace.py" script to later analyse
5251traces in the simpletrace data format.
5352
54- In the sub-directory the following files will be automatically generated
53+ The following files are automatically generated in <builddir>/trace/ during the
54+ build:
5555
56- - trace.c - the trace event state declarations
57- - trace.h - the trace event enums and probe functions
58- - trace-dtrace.h - DTrace event probe specification
59- - trace-dtrace.dtrace - DTrace event probe helper declaration
60- - trace-dtrace.o - binary DTrace provider (generated by dtrace)
61- - trace-ust.h - UST event probe helper declarations
56+ - trace-<subdir> .c - the trace event state declarations
57+ - trace-<subdir> .h - the trace event enums and probe functions
58+ - trace-dtrace-<subdir> .h - DTrace event probe specification
59+ - trace-dtrace-<subdir> .dtrace - DTrace event probe helper declaration
60+ - trace-dtrace-<subdir> .o - binary DTrace provider (generated by dtrace)
61+ - trace-ust-<subdir> .h - UST event probe helper declarations
6262
63- Source files in the sub-directory should #include the local 'trace.h' file,
64- without any sub-directory path prefix. eg io/channel-buffer.c would do::
63+ Here <subdir> is the sub-directory path with '/' replaced by '_'. For example,
64+ "accel/kvm" becomes "accel_kvm" and the final filename for "trace-<subdir>.c"
65+ becomes "trace-accel_kvm.c".
66+
67+ Source files in the source tree do not directly include generated files in
68+ "<builddir>/trace/". Instead they #include the local "trace.h" file, without
69+ any sub-directory path prefix. eg io/channel-buffer.c would do::
6570
6671 #include "trace.h"
6772
68- To access the 'io/trace.h' file. While it is possible to include a trace.h
69- file from outside a source file's own sub-directory, this is discouraged in
70- general. It is strongly preferred that all events be declared directly in
71- the sub-directory that uses them. The only exception is where there are some
72- shared trace events defined in the top level directory trace-events file.
73- The top level directory generates trace files with a filename prefix of
74- "trace/trace-root" instead of just "trace". This is to avoid ambiguity between
75- a trace.h in the current directory, vs the top level directory.
73+ The "io/trace.h" file must be created manually with an #include of the
74+ corresponding "trace/trace-<subdir>.h" file that will be generated in the
75+ builddir::
76+
77+ $ echo '#include "trace/trace-io.h"' >io/trace.h
78+
79+ While it is possible to include a trace.h file from outside a source file's own
80+ sub-directory, this is discouraged in general. It is strongly preferred that
81+ all events be declared directly in the sub-directory that uses them. The only
82+ exception is where there are some shared trace events defined in the top level
83+ directory trace-events file. The top level directory generates trace files
84+ with a filename prefix of "trace/trace-root" instead of just "trace". This is
85+ to avoid ambiguity between a trace.h in the current directory, vs the top level
86+ directory.
7687
7788Using trace events
7889------------------
0 commit comments