You must augment the build process for your application to include the DTrace provider and probe definitions. A typical build process takes each source file and compiles it to create a corresponding object file. The compiled object files are then linked to each other to create the finished application binary, as shown in the following example:
src1.o: src1.c gcc -c src1.c src2.o: src2.c gcc -c src2.c myserv: src1.o src2.o gcc -o myserv src1.o src2.o
If you included DTrace probe definitions in your application,
you need to add appropriate Makefile
rules to
your build process to execute the dtrace
command.
The dtrace command post-processes the object
files that are created by the preceding compiler commands and
generates the object file myserv.o
from
myserv.d
and the other object files. The
-G option is used to link provider and probe
definitions with a user application.
The -Wl,--export-dynamic link options to
gcc are required to support symbol lookup in
a stripped executable at runtime, for example, by running
ustack()
.
If you inserted probes in the source code by using the macros that were defined in a header file created by dtrace -h, you need to include that command in the Makefile:
myserv.h: myserv.d dtrace -h -s myserv.d src1.o: src1.c myserv.h gcc -c src1.c src2.o: src2.c myserv.h gcc -c src2.c myserv.o: myserv.d src1.o src2.o dtrace -G -s myserv.d src1.o src2.o myserv: myserv.o gcc -Wl,--export-dynamic,--strip-all -o myserv myserv.o src1.o src2.o
The rules in the Makefile
take into account
the dependency of the header file on the probe definition.