1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
|
'\" te
.\" Copyright 2004. Sun Microsystems Inc.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.
.\" See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with
.\" the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH TNF_PROBE 3TNF "Mar 1, 2004"
.SH NAME
TNF_PROBE, TNF_PROBE_0, TNF_PROBE_1, TNF_PROBE_2, TNF_PROBE_3, TNF_PROBE_4,
TNF_PROBE_5, TNF_PROBE_0_DEBUG, TNF_PROBE_1_DEBUG, TNF_PROBE_2_DEBUG,
TNF_PROBE_3_DEBUG, TNF_PROBE_4_DEBUG, TNF_PROBE_5_DEBUG, TNF_DEBUG \- probe
insertion interface
.SH SYNOPSIS
.LP
.nf
\fBcc\fR [ \fIflag\fR ... ] [ \fB-DTNF_DEBUG\fR ] \fIfile\fR ... [ \fB-ltnfprobe\fR ] [ \fIlibrary\fR ... ]
#include <tnf/probe.h>
\fBTNF_PROBE_0\fR(\fIname\fR, \fIkeys\fR, \fIdetail\fR);
.fi
.LP
.nf
\fBTNF_PROBE_1\fR(\fIname\fR, \fIkeys\fR, \fIdetail\fR, \fIarg_type_1\fR, \fIarg_name_1\fR, \fIarg_value_1\fR);
.fi
.LP
.nf
\fBTNF_PROBE_2\fR(\fIname\fR, \fIkeys\fR, \fIdetail\fR, \fIarg_type_1\fR, \fIarg_name_1\fR, \fIarg_value_1\fR,
\fIarg_type_2\fR, \fIarg_name_2\fR, \fIarg_value_2\fR);
.fi
.LP
.nf
\fBTNF_PROBE_3\fR(\fIname\fR, \fIkeys\fR, \fIdetail\fR, \fIarg_type_1\fR, \fIarg_name_1\fR,\fIarg_value_1\fR,
\fIarg_type_2\fR, \fIarg_name_2\fR, \fIarg_value_2\fR,
\fIarg_type_3\fR, \fIarg_name_3\fR, \fIarg_value_3\fR);
.fi
.LP
.nf
\fBTNF_PROBE_4\fR(\fIname\fR, \fIkeys\fR, \fIdetail\fR, \fIarg_type_1\fR, \fIarg_name_1\fR, \fIarg_value_1\fR,
\fIarg_type_2\fR, \fIarg_name_2\fR, \fIarg_value_2\fR,
\fIarg_type_3\fR, \fIarg_name_3\fR, \fIarg_value_3\fR,
\fIarg_type_4\fR, \fIarg_name_4\fR, \fIarg_value_4\fR);
.fi
.LP
.nf
\fBTNF_PROBE_5\fR(\fIname\fR, \fIkeys\fR, \fIdetail\fR, \fIarg_type_1\fR, \fIarg_name_1\fR, \fIarg_value_1\fR,
\fIarg_type_2\fR, \fIarg_name_2\fR, \fIarg_value_2\fR,
\fIarg_type_3\fR, \fIarg_name_3\fR, \fIarg_value_3\fR,
\fIarg_type_4\fR, \fIarg_name_4\fR, \fIarg_value_4\fR,
\fIarg_type_5\fR, \fIarg_name_5\fR, \fIarg_value_5\fR);
.fi
.LP
.nf
\fBTNF_PROBE_0_DEBUG\fR(\fIname\fR, \fIkeys\fR, \fIdetail\fR);
.fi
.LP
.nf
\fBTNF_PROBE_1_DEBUG\fR(\fIname\fR, \fIkeys\fR, \fIdetail\fR, \fIarg_type_1\fR, \fIarg_name_1\fR, \fIarg_value_1\fR);
.fi
.LP
.nf
\fBTNF_PROBE_2_DEBUG\fR(\fIname\fR, \fIkeys\fR, \fIdetail\fR, \fIarg_type_1\fR, \fIarg_name_1\fR, \fIarg_value_1\fR,
\fIarg_type_2\fR, \fIarg_name_2\fR, \fIarg_value_2\fR);
.fi
.LP
.nf
\fBTNF_PROBE_3_DEBUG\fR(\fIname\fR, \fIkeys\fR, \fIdetail\fR, \fIarg_type_1\fR, \fIarg_name_1\fR, \fIarg_value_1\fR,
\fIarg_type_2\fR, \fIarg_name_2\fR, \fIarg_value_2\fR,
\fIarg_type_3\fR, \fIarg_name_3\fR, \fIarg_value_3\fR);
.fi
.LP
.nf
\fBTNF_PROBE_4_DEBUG\fR(\fIname\fR, \fIkeys\fR, \fIdetail\fR, \fIarg_type_1\fR, \fIarg_name_1\fR, \fIarg_value_1\fR,
\fIarg_type_2\fR, \fIarg_name_2\fR, \fIarg_value_2\fR,
\fIarg_type_3\fR, \fIarg_name_3\fR, \fIarg_value_3\fR,
\fIarg_type_4\fR, \fIarg_name_4\fR, \fIarg_value_4\fR);
.fi
.LP
.nf
\fBTNF_PROBE_5_DEBUG\fR(\fIname\fR, \fIkeys\fR, \fIdetail\fR, \fIarg_type_1\fR, \fIarg_name_1\fR, \fIarg_value_1\fR,
\fIarg_type_2\fR, \fIarg_name_2\fR, \fIarg_value_2\fR,
\fIarg_type_3\fR, \fIarg_name_3\fR, \fIarg_value_3\fR,
\fIarg_type_4\fR, \fIarg_name_4\fR, \fIarg_value_4\fR,
\fIarg_type_5\fR, \fIarg_name_5\fR, \fIarg_value_5\fR);
.fi
.SH DESCRIPTION
.sp
.LP
This macro interface is used to insert probes into C or C++ code for tracing.
See \fBtracing\fR(3TNF) for a discussion of the Solaris tracing architecture,
including example source code that uses it.
.sp
.LP
You can place probes anywhere in C and C++ programs including .init
sections, .fini sections, multi-threaded code, shared objects, and shared objects opened
by \fBdlopen\fR(3C). Use probes to generate trace data for performance
analysis or to write debugging output to stderr. Probes are controlled at
runtime by \fBprex\fR(1).
.sp
.LP
The trace data is logged to a trace file in Trace Normal Form ( \fBTNF).\fR
The interface for the user to specify the name and size of the trace file is
described in \fBprex\fR(1). Think of the trace file as the least recently used
circular buffer. Once the file has been filled, newer events will overwrite the
older ones.
.sp
.LP
Use \fBTNF_PROBE_0\fR through \fBTNF_PROBE_5\fR to create production probes.
These probes are compiled in by default. Developers are encouraged to embed
such probes strategically, and to leave them compiled within production
software. Such probes facilitate on-site analysis of the software.
.sp
.LP
Use \fBTNF_PROBE_0_DEBUG\fR through \fBTNF_PROBE_5_DEBUG\fR to create debug
probes. These probes are compiled out by default. If you compile the program
with the preprocessor option \fB-DTNF_DEBUG\fR or with the preprocessor
control statement \fB#define\fR \fBTNF_DEBUG\fR ahead of the \fB#include\fR
\fB<tnf/probe.h>\fR statement, the debug probes will be compiled into the
program. When compiled in, debug probes differ in only one way from the
equivalent production probes. They contain an additional "debug" attribute
which may be used to distinguish them from production probes at runtime, for
example, when using \fBprex()\fR. Developers are encouraged to embed any number
of probes for debugging purposes. Disabled probes have such a small runtime
overhead that even large numbers of them do not make a significant impact.
.sp
.LP
If you compile with the preprocessor option \fB-DNPROBE\fR or place the
preprocessor control statement \fB#define\fR \fBNPROBE\fR ahead of the
\fB#include\fR \fB<tnf/probe.h>\fR statement, no probes will be compiled into
the program.
.SS "name"
.sp
.LP
The \fIname\fR of the probe should follow the syntax guidelines for identifiers
in ANSI C. The use of \fIname\fR declares it, hence no separate declaration is
necessary. This is a block scope declaration, so it does not affect the name
space of the program.
.SS "keys"
.sp
.LP
\fIkeys\fR is a string of space-separated keywords that specify the groups that
the probe belongs to. Semicolons, single quotation marks, and the equal
character (=) are not allowed in this string. If any of the groups are enabled,
the probe is enabled. \fIkeys\fR cannot be a variable. It must be a string
constant.
.SS "detail"
.sp
.LP
\fIdetail\fR is a string that consists of <attribute> <value> pairs that are
each separated by a semicolon. The first word (up to the space) is considered
to be the attribute and the rest of the string (up to the semicolon) is
considered the value. Single quotation marks are used to denote a string value.
Besides quotation marks, spaces separate multiple values. The value is
optional. Although semicolons or single quotation marks generally are not
allowed within either the attribute or the value, when text with embedded
spaces is meant to denote a single value, use single quotes surrounding this
text.
.sp
.LP
Use \fIdetail\fR for one of two reasons. First, use \fIdetail\fR to supply
an attribute that a user can type into \fBprex\fR(1) to select probes. For
example, if a user defines an attribute called color, then \fBprex\fR(1) can
select probes based on the value of color. Second, use \fIdetail\fR to annotate
a probe with a string that is written out to a trace file only once.
\fBprex\fR(1) uses spaces to tokenize the value when searching for a match.
Spaces around the semicolon delimiter are allowed. \fIdetail\fR cannot be a
variable; it must be a string constant. For example, the \fIdetail\fR string:
.sp
.in +2
.nf
"XYZ%debug 'entering function A'; XYZ%exception 'no file';
XYZ%func_entry; XYZ%color red blue"
.fi
.in -2
.sp
.LP
consists of 4 units:
.sp
.sp
.TS
box;
c c c
l l l .
\fBAttribute\fR \fBValue\fR \fBValues that\fR \fBprex\fR \fBmatches on\fR
_
XYZ%debug \&'entering function A' \&'entering function A'
XYZ%exception \&'no file' \&'no file'
XYZ%func_entry /.*/ (regular expression)
XYZ%color red blue red <or> blue
.TE
.sp
.LP
Attribute names must be prefixed by the vendor stock symbol followed by
the '%' character. This avoids conflicts in the attribute name space. All
attributes that do not have a '%' character are reserved. The following
attributes are predefined:
.sp
.sp
.TS
box;
c c
l l .
\fBAttribute\fR \fBSemantics\fR
_
name name of probe
keys T{
keys of the probe (value is space\(mi separated tokens)
T}
file file name of the probe
line line number of the probe
slots T{
slot names of the probe event (\fIarg_name_n\fR)
T}
object T{
the executable or shared object that this probe is in.
T}
debug T{
distinguishes debug probes from production probes
T}
.TE
.SS "arg_type_n"
.sp
.LP
This is the type of the \fIn\fRth argument. The following are predefined
\fBTNF\fR types:
.sp
.sp
.TS
box;
c c
l l .
\fBtnf Type\fR \fBAssociated C type (and semantics)\fR
_
tnf_int int
tnf_uint unsigned int
tnf_long long
tnf_ulong unsigned long
tnf_longlong T{
long long (if implemented in compilation system)
T}
tnf_ulonglong T{
unsigned long long (if implemented in compilation system)
T}
tnf_float float
tnf_double double
tnf_string char *
tnf_opaque void *
.TE
.sp
.LP
To define new \fBTNF\fR types that are records consisting of the predefined
\fBTNF\fR types or references to other user defined types, use the interface
specified in \fBTNF_DECLARE_RECORD\fR(3TNF).
.SS "arg_name_n"
.sp
.LP
\fIarg_name_n\fR is the name that the user associates with the \fIn\fRth
argument. Do not place quotation marks around \fIarg_name_n\fR. Follow the
syntax guidelines for identifiers in ANSI C. The string version of
\fIarg_name_n\fR is stored for every probe and can be accessed as the attribute
"slots".
.SS "arg_value_n"
.sp
.LP
\fIarg_value_n\fR is evaluated to yield a value to be included in the trace
file. A read access is done on any variables that are in mentioned in
\fIarg_value_n\fR. In a multithreaded program, it is the user's responsibility
to place locks around the \fBTNF_PROBE\fR macro if \fIarg_value_n\fR contains
a variable that should be read protected.
.SH EXAMPLES
.LP
\fBExample 1 \fRtracing(3TNF)
.sp
.LP
See \fBtracing\fR(3TNF) for complete examples showing debug and production
probes in source code.
.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(5) for descriptions of the following attributes:
.sp
.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE ATTRIBUTE VALUE
_
MT Level MT-Safe
.TE
.SH SEE ALSO
.sp
.LP
\fBld\fR(1), \fBprex\fR(1), \fBtnfdump\fR(1), \fBdlopen\fR(3C),
\fBlibtnfctl\fR(3TNF), \fBTNF_DECLARE_RECORD\fR(3TNF), \fBthreads\fR(5),
\fBtnf_process_disable\fR(3TNF), \fBtracing\fR(3TNF), \fBattributes\fR(5)
.SH NOTES
.sp
.LP
If attaching to a running program with \fBprex\fR(1) to control the probes,
compile the program with \fB-ltnfprobe\fR or start the program with the
environment variable \fBLD_PRELOAD\fR set to \fBlibtnfprobe.so.1\fR. See
\fBld\fR(1). If \fBlibtnfprobe\fR is explicitly linked into the program, it
must be listed before \fBlibdoor\fR, which in turn must be listed before
\fBlibthread\fR on the link line.
|