From: Frank Ch. Eigler Date: Tue, 16 Oct 2012 15:12:52 +0000 (-0400) Subject: documentation: mention non-semaphore mode for dtrace(1) headers X-Git-Tag: release-2.1~353 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=3f1ae6951ff3d8588d788ad0f198413df93c8925;p=systemtap.git documentation: mention non-semaphore mode for dtrace(1) headers --- diff --git a/dtrace.1 b/dtrace.1 index 5cd55df40..92046c4a9 100644 --- a/dtrace.1 +++ b/dtrace.1 @@ -67,24 +67,54 @@ struct astruct {int a; int b;}; .fi .in .RE -Then the command \fI"dtrace\ \-s\ test.d\ \-G"\fR -will create the probe definition file \fItest.o\fR -and the command \fI"dtrace\ \-s\ test.d\ \-h"\fR -will create the probe header file \fItest.h\fR -Subsequently the application can define probes using +Then the command \fI"dtrace\ \-s\ test.d\ \-G"\fR will create the +probe definition file \fItest.o\fR and the command \fI"dtrace\ \-s\ +test.d\ \-h"\fR will create the probe header file \fItest.h\fR +Subsequently the application can use the generated macros this way: + +.in +2 +.nf +#include "test.h" + \.\.\. +struct astruct s; + \.\.\. +SDT_PROBES_TEST_0(value); + \.\.\. +if (SDT_PROBES_TEST_1_ENABLED()) + SDT_PROBES_TEST_1(expensive_function(s)); +.fi +.in + +.SH SEMAPHORES + +Semaphores are flag variables used by probes as a way of bypassing +potentially costly processing to prepare arguments for probes that may +not even be active. They are automatically set/cleared by systemtap +when a relevant script is running, so the argument setup cost is only +paid when necessary. These semaphore variables are defined within the +the \fI"test.o"\fR object file, which must therefore be linked into an +application. +.PP +Sometimes, semaphore variables are not necessary nor helpful. Skipping +them can simplfy the build process, by omitting the extra \fI"test.o"\fR +file. To skip dependence upon semaphore variables, include \fI""\fR +within the application before \fI"test.h"\fR: + .in +2 .nf +#include #include "test.h" \.\.\. struct astruct s; \.\.\. SDT_PROBES_TEST_0(value); \.\.\. -SDT_PROBES_TEST_1(s); +if (SDT_PROBES_TEST_1_ENABLED()) + SDT_PROBES_TEST_1(cheap_function(s)); .fi .in -The application is linked with \fI"test.o"\fR when it is built. +In this mode, the ENABLED() test is fixed at 1. .SH SEE ALSO