]> sourceware.org Git - systemtap.git/blame - stapprobes.3stap
Give information about online servers and which servers were specified when no suitab...
[systemtap.git] / stapprobes.3stap
CommitLineData
5f92f126 1.\" t
ec1a2239 2.TH STAPPROBES 3stap
ba4a90fd
FCE
3.SH NAME
4stapprobes \- systemtap probe points
5
6.\" macros
7.de SAMPLE
8.br
9.RS
10.nf
11.nh
12..
13.de ESAMPLE
14.hy
15.fi
16.RE
17..
18
19.SH DESCRIPTION
20The following sections enumerate the variety of probe points supported
89965a32
FCE
21by the systemtap translator, and some of the additional aliases defined by
22standard tapset scripts. Many are individually documented in the
23.IR 3stap
24manual section, with the
25.IR probe::
26prefix.
ba4a90fd 27.PP
7abecb38 28The general probe point syntax is a dotted-symbol sequence. This
ba4a90fd
FCE
29allows a breakdown of the event namespace into parts, somewhat like
30the Domain Name System does on the Internet. Each component
7abecb38 31identifier may be parametrized by a string or number literal, with a
d898100a 32syntax like a function call. A component may include a "*" character,
649260f3
JS
33to expand to a set of matching probe points. It may also include "**"
34to match multiple sequential components at once. Probe aliases likewise
d898100a
FCE
35expand to other probe points. Each and every resulting probe point is
36normally resolved to some low-level system instrumentation facility
37(e.g., a kprobe address, marker, or a timer configuration), otherwise
38the elaboration phase will fail.
39.PP
40However, a probe point may be followed by a "?" character, to indicate
41that it is optional, and that no error should result if it fails to
42resolve. Optionalness passes down through all levels of
43alias/wildcard expansion. Alternately, a probe point may be followed
44by a "!" character, to indicate that it is both optional and
37f6433e 45sufficient. (Think vaguely of the Prolog cut operator.) If it does
d898100a
FCE
46resolve, then no further probe points in the same comma-separated list
47will be resolved. Therefore, the "!" sufficiency mark only makes
48sense in a list of probe point alternatives.
dfd11cc3
MH
49.PP
50Additionally, a probe point may be followed by a "if (expr)" statement, in
51order to enable/disable the probe point on-the-fly. With the "if" statement,
52if the "expr" is false when the probe point is hit, the whole probe body
53including alias's body is skipped. The condition is stacked up through
54all levels of alias/wildcard expansion. So the final condition becomes
55the logical-and of conditions of all expanded alias/wildcard.
6e3347a9 56
e904ad95
FCE
57These are all
58.B syntactically
59valid probe points. (They are generally
60.B semantically
61invalid, depending on the contents of the tapsets, and the versions of
62kernel/user software installed.)
ca88561f 63
ba4a90fd
FCE
64.SAMPLE
65kernel.function("foo").return
e904ad95 66process("/bin/vi").statement(0x2222)
ba4a90fd 67end
729286d8 68syscall.*
649260f3 69sys**open
6e3347a9 70kernel.function("no_such_function") ?
d898100a 71module("awol").function("no_such_function") !
dfd11cc3 72signal.*? if (switch)
94c3c803 73kprobe.function("foo")
ba4a90fd
FCE
74.ESAMPLE
75
6f05b6ab
FCE
76Probes may be broadly classified into "synchronous" and
77"asynchronous". A "synchronous" event is deemed to occur when any
78processor executes an instruction matched by the specification. This
79gives these probes a reference point (instruction address) from which
80more contextual data may be available. Other families of probe points
81refer to "asynchronous" events such as timers/counters rolling over,
82where there is no fixed reference point that is related. Each probe
83point specification may match multiple locations (for example, using
84wildcards or aliases), and all them are then probed. A probe
85declaration may also contain several comma-separated specifications,
86all of which are probed.
87
5f92f126
FCE
88.SH DWARF DEBUGINFO
89
90Resolving some probe points requires DWARF debuginfo or "debug
91symbols" for the specific part being instrumented. For some others,
92DWARF is automatically synthesized on the fly from source code header
93files. For others, it is not needed at all. Since a systemtap script
94may use any mixture of probe points together, the union of their DWARF
95requirements has to be met on the computer where script compilation
96occurs. (See the \fI\-\-use\-server\fR option and the \fBstap-server\
97(8)\fR man page for information about the remote compilation facility,
98which allows these requirements to be met on a different machine.)
99.PP
100The following point lists many of the available probe point families,
101to classify them with respect to their need for DWARF debuginfo.
102
103.TS
104l l l.
7bfd1083 105\fBDWARF NON-DWARF\fP
5f92f126 106
7bfd1083
TJL
107kernel.function, .statement kernel.mark
108module.function, .statement process.mark
109process.function, .statement begin, end, error, never
110process.mark \fI(backup)\fP timer
111 perf
112 procfs
113\fBAUTO-DWARF\fP kernel.statement.absolute
114 kernel.data
115kernel.trace kprobe.function
116 process.statement.absolute
117 process.begin, .end, .error
5f92f126
FCE
118.TE
119
120.SH PROBE POINT FAMILIES
121
65aeaea0 122.SS BEGIN/END/ERROR
ba4a90fd
FCE
123
124The probe points
125.IR begin " and " end
126are defined by the translator to refer to the time of session startup
127and shutdown. All "begin" probe handlers are run, in some sequence,
128during the startup of the session. All global variables will have
129been initialized prior to this point. All "end" probes are run, in
130some sequence, during the
131.I normal
132shutdown of a session, such as in the aftermath of an
133.I exit ()
134function call, or an interruption from the user. In the case of an
135error-triggered shutdown, "end" probes are not run. There are no
136target variables available in either context.
6a256b03
JS
137.PP
138If the order of execution among "begin" or "end" probes is significant,
139then an optional sequence number may be provided:
ca88561f 140
6a256b03
JS
141.SAMPLE
142begin(N)
143end(N)
144.ESAMPLE
ca88561f 145
6a256b03
JS
146The number N may be positive or negative. The probe handlers are run in
147increasing order, and the order between handlers with the same sequence
148number is unspecified. When "begin" or "end" are given without a
149sequence, they are effectively sequence zero.
ba4a90fd 150
65aeaea0
FCE
151The
152.IR error
153probe point is similar to the
154.IR end
d898100a
FCE
155probe, except that each such probe handler run when the session ends
156after errors have occurred. In such cases, "end" probes are skipped,
37f6433e 157but each "error" probe is still attempted. This kind of probe can be
d898100a
FCE
158used to clean up or emit a "final gasp". It may also be numerically
159parametrized to set a sequence.
65aeaea0 160
6e3347a9
FCE
161.SS NEVER
162The probe point
163.IR never
164is specially defined by the translator to mean "never". Its probe
165handler is never run, though its statements are analyzed for symbol /
166type correctness as usual. This probe point may be useful in
167conjunction with optional probes.
168
1027502b
FCE
169.SS SYSCALL
170
171The
172.IR syscall.*
173aliases define several hundred probes, too many to
174summarize here. They are:
175
176.SAMPLE
177syscall.NAME
178.br
179syscall.NAME.return
180.ESAMPLE
181
182Generally, two probes are defined for each normal system call as listed in the
183.IR syscalls(2)
184manual page, one for entry and one for return. Those system calls that never
185return do not have a corresponding
186.IR .return
187probe.
188.PP
df7f3a01 189Each probe alias provides a variety of variables. Looking at the tapset source
1027502b
FCE
190code is the most reliable way. Generally, each variable listed in the standard
191manual page is made available as a script-level variable, so
192.IR syscall.open
193exposes
194.IR filename ", " flags ", and " mode .
195In addition, a standard suite of variables is available at most aliases:
196.TP
197.IR argstr
198A pretty-printed form of the entire argument list, without parentheses.
199.TP
200.IR name
201The name of the system call.
202.TP
203.IR retstr
204For return probes, a pretty-printed form of the system-call result.
205.PP
df7f3a01
FCE
206As usual for probe aliases, these variables are all simply initialized
207once from the underlying $context variables, so that later changes to
208$context variables are not automatically reflected. Not all probe
209aliases obey all of these general guidelines. Please report any
210bothersome ones you encounter as a bug.
1027502b
FCE
211
212
ba4a90fd
FCE
213.SS TIMERS
214
215Intervals defined by the standard kernel "jiffies" timer may be used
216to trigger probe handlers asynchronously. Two probe point variants
217are supported by the translator:
ca88561f 218
ba4a90fd
FCE
219.SAMPLE
220timer.jiffies(N)
221timer.jiffies(N).randomize(M)
222.ESAMPLE
ca88561f 223
ba4a90fd
FCE
224The probe handler is run every N jiffies (a kernel-defined unit of
225time, typically between 1 and 60 ms). If the "randomize" component is
13d2ecdb 226given, a linearly distributed random value in the range [\-M..+M] is
ba4a90fd
FCE
227added to N every time the handler is run. N is restricted to a
228reasonable range (1 to around a million), and M is restricted to be
229smaller than N. There are no target variables provided in either
230context. It is possible for such probes to be run concurrently on
231a multi-processor computer.
422d1ceb 232.PP
197a4d62 233Alternatively, intervals may be specified in units of time.
422d1ceb 234There are two probe point variants similar to the jiffies timer:
ca88561f 235
422d1ceb
FCE
236.SAMPLE
237timer.ms(N)
238timer.ms(N).randomize(M)
239.ESAMPLE
ca88561f 240
197a4d62
JS
241Here, N and M are specified in milliseconds, but the full options for units
242are seconds (s/sec), milliseconds (ms/msec), microseconds (us/usec),
243nanoseconds (ns/nsec), and hertz (hz). Randomization is not supported for
244hertz timers.
245
246The actual resolution of the timers depends on the target kernel. For
247kernels prior to 2.6.17, timers are limited to jiffies resolution, so
248intervals are rounded up to the nearest jiffies interval. After 2.6.17,
249the implementation uses hrtimers for tighter precision, though the actual
250resolution will be arch-dependent. In either case, if the "randomize"
251component is given, then the random value will be added to the interval
252before any rounding occurs.
39e57ce0
FCE
253.PP
254Profiling timers are also available to provide probes that execute on all
3ca1f652
FCE
255CPUs at the rate of the system tick (CONFIG_HZ).
256This probe takes no parameters.
ca88561f 257
39e57ce0
FCE
258.SAMPLE
259timer.profile
260.ESAMPLE
ca88561f 261
39e57ce0
FCE
262Full context information of the interrupted process is available, making
263this probe suitable for a time-based sampling profiler.
ba4a90fd
FCE
264
265.SS DWARF
266
267This family of probe points uses symbolic debugging information for
268the target kernel/module/program, as may be found in unstripped
269executables, or the separate
270.I debuginfo
271packages. They allow placement of probes logically into the execution
272path of the target program, by specifying a set of points in the
273source or object code. When a matching statement executes on any
274processor, the probe handler is run in that context.
275.PP
276Points in a kernel, which are identified by
ca88561f 277module, source file, line number, function name, or some
6f05b6ab 278combination of these.
ba4a90fd
FCE
279.PP
280Here is a list of probe point families currently supported. The
281.B .function
282variant places a probe near the beginning of the named function, so that
283parameters are available as context variables. The
284.B .return
39e3139a
FCE
285variant places a probe at the moment
286.B after
287the return from the named function, so the return value is available
288as the "$return" context variable. The
54efe513 289.B .inline
b8da0ad1 290modifier for
54efe513 291.B .function
b8da0ad1
FCE
292filters the results to include only instances of inlined functions.
293The
294.B .call
4bda987e
SC
295modifier selects the opposite subset. The \textbf{.exported} modifier
296filters the results to include only exported functions. Inline
297functions do not have an identifiable return point, so
54efe513
GH
298.B .return
299is not supported on
300.B .inline
301probes. The
ba4a90fd
FCE
302.B .statement
303variant places a probe at the exact spot, exposing those local variables
304that are visible there.
ca88561f 305
ba4a90fd
FCE
306.SAMPLE
307kernel.function(PATTERN)
308.br
b8da0ad1
FCE
309kernel.function(PATTERN).call
310.br
ba4a90fd
FCE
311kernel.function(PATTERN).return
312.br
b8da0ad1 313kernel.function(PATTERN).inline
54efe513 314.br
592470cd
SC
315kernel.function(PATTERN).label(LPATTERN)
316.br
ba4a90fd
FCE
317module(MPATTERN).function(PATTERN)
318.br
b8da0ad1
FCE
319module(MPATTERN).function(PATTERN).call
320.br
ba4a90fd
FCE
321module(MPATTERN).function(PATTERN).return
322.br
b8da0ad1
FCE
323module(MPATTERN).function(PATTERN).inline
324.br
2cab6244
JS
325module(MPATTERN).function(PATTERN).label(LPATTERN)
326.br
54efe513 327.br
ba4a90fd
FCE
328kernel.statement(PATTERN)
329.br
37ebca01
FCE
330kernel.statement(ADDRESS).absolute
331.br
ba4a90fd 332module(MPATTERN).statement(PATTERN)
6f017dee
FCE
333.br
334process("PATH").function("NAME")
335.br
336process("PATH").statement("*@FILE.c:123")
337.br
b73a1293
SC
338process("PATH").library("PATH").function("NAME")
339.br
340process("PATH").library("PATH").statement("*@FILE.c:123")
341.br
6f017dee
FCE
342process("PATH").function("*").return
343.br
344process("PATH").function("myfun").label("foo")
5fa99496
FCE
345.br
346process(PID).statement(ADDRESS).absolute
ba4a90fd 347.ESAMPLE
ca88561f 348
6f017dee
FCE
349(See the USER-SPACE section below for more information on the process
350probes.)
351
ba4a90fd 352In the above list, MPATTERN stands for a string literal that aims to
592470cd
SC
353identify the loaded kernel module of interest and LPATTERN stands for
354a source program label. Both MPATTERN and LPATTERN may include the "*"
355"[]", and "?" wildcards.
356PATTERN stands for a string literal that
6f05b6ab 357aims to identify a point in the program. It is made up of three
ca88561f
MM
358parts:
359.IP \(bu 4
360The first part is the name of a function, as would appear in the
ba4a90fd
FCE
361.I nm
362program's output. This part may use the "*" and "?" wildcarding
ca88561f
MM
363operators to match multiple names.
364.IP \(bu 4
365The second part is optional and begins with the "@" character.
366It is followed by the path to the source file containing the function,
367which may include a wildcard pattern, such as mm/slab*.
79640c29 368If it does not match as is, an implicit "*/" is optionally added
ea384b8c 369.I before
79640c29
FCE
370the pattern, so that a script need only name the last few components
371of a possibly long source directory path.
ca88561f 372.IP \(bu 4
ba4a90fd 373Finally, the third part is optional if the file name part was given,
1bd128a3
SC
374and identifies the line number in the source file preceded by a ":"
375or a "+". The line number is assumed to be an
376absolute line number if preceded by a ":", or relative to the entry of
99a5f9cf
SC
377the function if preceded by a "+".
378All the lines in the function can be matched with ":*".
f7470174 379A range of lines x through y can be matched with ":x\-y".
ca88561f 380.PP
ba4a90fd 381As an alternative, PATTERN may be a numeric constant, indicating an
ea384b8c
FCE
382address. Such an address may be found from symbol tables of the
383appropriate kernel / module object file. It is verified against
384known statement code boundaries, and will be relocated for use at
385run time.
386.PP
387In guru mode only, absolute kernel-space addresses may be specified with
388the ".absolute" suffix. Such an address is considered already relocated,
389as if it came from
390.BR /proc/kallsyms ,
391so it cannot be checked against statement/instruction boundaries.
6f017dee
FCE
392
393.SS CONTEXT VARIABLES
394
ba4a90fd 395.PP
6f017dee 396Many of the source-level context variables, such as function parameters,
ba4a90fd
FCE
397locals, globals visible in the compilation unit, may be visible to
398probe handlers. They may refer to these variables by prefixing their
399name with "$" within the scripts. In addition, a special syntax
6f017dee
FCE
400allows limited traversal of structures, pointers, and arrays. More
401syntax allows pretty-printing of individual variables or their groups.
402See also
403.BR @cast .
404
ba4a90fd
FCE
405.TP
406$var
407refers to an in-scope variable "var". If it's an integer-like type,
7b9361d5
FCE
408it will be cast to a 64-bit int for systemtap script use. String-like
409pointers (char *) may be copied to systemtap string values using the
410.IR kernel_string " or " user_string
411functions.
ba4a90fd 412.TP
ab5e90c2
FCE
413$var\->field traversal via a structure's or a pointer's field. This
414generalized indirection operator may be repeated to follow more
415levels. Note that the
416.IR .
417operator is not used for plain structure
418members, only
419.IR \->
420for both purposes. (This is because "." is reserved for string
421concatenation.)
ba4a90fd 422.TP
a43ba433
FCE
423$return
424is available in return probes only for functions that are declared
425with a return value.
426.TP
ba4a90fd 427$var[N]
33b081c5
JS
428indexes into an array. The index given with a literal number or even
429an arbitrary numeric expression.
6f017dee
FCE
430.PP
431A number of operators exist for such basic context variable expressions:
34af38db 432.TP
2cb3fe26
SC
433$$vars
434expands to a character string that is equivalent to
6f017dee
FCE
435.SAMPLE
436sprintf("parm1=%x ... parmN=%x var1=%x ... varN=%x",
437 parm1, ..., parmN, var1, ..., varN)
438.ESAMPLE
439for each variable in scope at the probe point. Some values may be
440printed as
441.IR =?
442if their run-time location cannot be found.
2cb3fe26
SC
443.TP
444$$locals
a43ba433 445expands to a subset of $$vars for only local variables.
2cb3fe26
SC
446.TP
447$$parms
a43ba433
FCE
448expands to a subset of $$vars for only function parameters.
449.TP
450$$return
451is available in return probes only. It expands to a string that
fd574705 452is equivalent to sprintf("return=%x", $return)
a43ba433 453if the probed function has a return value, or else an empty string.
6f017dee
FCE
454.TP
455& $EXPR
456expands to the address of the given context variable expression, if it
457is addressable.
458.TP
459@defined($EXPR)
460expands to 1 or 0 iff the given context variable expression is resolvable,
461for use in conditionals such as
462.SAMPLE
f7470174 463@defined($foo\->bar) ? $foo\->bar : 0
6f017dee
FCE
464.ESAMPLE
465.TP
466$EXPR$
467expands to a string with all of $EXPR's members, equivalent to
468.SAMPLE
469sprintf("{.a=%i, .b=%u, .c={...}, .d=[...]}",
470 $EXPR\->a, $EXPR\->b)
471.ESAMPLE
472.TP
473$EXPR$$
474expands to a string with all of $var's members and submembers, equivalent to
475.SAMPLE
476sprintf("{.a=%i, .b=%u, .c={.x=%p, .y=%c}, .d=[%i, ...]}",
477 $EXPR\->a, $EXPR\->b, $EXPR\->c\->x, $EXPR\->c\->y, $EXPR\->d[0])
478.ESAMPLE
479
39e3139a
FCE
480.PP
481For ".return" probes, context variables other than the "$return"
482value itself are only available for the function call parameters.
483The expressions evaluate to the
484.IR entry-time
485values of those variables, since that is when a snapshot is taken.
486Other local variables are not generally accessible, since by the time
487a ".return" probe hits, the probed function will have already returned.
8cc799a5
JS
488.PP
489Arbitrary entry-time expressions can also be saved for ".return"
490probes using the
491.IR @entry(expr)
492operator. For example, one can compute the elapsed time of a function:
493.SAMPLE
494probe kernel.function("do_filp_open").return {
495 println( get_timeofday_us() \- @entry(get_timeofday_us()) )
496}
497.ESAMPLE
39e3139a 498
ba4a90fd 499
94c3c803
AM
500.SS DWARFLESS
501In absence of debugging information, entry & exit points of kernel & module
502functions can be probed using the "kprobe" family of probes.
503However, these do not permit looking up the arguments / local variables
504of the function.
505Following constructs are supported :
506.SAMPLE
507kprobe.function(FUNCTION)
508kprobe.function(FUNCTION).return
509kprobe.module(NAME).function(FUNCTION)
510kprobe.module(NAME).function(FUNCTION).return
511kprobe.statement.(ADDRESS).absolute
512.ESAMPLE
513.PP
514Probes of type
515.B function
516are recommended for kernel functions, whereas probes of type
517.B module
518are recommended for probing functions of the specified module.
519In case the absolute address of a kernel or module function is known,
520.B statement
521probes can be utilized.
522.PP
523Note that
524.I FUNCTION
525and
526.I MODULE
527names
528.B must not
529contain wildcards, or the probe will not be registered.
530Also, statement probes must be run under guru-mode only.
531
532
1ada6f08 533.SS USER-SPACE
0a1c696d
FCE
534Support for user-space probing is available for kernels
535that are configured with the utrace extensions. See
536.SAMPLE
537http://people.redhat.com/roland/utrace/
538.ESAMPLE
539.PP
540There are several forms. First, a non-symbolic probe point:
1ada6f08
FCE
541.SAMPLE
542process(PID).statement(ADDRESS).absolute
543.ESAMPLE
544is analogous to
545.IR
546kernel.statement(ADDRESS).absolute
547in that both use raw (unverified) virtual addresses and provide
548no $variables. The target PID parameter must identify a running
549process, and ADDRESS should identify a valid instruction address.
550All threads of that process will be probed.
29cb9b42 551.PP
0a1c696d
FCE
552Second, non-symbolic user-kernel interface events handled by
553utrace may be probed:
29cb9b42 554.SAMPLE
dd078c96 555process(PID).begin
82f0e81b 556process("FULLPATH").begin
986e98de 557process.begin
dd078c96 558process(PID).thread.begin
82f0e81b 559process("FULLPATH").thread.begin
986e98de 560process.thread.begin
dd078c96 561process(PID).end
82f0e81b 562process("FULLPATH").end
986e98de 563process.end
dd078c96 564process(PID).thread.end
82f0e81b 565process("FULLPATH").thread.end
986e98de 566process.thread.end
29cb9b42 567process(PID).syscall
82f0e81b 568process("FULLPATH").syscall
986e98de 569process.syscall
29cb9b42 570process(PID).syscall.return
82f0e81b 571process("FULLPATH").syscall.return
986e98de 572process.syscall.return
0afb7073 573process(PID).insn
82f0e81b 574process("FULLPATH").insn
0afb7073 575process(PID).insn.block
82f0e81b 576process("FULLPATH").insn.block
29cb9b42
DS
577.ESAMPLE
578.PP
579A
dd078c96 580.B .begin
82f0e81b 581probe gets called when new process described by PID or FULLPATH gets created.
29cb9b42 582A
dd078c96 583.B .thread.begin
82f0e81b 584probe gets called when a new thread described by PID or FULLPATH gets created.
159cb109 585A
dd078c96 586.B .end
82f0e81b 587probe gets called when process described by PID or FULLPATH dies.
dd078c96
DS
588A
589.B .thread.end
82f0e81b 590probe gets called when a thread described by PID or FULLPATH dies.
29cb9b42
DS
591A
592.B .syscall
82f0e81b 593probe gets called when a thread described by PID or FULLPATH makes a
6270adc1
MH
594system call. The system call number is available in the
595.BR $syscall
596context variable, and the first 6 arguments of the system call
597are available in the
598.BR $argN
599(ex. $arg1, $arg2, ...) context variable.
29cb9b42
DS
600A
601.B .syscall.return
82f0e81b 602probe gets called when a thread described by PID or FULLPATH returns from a
5d67b47c
MH
603system call. The system call number is available in the
604.BR $syscall
605context variable, and the return value of the system call is available
606in the
607.BR $return
29cb9b42 608context variable.
a96d1db0 609A
0afb7073 610.B .insn
82f0e81b 611probe gets called for every single-stepped instruction of the process described by PID or FULLPATH.
0afb7073
FCE
612A
613.B .insn.block
82f0e81b
FCE
614probe gets called for every block-stepped instruction of the process described by PID or FULLPATH.
615.PP
616If a process probe is specified without a PID or FULLPATH, all user
617threads will be probed. However, if systemtap was invoked with the
f7470174 618.IR \-c " or " \-x
82f0e81b 619options, then process probes are restricted to the process
6d5d594e
LB
620hierarchy associated with the target process. If a process probe is
621specified without a PID or FULLPATH, but with the
622.IR \-c "
623option, the PATH of the
624.IR \-c "
625cmd will be heuristically filled into the process PATH.
0a1c696d
FCE
626
627.PP
628Third, symbolic static instrumentation compiled into programs and
629shared libraries may be
630probed:
631.SAMPLE
632process("PATH").mark("LABEL")
a794dbeb 633process("PATH").provider("PROVIDER").mark("LABEL")
0a1c696d
FCE
634.ESAMPLE
635.PP
f28a8c28
SC
636A
637.B .mark
638probe gets called via a static probe which is defined in the
a794dbeb
FCE
639application by STAP_PROBE1(PROVIDER,LABEL,arg1), which is defined in
640sdt.h. The handle is an application handle, LABEL corresponds to
641the .mark argument, and arg1 is the argument. STAP_PROBE1 is used for
642probes with 1 argument, STAP_PROBE2 is used for probes with 2
643arguments, and so on. The arguments of the probe are available in the
644context variables $arg1, $arg2, ... An alternative to using the
645STAP_PROBE macros is to use the dtrace script to create custom macros.
646Additionally, the variables $$name and $$provider are available as
647parts of the probe point name.
0a1c696d 648
29cb9b42 649.PP
0a1c696d
FCE
650Finally, full symbolic source-level probes in user-space programs
651and shared libraries are supported. These are exactly analogous
652to the symbolic DWARF-based kernel/module probes described above,
f7470174 653and expose similar contextual $variables.
0a1c696d
FCE
654.SAMPLE
655process("PATH").function("NAME")
656process("PATH").statement("*@FILE.c:123")
4d0fcb93
SC
657process("PATH").plt("NAME")
658process("PATH").library("PATH").plt("NAME")
b73a1293
SC
659process("PATH").library("PATH").function("NAME")
660process("PATH").library("PATH").statement("*@FILE.c:123")
0a1c696d
FCE
661process("PATH").function("*").return
662process("PATH").function("myfun").label("foo")
663.ESAMPLE
664
665.PP
666Note that for all process probes,
29cb9b42 667.I PATH
ea384b8c
FCE
668names refer to executables that are searched the same way shells do: relative
669to the working directory if they contain a "/" character, otherwise in
670.BR $PATH .
d1bcbe71
RH
671If PATH names refer to scripts, the actual interpreters (specified in the
672script in the first line after the #! characters) are probed.
b73a1293
SC
673If PATH is a process component parameter referring to shared libraries
674then all processes that map it at runtime would be selected for
675probing. If PATH is a library component parameter referring to shared
676libraries then the process specified by the process component would be
4d0fcb93
SC
677selected. A .plt probe will probe functions in the program linkage table
678corresponding to the rest of the probe point. .plt can be specified
679as a shorthand for .plt("*").
82f0e81b
FCE
680If the PATH string contains wildcards as in the MPATTERN case, then
681standard globbing is performed to find all matching paths. In this
682case, the
683.BR $PATH
684environment variable is not used.
685
686.PP
153e7a22
FCE
687If systemtap was invoked with the
688.IR \-c " or " \-x
760695db
FCE
689options, then process probes are restricted to the process
690hierarchy associated with the target process.
1ada6f08 691
9cb48751
DS
692.SS PROCFS
693
694These probe points allow procfs "files" in
c243f608
LB
695/proc/systemtap/MODNAME to be created, read and written using a
696permission that may be modified using the proper umask value. Default permissions are 0400 for read
697probes, and 0200 for write probes. If both a read and write probe are being
698used on the same file, a default permission of 0600 will be used.
699Using procfs.umask(0040).read would
700result in a 0404 permission set for the file.
9cb48751
DS
701.RI ( MODNAME
702is the name of the systemtap module). The
703.I proc
704filesystem is a pseudo-filesystem which is used an an interface to
c243f608 705kernel data structures. There are several probe point variants supported
9cb48751 706by the translator:
ca88561f 707
9cb48751
DS
708.SAMPLE
709procfs("PATH").read
c243f608 710procfs("PATH").umask(UMASK).read
38975255 711procfs("PATH").read.maxsize(MAXSIZE)
c243f608 712procfs("PATH").umask(UMASK).maxsize(MAXSIZE)
9cb48751 713procfs("PATH").write
c243f608 714procfs("PATH").umask(UMASK).write
9cb48751 715procfs.read
c243f608 716procfs.umask(UMASK).read
38975255 717procfs.read.maxsize(MAXSIZE)
c243f608 718procfs.umask(UMASK).read.maxsize(MAXSIZE)
9cb48751 719procfs.write
c243f608 720procfs.umask(UMASK).write
9cb48751 721.ESAMPLE
ca88561f 722
9cb48751
DS
723.I PATH
724is the file name (relative to /proc/systemtap/MODNAME) to be created.
725If no
726.I PATH
727is specified (as in the last two variants above),
728.I PATH
729defaults to "command".
730.PP
731When a user reads /proc/systemtap/MODNAME/PATH, the corresponding
732procfs
733.I read
734probe is triggered. The string data to be read should be assigned to
735a variable named
736.IR $value ,
737like this:
ca88561f 738
9cb48751
DS
739.SAMPLE
740procfs("PATH").read { $value = "100\\n" }
741.ESAMPLE
742.PP
743When a user writes into /proc/systemtap/MODNAME/PATH, the
744corresponding procfs
745.I write
746probe is triggered. The data the user wrote is available in the
747string variable named
748.IR $value ,
749like this:
ca88561f 750
9cb48751
DS
751.SAMPLE
752procfs("PATH").write { printf("user wrote: %s", $value) }
753.ESAMPLE
38975255
DS
754.PP
755.I MAXSIZE
756is the size of the procfs read buffer. Specifying
757.I MAXSIZE
758allows larger procfs output. If no
759.I MAXSIZE
760is specified, the procfs read buffer defaults to
761.I STP_PROCFS_BUFSIZE
762(which defaults to
763.IR MAXSTRINGLEN ,
764the maximum length of a string).
765If setting the procfs read buffers for more than one file is needed,
766it may be easiest to override the
767.I STP_PROCFS_BUFSIZE
768definition.
769Here's an example of using
770.IR MAXSIZE :
771
772.SAMPLE
773procfs.read.maxsize(1024) {
774 $value = "long string..."
775 $value .= "another long string..."
776 $value .= "another long string..."
777 $value .= "another long string..."
778}
779.ESAMPLE
9cb48751 780
6f05b6ab
FCE
781.SS MARKERS
782
783This family of probe points hooks up to static probing markers
784inserted into the kernel or modules. These markers are special macro
785calls inserted by kernel developers to make probing faster and more
786reliable than with DWARF-based probes. Further, DWARF debugging
787information is
788.I not
789required to probe markers.
790
791Marker probe points begin with
f781f849
DS
792.BR kernel .
793The next part names the marker itself:
6f05b6ab
FCE
794.BR mark("name") .
795The marker name string, which may contain the usual wildcard characters,
796is matched against the names given to the marker macros when the kernel
eb973c2a
DS
797and/or module was compiled. Optionally, you can specify
798.BR format("format") .
37f6433e 799Specifying the marker format string allows differentiation between two
eb973c2a 800markers with the same name but different marker format strings.
6f05b6ab
FCE
801
802The handler associated with a marker-based probe may read the
803optional parameters specified at the macro call site. These are
804named
805.BR $arg1 " through " $argNN ,
806where NN is the number of parameters supplied by the macro. Number
807and string parameters are passed in a type-safe manner.
808
eb973c2a
DS
809The marker format string associated with a marker is available in
810.BR $format .
37f6433e 811And also the marker name string is available in
bc54e71c 812.BR $name .
eb973c2a 813
bc724b8b
JS
814.SS TRACEPOINTS
815
816This family of probe points hooks up to static probing tracepoints
817inserted into the kernel or modules. As with markers, these
818tracepoints are special macro calls inserted by kernel developers to
819make probing faster and more reliable than with DWARF-based probes,
820and DWARF debugging information is not required to probe tracepoints.
821Tracepoints have an extra advantage of more strongly-typed parameters
822than markers.
823
824Tracepoint probes begin with
825.BR kernel .
826The next part names the tracepoint itself:
827.BR trace("name") .
828The tracepoint name string, which may contain the usual wildcard
829characters, is matched against the names defined by the kernel
830developers in the tracepoint header files.
831
832The handler associated with a tracepoint-based probe may read the
833optional parameters specified at the macro call site. These are
834named according to the declaration by the tracepoint author. For
835example, the tracepoint probe
836.BR kernel.trace("sched_switch")
837provides the parameters
838.BR $rq ", " $prev ", and " $next .
839If the parameter is a complex type, as in a struct pointer, then a
840script can access fields with the same syntax as DWARF $target
841variables. Also, tracepoint parameters cannot be modified, but in
842guru-mode a script may modify fields of parameters.
843
844The name of the tracepoint is available in
845.BR $$name ,
846and a string of name=value pairs for all parameters of the tracepoint
847is available in
046e7190 848.BR $$vars " or " $$parms .
bc724b8b 849
dd225250
PS
850.SS HARDWARE BREAKPOINTS
851This family of probes is used to set hardware watchpoints for a given
852 (global) kernel symbol. The probes take three components as inputs :
853
8541. The
855.BR virtual address / name
856of the kernel symbol to be traced is supplied as argument to this class
857of probes. ( Probes for only data segment variables are supported. Probing
858local variables of a function cannot be done.)
859
8602. Nature of access to be probed :
861a.
862.I .write
863probe gets triggered when a write happens at the specified address/symbol
864name.
865b.
866.I rw
867probe is triggered when either a read or write happens.
868
8693.
870.BR .length
871(optional)
872Users have the option of specifying the address interval to be probed
873using "length" constructs. The user-specified length gets approximated
874to the closest possible address length that the architecture can
875support. If the specified length exceeds the limits imposed by
876architecture, an error message is flagged and probe registration fails.
877Wherever 'length' is not specified, the translator requests a hardware
878breakpoint probe of length 1. It should be noted that the "length"
879construct is not valid with symbol names.
880
881Following constructs are supported :
882.SAMPLE
883probe kernel.data(ADDRESS).write
884probe kernel.data(ADDRESS).rw
885probe kernel.data(ADDRESS).length(LEN).write
886probe kernel.data(ADDRESS).length(LEN).rw
887probe kernel.data("SYMBOL_NAME").write
888probe kernel.data("SYMBOL_NAME").rw
889.ESAMPLE
890
891This set of probes make use of the debug registers of the processor,
892which is a scarce resource. (4 on x86 , 1 on powerpc ) The script
893translation flags a warning if a user requests more hardware breakpoint probes
894than the limits set by architecture. For example,a pass-2 warning is flashed
895when an input script requests 5 hardware breakpoint probes on an x86
896system while x86 architecture supports a maximum of 4 breakpoints.
897Users are cautioned to set probes judiciously.
898
ba4a90fd
FCE
899.SH EXAMPLES
900.PP
901Here are some example probe points, defining the associated events.
902.TP
903begin, end, end
904refers to the startup and normal shutdown of the session. In this
905case, the handler would run once during startup and twice during
906shutdown.
907.TP
908timer.jiffies(1000).randomize(200)
13d2ecdb 909refers to a periodic interrupt, every 1000 +/\- 200 jiffies.
ba4a90fd
FCE
910.TP
911kernel.function("*init*"), kernel.function("*exit*")
912refers to all kernel functions with "init" or "exit" in the name.
913.TP
914kernel.function("*@kernel/sched.c:240")
915refers to any functions within the "kernel/sched.c" file that span
6ff00e1d
FCE
916line 240.
917.BR
918Note
919that this is
920.BR not
921a probe at the statement at that line number. Use the
922.IR
923kernel.statement
924probe instead.
ba4a90fd 925.TP
6f05b6ab
FCE
926kernel.mark("getuid")
927refers to an STAP_MARK(getuid, ...) macro call in the kernel.
928.TP
ba4a90fd
FCE
929module("usb*").function("*sync*").return
930refers to the moment of return from all functions with "sync" in the
931name in any of the USB drivers.
932.TP
933kernel.statement(0xc0044852)
934refers to the first byte of the statement whose compiled instructions
935include the given address in the kernel.
b4ceace2 936.TP
a5ae3f3d 937kernel.statement("*@kernel/sched.c:2917")
1bd128a3
SC
938refers to the statement of line 2917 within "kernel/sched.c".
939.TP
940kernel.statement("bio_init@fs/bio.c+3")
941refers to the statement at line bio_init+3 within "fs/bio.c".
a5ae3f3d 942.TP
dd225250
PS
943kernel.data("pid_max").write
944refers to a hardware preakpoint of type "write" set on pid_max
945.TP
729286d8 946syscall.*.return
b4ceace2 947refers to the group of probe aliases with any name in the third position
ba4a90fd 948
f33e9151
FCE
949.SS PERF
950
951This
952.IR prototype
953family of probe points interfaces to the kernel "perf event"
954infrasture for controlling hardware performance counters.
955The events being attached to are described by the "type",
956"config" fields of the
957.IR perf_event_attr
958structure, and are sampled at an interval governed by the
959"sample_period" field.
960
961These fields are made available to systemtap scripts using
962the following syntax:
963.SAMPLE
bb9fd173 964probe perf.type(NN).config(MM).sample(XX)
f33e9151
FCE
965probe perf.type(NN).config(MM)
966.ESAMPLE
19f00bd9
FCE
967The systemtap probe handler is called once per XX increments
968of the underlying performance counter. The default sampling
969count is 1000000.
f33e9151
FCE
970The range of valid type/config is described by the
971.IR perf_event_open (2)
972system call, and/or the
973.IR linux/perf_event.h
8fb91f5f
FCE
974file. Invalid combinations or exhausted hardware counter resources
975result in errors during systemtap script startup. Systemtap does
f33e9151
FCE
976not sanity-check the values: it merely passes them through to
977the kernel for error- and safety-checking.
978
ba4a90fd 979.SH SEE ALSO
78db65bd 980.IR stap (1),
89965a32
FCE
981.IR probe::* (3stap),
982.IR tapset::* (3stap)
This page took 0.231455 seconds and 5 git commands to generate.