perf script: Add option to list dlfilters
[linux-2.6-block.git] / tools / perf / Documentation / perf-script.txt
CommitLineData
133dc4c3 1perf-script(1)
4778e0e8 2=============
0a02ad93
IM
3
4NAME
5----
133dc4c3 6perf-script - Read perf.data (created by perf record) and display trace output
0a02ad93
IM
7
8SYNOPSIS
9--------
10[verse]
133dc4c3
IM
11'perf script' [<options>]
12'perf script' [<options>] record <script> [<record-options>] <command>
13'perf script' [<options>] report <script> [script-args]
14'perf script' [<options>] <script> <required-script-args> [<record-options>] <command>
15'perf script' [<options>] <top-script> [script-args]
0a02ad93
IM
16
17DESCRIPTION
18-----------
19This command reads the input file and displays the trace recorded.
20
133dc4c3 21There are several variants of perf script:
a6005123 22
133dc4c3 23 'perf script' to see a detailed trace of the workload that was
a6005123
TZ
24 recorded.
25
cff68e58
TZ
26 You can also run a set of pre-canned scripts that aggregate and
27 summarize the raw trace data in various ways (the list of scripts is
133dc4c3 28 available via 'perf script -l'). The following variants allow you to
cff68e58
TZ
29 record and run those scripts:
30
133dc4c3
IM
31 'perf script record <script> <command>' to record the events required
32 for 'perf script report'. <script> is the name displayed in the
33 output of 'perf script --list' i.e. the actual script name minus any
d3c4f798
TZ
34 language extension. If <command> is not specified, the events are
35 recorded using the -a (system-wide) 'perf record' option.
a6005123 36
133dc4c3 37 'perf script report <script> [args]' to run and display the results
d3c4f798 38 of <script>. <script> is the name displayed in the output of 'perf
5c64f99b 39 script --list' i.e. the actual script name minus any language
133dc4c3 40 extension. The perf.data output from a previous run of 'perf script
a6005123 41 record <script>' is used and should be present for this command to
d3c4f798
TZ
42 succeed. [args] refers to the (mainly optional) args expected by
43 the script.
44
133dc4c3 45 'perf script <script> <required-script-args> <command>' to both
d3c4f798
TZ
46 record the events required for <script> and to run the <script>
47 using 'live-mode' i.e. without writing anything to disk. <script>
133dc4c3 48 is the name displayed in the output of 'perf script --list' i.e. the
d3c4f798
TZ
49 actual script name minus any language extension. If <command> is
50 not specified, the events are recorded using the -a (system-wide)
51 'perf record' option. If <script> has any required args, they
52 should be specified before <command>. This mode doesn't allow for
53 optional script args to be specified; if optional script args are
133dc4c3
IM
54 desired, they can be specified using separate 'perf script record'
55 and 'perf script report' commands, with the stdout of the record step
d3c4f798
TZ
56 piped to the stdin of the report script, using the '-o -' and '-i -'
57 options of the corresponding commands.
58
133dc4c3 59 'perf script <top-script>' to both record the events required for
d3c4f798
TZ
60 <top-script> and to run the <top-script> using 'live-mode'
61 i.e. without writing anything to disk. <top-script> is the name
133dc4c3 62 displayed in the output of 'perf script --list' i.e. the actual
d3c4f798
TZ
63 script name minus any language extension; a <top-script> is defined
64 as any script name ending with the string 'top'.
65
133dc4c3 66 [<record-options>] can be passed to the record steps of 'perf script
d3c4f798 67 record' and 'live-mode' variants; this isn't possible however for
133dc4c3 68 <top-script> 'live-mode' or 'perf script report' variants.
a6005123 69
cff68e58
TZ
70 See the 'SEE ALSO' section for links to language-specific
71 information on how to write and run your own trace scripts.
72
0a02ad93
IM
73OPTIONS
74-------
d3c4f798
TZ
75<command>...::
76 Any command you can specify in a shell.
77
0a02ad93 78-D::
5c64f99b 79--dump-raw-trace=::
0a02ad93
IM
80 Display verbose dump of the trace data.
81
a6005123
TZ
82-L::
83--Latency=::
84 Show latency attributes (irqs/preemption disabled, etc).
85
86-l::
87--list=::
88 Display a list of available trace scripts.
89
f526d68b 90-s ['lang']::
89fbf0b8
TZ
91--script=::
92 Process trace data with the given script ([lang]:script[.ext]).
f526d68b
TZ
93 If the string 'lang' is specified in place of a script name, a
94 list of supported languages will be displayed instead.
89fbf0b8
TZ
95
96-g::
97--gen-script=::
133dc4c3 98 Generate perf-script.[ext] starter script for given language,
89fbf0b8
TZ
99 using current perf.data.
100
291961fc
AH
101--dlfilter=<file>::
102 Filter sample events using the given shared object file.
103 Refer linkperf:perf-dlfilter[1]
104
638e2b99
AH
105--list-dlfilters=::
106 Display a list of available dlfilters. Use with option -v (must come
107 before option --list-dlfilters) to show long descriptions.
108
d3c4f798
TZ
109-a::
110 Force system-wide collection. Scripts run without a <command>
111 normally use -a by default, while scripts run with a <command>
112 normally don't - this option allows the latter to be run in
113 system-wide mode.
114
646420f1
SB
115-i::
116--input=::
efad1415 117 Input file name. (default: perf.data unless stdin is a fifo)
646420f1
SB
118
119-d::
120--debug-mode::
121 Do various checks like samples ordering and lost events.
d3c4f798 122
dc323ce8 123-F::
176fcc5c 124--fields::
745f43e3 125 Comma separated list of fields to print. Options are:
400ea6d3 126 comm, tid, pid, time, cpu, event, trace, ip, sym, dso, addr, symoff,
6b9bae63
KL
127 srcline, period, iregs, uregs, brstack, brstacksym, flags, bpf-output,
128 brstackinsn, brstackoff, callindent, insn, insnlen, synth, phys_addr,
c513de8a 129 metric, misc, srccode, ipc, data_page_size, code_page_size.
47e78084 130 Field list can be prepended with the type, trace, sw or hw,
1424dc96 131 to indicate to which event type the field list applies.
cbb0bba9 132 e.g., -F sw:comm,tid,time,ip,sym and -F trace:time,cpu,trace
c0230b2b 133
cbb0bba9 134 perf script -F <fields>
176fcc5c
ACM
135
136 is equivalent to:
137
cbb0bba9 138 perf script -F trace:<fields> -F sw:<fields> -F hw:<fields>
48000a1a 139
176fcc5c
ACM
140 i.e., the specified fields apply to all event types if the type string
141 is not given.
48000a1a 142
36ce5651
AK
143 In addition to overriding fields, it is also possible to add or remove
144 fields from the defaults. For example
145
146 -F -cpu,+insn
147
148 removes the cpu field and adds the insn field. Adding/removing fields
149 cannot be mixed with normal overriding.
150
176fcc5c
ACM
151 The arguments are processed in the order received. A later usage can
152 reset a prior request. e.g.:
48000a1a 153
cbb0bba9 154 -F trace: -F comm,tid,time,ip,sym
48000a1a 155
cbb0bba9 156 The first -F suppresses trace events (field list is ""), but then the
787bef17 157 second invocation sets the fields to comm,tid,time,ip,sym. In this case a
176fcc5c 158 warning is given to the user:
48000a1a 159
176fcc5c 160 "Overriding previous field request for all events."
48000a1a 161
96355f2c 162 Alternatively, consider the order:
48000a1a 163
cbb0bba9 164 -F comm,tid,time,ip,sym -F trace:
48000a1a 165
cbb0bba9 166 The first -F sets the fields for all events and the second -F
176fcc5c
ACM
167 suppresses trace events. The user is given a warning message about
168 the override, and the result of the above is that only S/W and H/W
169 events are displayed with the given fields.
48000a1a 170
6ef362fd
JO
171 It's possible tp add/remove fields only for specific event type:
172
173 -Fsw:-cpu,-period
174
175 removes cpu and period from software events.
176
176fcc5c
ACM
177 For the 'wildcard' option if a user selected field is invalid for an
178 event type, a message is displayed to the user that the option is
179 ignored for that type. For example:
48000a1a 180
cbb0bba9 181 $ perf script -F comm,tid,trace
176fcc5c
ACM
182 'trace' not valid for hardware events. Ignoring.
183 'trace' not valid for software events. Ignoring.
48000a1a 184
176fcc5c
ACM
185 Alternatively, if the type is given an invalid field is specified it
186 is an error. For example:
48000a1a 187
cbb0bba9 188 perf script -v -F sw:comm,tid,trace
176fcc5c 189 'trace' not valid for software events.
48000a1a 190
176fcc5c 191 At this point usage is displayed, and perf-script exits.
48000a1a 192
400ea6d3 193 The flags field is synthesized and may have a value when Instruction
f42907e8 194 Trace decoding. The flags are "bcrosyiABExgh" which stand for branch,
400ea6d3 195 call, return, conditional, system, asynchronous, interrupt,
f42907e8 196 transaction abort, trace begin, trace end, in transaction, VM-Entry, and VM-Exit
055cd33d
AH
197 respectively. Known combinations of flags are printed more nicely e.g.
198 "call" for "bc", "return" for "br", "jcc" for "bo", "jmp" for "b",
199 "int" for "bci", "iret" for "bri", "syscall" for "bcs", "sysret" for "brs",
200 "async" for "by", "hw int" for "bcyi", "tx abrt" for "bA", "tr strt" for "bB",
f42907e8
AH
201 "tr end" for "bE", "vmentry" for "bcg", "vmexit" for "bch".
202 However the "x" flag will be displayed separately in those
055cd33d 203 cases e.g. "jcc (x)" for a condition branch within a transaction.
400ea6d3 204
e216708d
AH
205 The callindent field is synthesized and may have a value when
206 Instruction Trace decoding. For calls and returns, it will display the
207 name of the symbol indented with spaces to reflect the stack depth.
208
224e2c97
AK
209 When doing instruction trace decoding insn and insnlen give the
210 instruction bytes and the instruction length of the current
211 instruction.
212
47e78084
AH
213 The synth field is used by synthesized events which may be created when
214 Instruction Trace decoding.
215
68fb45bf
AH
216 The ipc (instructions per cycle) field is synthesized and may have a value when
217 Instruction Trace decoding.
218
176fcc5c 219 Finally, a user may not set fields to none for all event types.
cbb0bba9 220 i.e., -F "" is not allowed.
176fcc5c 221
dc323ce8 222 The brstack output includes branch related information with raw addresses using the
48d02a1d 223 /v/v/v/v/cycles syntax in the following order:
dc323ce8
SE
224 FROM: branch source instruction
225 TO : branch target instruction
226 M/P/-: M=branch target mispredicted or branch direction was mispredicted, P=target predicted or direction predicted, -=not supported
227 X/- : X=branch inside a transactional region, -=not in transaction region or not supported
228 A/- : A=TSX abort entry, -=not aborted region or not supported
48d02a1d 229 cycles
dc323ce8
SE
230
231 The brstacksym is identical to brstack, except that the FROM and TO addresses are printed in a symbolic form if possible.
232
48d02a1d
AK
233 When brstackinsn is specified the full assembler sequences of branch sequences for each sample
234 is printed. This is the full execution path leading to the sample. This is only supported when the
235 sample was recorded with perf record -b or -j any.
236
106dacd8
MS
237 The brstackoff field will print an offset into a specific dso/binary.
238
4bd1bef8
AK
239 With the metric option perf script can compute metrics for
240 sampling periods, similar to perf stat. This requires
7db7218a 241 specifying a group with multiple events defining metrics with the :S option
4bd1bef8 242 for perf record. perf will sample on the first event, and
7db7218a 243 print computed metrics for all the events in the group. Please note
4bd1bef8 244 that the metric computed is averaged over the whole sampling
7db7218a 245 period (since the last sample), not just for the sample point.
4bd1bef8 246
28a0b398
JO
247 For sample events it's possible to display misc field with -F +misc option,
248 following letters are displayed for each bit:
249
bf30cc18
AB
250 PERF_RECORD_MISC_KERNEL K
251 PERF_RECORD_MISC_USER U
252 PERF_RECORD_MISC_HYPERVISOR H
253 PERF_RECORD_MISC_GUEST_KERNEL G
254 PERF_RECORD_MISC_GUEST_USER g
255 PERF_RECORD_MISC_MMAP_DATA* M
256 PERF_RECORD_MISC_COMM_EXEC E
257 PERF_RECORD_MISC_SWITCH_OUT S
258 PERF_RECORD_MISC_SWITCH_OUT_PREEMPT Sp
28a0b398
JO
259
260 $ perf script -F +misc ...
261 sched-messaging 1414 K 28690.636582: 4590 cycles ...
262 sched-messaging 1407 U 28690.636600: 325620 cycles ...
263 sched-messaging 1414 K 28690.636608: 19473 cycles ...
264 misc field ___________/
265
c0230b2b
DA
266-k::
267--vmlinux=<file>::
268 vmlinux pathname
269
270--kallsyms=<file>::
271 kallsyms pathname
272
273--symfs=<directory>::
274 Look for files with symbols relative to this directory.
275
276-G::
277--hide-call-graph::
278 When printing symbols do not display call chain.
745f43e3 279
64eff7d9
DA
280--stop-bt::
281 Stop display of callgraph at these symbols
282
c8e66720 283-C::
5d67be97
AB
284--cpu:: Only report samples for the list of CPUs provided. Multiple CPUs can
285 be provided as a comma-separated list with no space: 0,1. Ranges of
286 CPUs are specified with -: 0-2. Default is to report samples on all
287 CPUs.
288
e7984b7b
DA
289-c::
290--comms=::
291 Only display events for these comms. CSV that understands
292 file://filename entries.
293
e03eaa40
DA
294--pid=::
295 Only show events for given process ID (comma separated list).
296
297--tid=::
298 Only show events for given thread ID (comma separated list).
299
fbe96f29
SE
300-I::
301--show-info::
302 Display extended information about the perf.data file. This adds
303 information which may be very large and thus may clutter the display.
304 It currently includes: cpu and numa topology of the host system.
305 It can only be used with the perf script report mode.
306
0bc8d205
AN
307--show-kernel-path::
308 Try to resolve the path of [kernel.kallsyms]
309
ad7ebb9a
NK
310--show-task-events
311 Display task related events (e.g. FORK, COMM, EXIT).
312
ba1ddf42
NK
313--show-mmap-events
314 Display mmap related events (e.g. MMAP, MMAP2).
315
96a44bbc
HB
316--show-namespace-events
317 Display namespace events i.e. events of type PERF_RECORD_NAMESPACES.
318
7c14898b
AH
319--show-switch-events
320 Display context switch events i.e. events of type PERF_RECORD_SWITCH or
321 PERF_RECORD_SWITCH_CPU_WIDE.
322
3d7c27b6
JO
323--show-lost-events
324 Display lost events i.e. events of type PERF_RECORD_LOST.
325
3233b37a
JO
326--show-round-events
327 Display finished round events i.e. events of type PERF_RECORD_FINISHED_ROUND.
328
490c8cc9
JO
329--show-bpf-events
330 Display bpf events i.e. events of type PERF_RECORD_KSYMBOL and PERF_RECORD_BPF_EVENT.
331
160d4af9
NK
332--show-cgroup-events
333 Display cgroup events i.e. events of type PERF_RECORD_CGROUP.
334
92ecf3a6
AH
335--show-text-poke-events
336 Display text poke events i.e. events of type PERF_RECORD_TEXT_POKE and
337 PERF_RECORD_KSYMBOL.
338
77e0070d
MD
339--demangle::
340 Demangle symbol names to human readable form. It's enabled by default,
341 disable with --no-demangle.
342
343--demangle-kernel::
344 Demangle kernel symbol names to human readable form (for C++ kernels).
345
e90debdd
JO
346--header
347 Show perf.data header.
348
349--header-only
350 Show only perf.data header.
351
7a680eb9
AH
352--itrace::
353 Options for decoding instruction tracing data. The options are:
354
60b88d87 355include::itrace.txt[]
7a680eb9
AH
356
357 To disable decoding entirely, use --no-itrace.
358
a9710ba0
AK
359--full-source-path::
360 Show the full path for source files for srcline output.
361
6125cc8d
ACM
362--max-stack::
363 Set the stack depth limit when parsing the callchain, anything
364 beyond the specified depth will be ignored. This is a trade-off
365 between information loss and faster processing especially for
366 workloads that can have a very long callchain stack.
367 Note that when using the --itrace option the synthesized callchain size
368 will override this value if the synthesized callchain size is bigger.
369
fe176085 370 Default: 127
6125cc8d 371
83e19860
AH
372--ns::
373 Use 9 decimal places when displaying time (i.e. show the nanoseconds)
374
e0be62cc
JO
375-f::
376--force::
377 Don't do ownership validation.
378
a91f4c47
DA
379--time::
380 Only analyze samples within given time window: <start>,<stop>. Times
0ccc69ba 381 have the format seconds.nanoseconds. If start is not given (i.e. time
a91f4c47 382 string is ',x.y') then analysis starts at the beginning of the file. If
0ccc69ba 383 stop time is not given (i.e. time string is 'x.y,') then analysis goes
a77a05e2
AH
384 to end of file. Multiple ranges can be separated by spaces, which
385 requires the argument to be quoted e.g. --time "1234.567,1234.789 1235,"
a91f4c47 386
0ccc69ba 387 Also support time percent with multiple time ranges. Time string is
cc2ef584 388 'a%/n,b%/m,...' or 'a%-b%,c%-%d,...'.
2ab046cd
JY
389
390 For example:
cc2ef584 391 Select the second 10% time slice:
2ab046cd
JY
392 perf script --time 10%/2
393
cc2ef584 394 Select from 0% to 10% time slice:
2ab046cd
JY
395 perf script --time 0%-10%
396
cc2ef584 397 Select the first and second 10% time slices:
2ab046cd
JY
398 perf script --time 10%/1,10%/2
399
cc2ef584 400 Select from 0% to 10% and 30% to 40% slices:
2ab046cd
JY
401 perf script --time 0%-10%,30%-40%
402
48d02a1d 403--max-blocks::
5f8eec32 404 Set the maximum number of program blocks to print with brstackinsn for
48d02a1d
AK
405 each sample.
406
90b10f47
AK
407--reltime::
408 Print time stamps relative to trace start.
409
26567ed7
HPP
410--deltatime::
411 Print time stamps relative to previous event.
412
a14390fd
ACM
413--per-event-dump::
414 Create per event files with a "perf.data.EVENT.dump" name instead of
415 printing to stdout, useful, for instance, for generating flamegraphs.
416
325fbff5
NK
417--inline::
418 If a callgraph address belongs to an inlined function, the inline stack
d8a88dd2
MW
419 will be printed. Each entry has function name and file/line. Enabled by
420 default, disable with --no-inline.
325fbff5 421
b585ebdb
AK
422--insn-trace::
423 Show instruction stream for intel_pt traces. Combine with --xed to
424 show disassembly.
425
426--xed::
427 Run xed disassembler on output. Requires installing the xed disassembler.
428
628d736d
IR
429-S::
430--symbols=symbol[,symbol...]::
431 Only consider the listed symbols. Symbols are typically a name
432 but they may also be hexadecimal address.
433
61d9fc44
JY
434 The hexadecimal address may be the start address of a symbol or
435 any other address to filter the trace records
436
628d736d
IR
437 For example, to select the symbol noploop or the address 0x4007a0:
438 perf script --symbols=noploop,0x4007a0
439
61d9fc44
JY
440 Support filtering trace records by symbol name, start address of
441 symbol, any hexadecimal address and address range.
442
443 The comparison order is:
444
445 1. symbol name comparison
446 2. symbol start address comparison.
447 3. any hexadecimal address comparison.
448 4. address range comparison (see --addr-range).
449
450--addr-range::
451 Use with -S or --symbols to list traced records within address range.
452
453 For example, to list the traced records within the address range
454 [0x4007a0, 0x0x4007a9]:
455 perf script -S 0x4007a0 --addr-range 10
456
4b799a9b
JY
457--dsos=::
458 Only consider symbols in these DSOs.
459
d1b1552e
AK
460--call-trace::
461 Show call stream for intel_pt traces. The CPUs are interleaved, but
462 can be filtered with -C.
463
464--call-ret-trace::
465 Show call and return stream for intel_pt traces.
466
99f753f0
AK
467--graph-function::
468 For itrace only show specified functions and their callees for
469 itrace. Multiple functions can be separated by comma.
470
f90a2417
ACM
471--switch-on EVENT_NAME::
472 Only consider events after this event is found.
473
dd41f660
ACM
474--switch-off EVENT_NAME::
475 Stop considering events after this event is found.
476
6469eb6d 477--show-on-off-events::
dd41f660 478 Show the --switch-on/off events too.
6469eb6d 479
680d125c
KL
480--stitch-lbr::
481 Show callgraph with stitched LBRs, which may have more complete
482 callgraph. The perf.data file must have been obtained using
483 perf record --call-graph lbr.
484 Disabled by default. In common cases with call stack overflows,
485 it can recreate better call stacks than the default lbr call stack
486 output. But this approach is not full proof. There can be cases
487 where it creates incorrect call stacks from incorrect matches.
488 The known limitations include exception handing such as
489 setjmp/longjmp will have calls/returns not match.
490
0a02ad93
IM
491SEE ALSO
492--------
133dc4c3 493linkperf:perf-record[1], linkperf:perf-script-perl[1],
291961fc
AH
494linkperf:perf-script-python[1], linkperf:perf-intel-pt[1],
495linkperf:perf-dlfilter[1]