Skip to content

Commit 0dfb3ca

Browse files
committed
trace: update docs with meson build information
The documentation still refers to the makefile and the old sub-directory layout. Meson works differently: tracetool output is placed into the builddir with mangled filenames like <builddir>/trace/trace-accel_kvm.h for the accel/kvm/ trace.h definition. This meson setup also requires a manually-created accel/kvm/trace.h file that #includes the <builddir>/trace/trace-accel_kvm.h file. Document this! Reported-by: Peter Maydell <[email protected]> Signed-off-by: Stefan Hajnoczi <[email protected]> Message-id: [email protected] Signed-off-by: Stefan Hajnoczi <[email protected]>
1 parent 3faf22e commit 0dfb3ca

File tree

1 file changed

+34
-23
lines changed

1 file changed

+34
-23
lines changed

docs/devel/tracing.rst

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -39,40 +39,51 @@ Trace events
3939
Sub-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

4948
The individual "trace-events" files are merged into a "trace-events-all" file,
5049
which is also installed into "/usr/share/qemu" with the name "trace-events".
5150
This merged file is to be used by the "simpletrace.py" script to later analyse
5251
traces 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

7788
Using trace events
7889
------------------

0 commit comments

Comments
 (0)