1PERF-PROBE(1) perf Manual PERF-PROBE(1)
2
3
4
6 perf-probe - Define new dynamic tracepoints
7
9 perf probe [options] --add=PROBE [...]
10 or
11 perf probe [options] PROBE
12 or
13 perf probe [options] --del=[GROUP:]EVENT [...]
14 or
15 perf probe --list[=[GROUP:]EVENT]
16 or
17 perf probe [options] --line=LINE
18 or
19 perf probe [options] --vars=PROBEPOINT
20 or
21 perf probe [options] --funcs
22 or
23 perf probe [options] --definition=PROBE [...]
24
26 This command defines dynamic tracepoint events, by symbol and registers
27 without debuginfo, or by C expressions (C line numbers, C function
28 names, and C local variables) with debuginfo.
29
31 -k, --vmlinux=PATH
32 Specify vmlinux path which has debuginfo (Dwarf binary). Only when
33 using this with --definition, you can give an offline vmlinux file.
34
35 -m, --module=MODNAME|PATH
36 Specify module name in which perf-probe searches probe points or
37 lines. If a path of module file is passed, perf-probe treat it as
38 an offline module (this means you can add a probe on a module which
39 has not been loaded yet).
40
41 -s, --source=PATH
42 Specify path to kernel source.
43
44 -v, --verbose
45 Be more verbose (show parsed arguments, etc). Can not use with -q.
46
47 -q, --quiet
48 Be quiet (do not show any messages including errors). Can not use
49 with -v.
50
51 -a, --add=
52 Define a probe event (see PROBE SYNTAX for detail).
53
54 -d, --del=
55 Delete probe events. This accepts glob wildcards(*, ?) and
56 character classes(e.g. [a-z], [!A-Z]).
57
58 -l, --list[=[GROUP:]EVENT]
59 List up current probe events. This can also accept filtering
60 patterns of event names. When this is used with --cache, perf shows
61 all cached probes instead of the live probes.
62
63 -L, --line=
64 Show source code lines which can be probed. This needs an argument
65 which specifies a range of the source code. (see LINE SYNTAX for
66 detail)
67
68 -V, --vars=
69 Show available local variables at given probe point. The argument
70 syntax is same as PROBE SYNTAX, but NO ARGs.
71
72 --externs
73 (Only for --vars) Show external defined variables in addition to
74 local variables.
75
76 --no-inlines
77 (Only for --add) Search only for non-inlined functions. The
78 functions which do not have instances are ignored.
79
80 -F, --funcs[=FILTER]
81 Show available functions in given module or kernel. With -x/--exec,
82 can also list functions in a user space executable / shared
83 library. This also can accept a FILTER rule argument.
84
85 -D, --definition=
86 Show trace-event definition converted from given probe-event
87 instead of write it into tracing/[k,u]probe_events.
88
89 --filter=FILTER
90 (Only for --vars and --funcs) Set filter. FILTER is a combination
91 of glob pattern, see FILTER PATTERN for detail. Default FILTER is
92 "!k???tab_* & !crc_*" for --vars, and "!_*" for --funcs. If several
93 filters are specified, only the last filter is used.
94
95 -f, --force
96 Forcibly add events with existing name.
97
98 -n, --dry-run
99 Dry run. With this option, --add and --del doesn’t execute actual
100 adding and removal operations.
101
102 --cache
103 (With --add) Cache the probes. Any events which successfully added
104 are also stored in the cache file. (With --list) Show cached
105 probes. (With --del) Remove cached probes.
106
107 --max-probes=NUM
108 Set the maximum number of probe points for an event. Default is
109 128.
110
111 -x, --exec=PATH
112 Specify path to the executable or shared library file for user
113 space tracing. Can also be used with --funcs option.
114
115 --demangle
116 Demangle application symbols. --no-demangle is also available for
117 disabling demangling.
118
119 --demangle-kernel
120 Demangle kernel symbols. --no-demangle-kernel is also available for
121 disabling kernel demangling.
122
123 In absence of -m/-x options, perf probe checks if the first argument
124 after the options is an absolute path name. If its an absolute path,
125 perf probe uses it as a target module/target user space binary to
126 probe.
127
129 Probe points are defined by following syntax.
130
131 1) Define event based on function name
132 [[GROUP:]EVENT=]FUNC[@SRC][:RLN|+OFFS|%return|;PTN] [ARG ...]
133
134 2) Define event based on source file with line number
135 [[GROUP:]EVENT=]SRC:ALN [ARG ...]
136
137 3) Define event based on source file with lazy pattern
138 [[GROUP:]EVENT=]SRC;PTN [ARG ...]
139
140 4) Pre-defined SDT events or cached event with name
141 %[sdt_PROVIDER:]SDTEVENT
142 or,
143 sdt_PROVIDER:SDTEVENT
144
145 EVENT specifies the name of new event, if omitted, it will be set the
146 name of the probed function. You can also specify a group name by
147 GROUP, if omitted, set probe is used for kprobe and probe_<bin> is used
148 for uprobe. Note that using existing group name can conflict with other
149 events. Especially, using the group name reserved for kernel modules
150 can hide embedded events in the modules. FUNC specifies a probed
151 function name, and it may have one of the following options; +OFFS is
152 the offset from function entry address in bytes, :RLN is the
153 relative-line number from function entry line, and %return means that
154 it probes function return. And ;PTN means lazy matching pattern (see
155 LAZY MATCHING). Note that ;PTN must be the end of the probe point
156 definition. In addition, @SRC specifies a source file which has that
157 function. It is also possible to specify a probe point by the source
158 line number or lazy matching by using SRC:ALN or SRC;PTN syntax, where
159 SRC is the source file path, :ALN is the line number and ;PTN is the
160 lazy matching pattern. ARG specifies the arguments of this probe point,
161 (see PROBE ARGUMENT). SDTEVENT and PROVIDER is the pre-defined event
162 name which is defined by user SDT (Statically Defined Tracing) or the
163 pre-cached probes with event name. Note that before using the SDT
164 event, the target binary (on which SDT events are defined) must be
165 scanned by perf-buildid-cache(1) to make SDT events as cached events.
166
167 For details of the SDT, see below.
168 https://sourceware.org/gdb/onlinedocs/gdb/Static-Probe-Points.html
169
171 Each probe argument follows below syntax.
172
173 [NAME=]LOCALVAR|$retval|%REG|@SYMBOL[:TYPE]
174
175 NAME specifies the name of this argument (optional). You can use the
176 name of local variable, local data structure member (e.g. var→field,
177 var.field2), local array with fixed index (e.g. array[1], var→array[0],
178 var→pointer[2]), or kprobe-tracer argument format (e.g. $retval, %ax,
179 etc). Note that the name of this argument will be set as the last
180 member name if you specify a local data structure member (e.g. field2
181 for var→field1.field2.) $vars and $params special arguments are also
182 available for NAME, $vars is expanded to the local variables (including
183 function parameters) which can access at given probe point. $params is
184 expanded to only the function parameters. TYPE casts the type of this
185 argument (optional). If omitted, perf probe automatically set the type
186 based on debuginfo. Currently, basic types
187 (u8/u16/u32/u64/s8/s16/s32/s64), signedness casting (u/s), "string" and
188 bitfield are supported. (see TYPES for detail)
189
190 On x86 systems %REG is always the short form of the register: for
191 example %AX. %RAX or %EAX is not valid.
192
194 Basic types (u8/u16/u32/u64/s8/s16/s32/s64) are integer types. Prefix s
195 and u means those types are signed and unsigned respectively. Traced
196 arguments are shown in decimal (signed) or hex (unsigned). You can also
197 use s or u to specify only signedness and leave its size auto-detected
198 by perf probe. String type is a special type, which fetches a
199 "null-terminated" string from kernel space. This means it will fail and
200 store NULL if the string container has been paged out. You can specify
201 string type only for the local variable or structure member which is an
202 array of or a pointer to char or unsigned char type. Bitfield is
203 another special type, which takes 3 parameters, bit-width, bit-offset,
204 and container-size (usually 32). The syntax is;
205
206 b<bit-width>@<bit-offset>/<container-size>
207
209 Line range is described by following syntax.
210
211 "FUNC[@SRC][:RLN[+NUM|-RLN2]]|SRC[:ALN[+NUM|-ALN2]]"
212
213 FUNC specifies the function name of showing lines. RLN is the start
214 line number from function entry line, and RLN2 is the end line number.
215 As same as probe syntax, SRC means the source file path, ALN is start
216 line number, and ALN2 is end line number in the file. It is also
217 possible to specify how many lines to show by using NUM. Moreover,
218 FUNC@SRC combination is good for searching a specific function when
219 several functions share same name. So, "source.c:100-120" shows lines
220 between 100th to l20th in source.c file. And "func:10+20" shows 20
221 lines from 10th line of func function.
222
224 The lazy line matching is similar to glob matching but ignoring spaces in both of pattern and target. So this accepts wildcards('*', '?') and character classes(e.g. [a-z], [!A-Z]).
225
226 e.g. a=* can matches a=b, a = b, a == b and so on.
227
228 This provides some sort of flexibility and robustness to probe point
229 definitions against minor code changes. For example, actual 10th line
230 of schedule() can be moved easily by modifying schedule(), but the same
231 line matching rq=cpu_rq* may still exist in the function.)
232
234 The filter pattern is a glob matching pattern(s) to filter variables.
235 In addition, you can use "!" for specifying filter-out rule. You also can give several rules combined with "&" or "|", and fold those rules as one rule by using "(" ")".
236
237 e.g. With --filter "foo* | bar*", perf probe -V shows variables which
238 start with "foo" or "bar". With --filter "!foo* & *bar", perf probe -V
239 shows variables which don’t start with "foo" and end with "bar", like
240 "fizzbar". But "foobar" is filtered out.
241
243 Display which lines in schedule() can be probed:
244
245 ./perf probe --line schedule
246
247 Add a probe on schedule() function 12th line with recording cpu local
248 variable:
249
250 ./perf probe schedule:12 cpu
251 or
252 ./perf probe --add='schedule:12 cpu'
253
254 Add one or more probes which has the name start with "schedule".
255
256 ./perf probe schedule*
257 or
258 ./perf probe --add='schedule*'
259
260 Add probes on lines in schedule() function which calls
261 update_rq_clock().
262
263 ./perf probe 'schedule;update_rq_clock*'
264 or
265 ./perf probe --add='schedule;update_rq_clock*'
266
267 Delete all probes on schedule().
268
269 ./perf probe --del='schedule*'
270
271 Add probes at zfree() function on /bin/zsh
272
273 ./perf probe -x /bin/zsh zfree or ./perf probe /bin/zsh zfree
274
275 Add probes at malloc() function on libc
276
277 ./perf probe -x /lib/libc.so.6 malloc or ./perf probe /lib/libc.so.6 malloc
278
280 perf-trace(1), perf-record(1), perf-buildid-cache(1)
281
282
283
284perf 06/18/2019 PERF-PROBE(1)