'\" t .\" Title: perf-probe .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 1.5.7.1 .\" Date: 2018-11-27 .\" Manual: perf Manual .\" Source: perf .\" Language: English .\" .TH "PERF_4.19\-PROBE" "1" "2018-11-27" "perf" "perf Manual" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 .nh .ad l .de URL \fI\\$2\fP <\\$1>\\$3 .. .als MTO URL .if \n[.g] \{\ . mso www.tmac . am URL . ad l . . . am MTO . ad l . . . LINKSTYLE blue R < > .\} .SH "NAME" perf\-probe \- Define new dynamic tracepoints .SH "SYNOPSIS" .sp .nf \fIperf probe\fP [options] \-\-add=\fIPROBE\fP [...] or \fIperf probe\fP [options] PROBE or \fIperf probe\fP [options] \-\-del=\fI[GROUP:]EVENT\fP [...] or \fIperf probe\fP \-\-list[=[GROUP:]EVENT] or \fIperf probe\fP [options] \-\-line=\fILINE\fP or \fIperf probe\fP [options] \-\-vars=\fIPROBEPOINT\fP or \fIperf probe\fP [options] \-\-funcs or \fIperf probe\fP [options] \-\-definition=\fIPROBE\fP [...] .fi .br .SH "DESCRIPTION" .sp This command defines dynamic tracepoint events, by symbol and registers without debuginfo, or by C expressions (C line numbers, C function names, and C local variables) with debuginfo. .SH "OPTIONS" .sp \-k, \-\-vmlinux=PATH .RS 4 Specify vmlinux path which has debuginfo (Dwarf binary). Only when using this with \-\-definition, you can give an offline vmlinux file. .RE .sp \-m, \-\-module=MODNAME|PATH .RS 4 Specify module name in which perf\-probe searches probe points or lines. If a path of module file is passed, perf\-probe treat it as an offline module (this means you can add a probe on a module which has not been loaded yet). .RE .sp \-s, \-\-source=PATH .RS 4 Specify path to kernel source. .RE .sp \-v, \-\-verbose .RS 4 Be more verbose (show parsed arguments, etc). Can not use with \-q. .RE .sp \-q, \-\-quiet .RS 4 Be quiet (do not show any messages including errors). Can not use with \-v. .RE .sp \-a, \-\-add= .RS 4 Define a probe event (see PROBE SYNTAX for detail). .RE .sp \-d, \-\-del= .RS 4 Delete probe events. This accepts glob wildcards(\fI*\fP, \fI?\fP) and character classes(e.g. [a\-z], [!A\-Z]). .RE .sp \-l, \-\-list[=[GROUP:]EVENT] .RS 4 List up current probe events. This can also accept filtering patterns of event names. When this is used with \-\-cache, perf shows all cached probes instead of the live probes. .RE .sp \-L, \-\-line= .RS 4 Show source code lines which can be probed. This needs an argument which specifies a range of the source code. (see LINE SYNTAX for detail) .RE .sp \-V, \-\-vars= .RS 4 Show available local variables at given probe point. The argument syntax is same as PROBE SYNTAX, but NO ARGs. .RE .sp \-\-externs .RS 4 (Only for \-\-vars) Show external defined variables in addition to local variables. .RE .sp \-\-no\-inlines .RS 4 (Only for \-\-add) Search only for non\-inlined functions. The functions which do not have instances are ignored. .RE .sp \-F, \-\-funcs[=FILTER] .RS 4 Show available functions in given module or kernel. With \-x/\-\-exec, can also list functions in a user space executable / shared library. This also can accept a FILTER rule argument. .RE .sp \-D, \-\-definition= .RS 4 Show trace\-event definition converted from given probe\-event instead of write it into tracing/[k,u]probe_events. .RE .sp \-\-filter=FILTER .RS 4 (Only for \-\-vars and \-\-funcs) Set filter. FILTER is a combination of glob pattern, see FILTER PATTERN for detail. Default FILTER is "!\fIk???tab_* & !\fPcrc_*" for \-\-vars, and "!_*" for \-\-funcs. If several filters are specified, only the last filter is used. .RE .sp \-f, \-\-force .RS 4 Forcibly add events with existing name. .RE .sp \-n, \-\-dry\-run .RS 4 Dry run. With this option, \-\-add and \-\-del doesn\(cqt execute actual adding and removal operations. .RE .sp \-\-cache .RS 4 (With \-\-add) Cache the probes. Any events which successfully added are also stored in the cache file. (With \-\-list) Show cached probes. (With \-\-del) Remove cached probes. .RE .sp \-\-max\-probes=NUM .RS 4 Set the maximum number of probe points for an event. Default is 128. .RE .sp \-\-target\-ns=PID: Obtain mount namespace information from the target pid. This is used when creating a uprobe for a process that resides in a different mount namespace from the perf(1) utility. .sp \-x, \-\-exec=PATH .RS 4 Specify path to the executable or shared library file for user space tracing. Can also be used with \-\-funcs option. .RE .sp \-\-demangle .RS 4 Demangle application symbols. \-\-no\-demangle is also available for disabling demangling. .RE .sp \-\-demangle\-kernel .RS 4 Demangle kernel symbols. \-\-no\-demangle\-kernel is also available for disabling kernel demangling. .RE .sp In absence of \-m/\-x options, perf probe checks if the first argument after the options is an absolute path name. If its an absolute path, perf probe uses it as a target module/target user space binary to probe. .SH "PROBE SYNTAX" .sp Probe points are defined by following syntax. .sp .if n .RS 4 .nf 1) Define event based on function name [[GROUP:]EVENT=]FUNC[@SRC][:RLN|+OFFS|%return|;PTN] [ARG ...] .fi .if n .RE .sp .if n .RS 4 .nf 2) Define event based on source file with line number [[GROUP:]EVENT=]SRC:ALN [ARG ...] .fi .if n .RE .sp .if n .RS 4 .nf 3) Define event based on source file with lazy pattern [[GROUP:]EVENT=]SRC;PTN [ARG ...] .fi .if n .RE .sp .if n .RS 4 .nf 4) Pre\-defined SDT events or cached event with name %[sdt_PROVIDER:]SDTEVENT or, sdt_PROVIDER:SDTEVENT .fi .if n .RE .sp \fIEVENT\fP specifies the name of new event, if omitted, it will be set the name of the probed function, and for return probes, a "_\(rs_return" suffix is automatically added to the function name. You can also specify a group name by \fIGROUP\fP, if omitted, set \fIprobe\fP is used for kprobe and \fIprobe_\fP is used for uprobe. Note that using existing group name can conflict with other events. Especially, using the group name reserved for kernel modules can hide embedded events in the modules. \fIFUNC\fP specifies a probed function name, and it may have one of the following options; \fI+OFFS\fP is the offset from function entry address in bytes, \fI:RLN\fP is the relative\-line number from function entry line, and \fI%return\fP means that it probes function return. And \fI;PTN\fP means lazy matching pattern (see LAZY MATCHING). Note that \fI;PTN\fP must be the end of the probe point definition. In addition, \fI@SRC\fP specifies a source file which has that function. It is also possible to specify a probe point by the source line number or lazy matching by using \fISRC:ALN\fP or \fISRC;PTN\fP syntax, where \fISRC\fP is the source file path, \fI:ALN\fP is the line number and \fI;PTN\fP is the lazy matching pattern. \fIARG\fP specifies the arguments of this probe point, (see PROBE ARGUMENT). \fISDTEVENT\fP and \fIPROVIDER\fP is the pre\-defined event name which is defined by user SDT (Statically Defined Tracing) or the pre\-cached probes with event name. Note that before using the SDT event, the target binary (on which SDT events are defined) must be scanned by perf\-buildid\-cache(1) to make SDT events as cached events. .sp For details of the SDT, see below. .URL "https://sourceware.org/gdb/onlinedocs/gdb/Static\-Probe\-Points.html" "" "" .SH "ESCAPED CHARACTER" .sp In the probe syntax, \fI=\fP, \fI@\fP, \fI+\fP, \fI:\fP and \fI;\fP are treated as a special character. You can use a backslash (\fI\(rs\fP) to escape the special characters. This is useful if you need to probe on a specific versioned symbols, like @GLIBC_... suffixes, or also you need to specify a source file which includes the special characters. Note that usually single backslash is consumed by shell, so you might need to pass double backslash (\(rs\) or wrapping with single quotes (\(aqAAA\(rs@BBB\(aq). See EXAMPLES how it is used. .SH "PROBE ARGUMENT" .sp Each probe argument follows below syntax. .sp .if n .RS 4 .nf [NAME=]LOCALVAR|$retval|%REG|@SYMBOL[:TYPE] .fi .if n .RE .sp \fINAME\fP specifies the name of this argument (optional). You can use the name of local variable, local data structure member (e.g. var\(->field, var.field2), local array with fixed index (e.g. array[1], var\(->array[0], var\(->pointer[2]), or kprobe\-tracer argument format (e.g. $retval, %ax, etc). Note that the name of this argument will be set as the last member name if you specify a local data structure member (e.g. field2 for \fIvar\(->field1.field2\fP.) \fI$vars\fP and \fI$params\fP special arguments are also available for NAME, \fI$vars\fP is expanded to the local variables (including function parameters) which can access at given probe point. \fI$params\fP is expanded to only the function parameters. \fITYPE\fP casts the type of this argument (optional). If omitted, perf probe automatically set the type based on debuginfo (*). Currently, basic types (u8/u16/u32/u64/s8/s16/s32/s64), hexadecimal integers (x/x8/x16/x32/x64), signedness casting (u/s), "string" and bitfield are supported. (see TYPES for detail) On x86 systems %REG is always the short form of the register: for example %AX. %RAX or %EAX is not valid. .SH "TYPES" .sp Basic types (u8/u16/u32/u64/s8/s16/s32/s64) and hexadecimal integers (x8/x16/x32/x64) are integer types. Prefix \fIs\fP and \fIu\fP means those types are signed and unsigned respectively, and \fIx\fP means that is shown in hexadecimal format. Traced arguments are shown in decimal (sNN/uNN) or hex (xNN). You can also use \fIs\fP or \fIu\fP to specify only signedness and leave its size auto\-detected by perf probe. Moreover, you can use \fIx\fP to explicitly specify to be shown in hexadecimal (the size is also auto\-detected). String type is a special type, which fetches a "null\-terminated" string from kernel space. This means it will fail and store NULL if the string container has been paged out. You can specify \fIstring\fP type only for the local variable or structure member which is an array of or a pointer to \fIchar\fP or \fIunsigned char\fP type. Bitfield is another special type, which takes 3 parameters, bit\-width, bit\-offset, and container\-size (usually 32). The syntax is; .sp .if n .RS 4 .nf b@/ .fi .if n .RE .SH "LINE SYNTAX" .sp Line range is described by following syntax. .sp .if n .RS 4 .nf "FUNC[@SRC][:RLN[+NUM|\-RLN2]]|SRC[:ALN[+NUM|\-ALN2]]" .fi .if n .RE .sp FUNC specifies the function name of showing lines. \fIRLN\fP is the start line number from function entry line, and \fIRLN2\fP is the end line number. As same as probe syntax, \fISRC\fP means the source file path, \fIALN\fP is start line number, and \fIALN2\fP is end line number in the file. It is also possible to specify how many lines to show by using \fINUM\fP. Moreover, \fIFUNC@SRC\fP combination is good for searching a specific function when several functions share same name. So, "source.c:100\-120" shows lines between 100th to l20th in source.c file. And "func:10+20" shows 20 lines from 10th line of func function. .SH "LAZY MATCHING" .sp .if n .RS 4 .nf The lazy line matching is similar to glob matching but ignoring spaces in both of pattern and target. So this accepts wildcards(\(aq*\(aq, \(aq?\(aq) and character classes(e.g. [a\-z], [!A\-Z]). .fi .if n .RE .sp e.g. \fIa=*\fP can matches \fIa=b\fP, \fIa = b\fP, \fIa == b\fP and so on. .sp This provides some sort of flexibility and robustness to probe point definitions against minor code changes. For example, actual 10th line of schedule() can be moved easily by modifying schedule(), but the same line matching \fIrq=cpu_rq*\fP may still exist in the function.) .SH "FILTER PATTERN" .sp .if n .RS 4 .nf The filter pattern is a glob matching pattern(s) to filter variables. 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 "(" ")". .fi .if n .RE .sp e.g. With \-\-filter "foo* | bar*", perf probe \-V shows variables which start with "foo" or "bar". With \-\-filter "!foo* & *bar", perf probe \-V shows variables which don\(cqt start with "foo" and end with "bar", like "fizzbar". But "foobar" is filtered out. .SH "EXAMPLES" .sp Display which lines in schedule() can be probed: .sp .if n .RS 4 .nf \&./perf probe \-\-line schedule .fi .if n .RE .sp Add a probe on schedule() function 12th line with recording cpu local variable: .sp .if n .RS 4 .nf \&./perf probe schedule:12 cpu or \&./perf probe \-\-add=\(aqschedule:12 cpu\(aq .fi .if n .RE .sp Add one or more probes which has the name start with "schedule". .sp .if n .RS 4 .nf \&./perf probe schedule* or \&./perf probe \-\-add=\(aqschedule*\(aq .fi .if n .RE .sp Add probes on lines in schedule() function which calls update_rq_clock(). .sp .if n .RS 4 .nf \&./perf probe \(aqschedule;update_rq_clock*\(aq or \&./perf probe \-\-add=\(aqschedule;update_rq_clock*\(aq .fi .if n .RE .sp Delete all probes on schedule(). .sp .if n .RS 4 .nf \&./perf probe \-\-del=\(aqschedule*\(aq .fi .if n .RE .sp Add probes at zfree() function on /bin/zsh .sp .if n .RS 4 .nf \&./perf probe \-x /bin/zsh zfree or ./perf probe /bin/zsh zfree .fi .if n .RE .sp Add probes at malloc() function on libc .sp .if n .RS 4 .nf \&./perf probe \-x /lib/libc.so.6 malloc or ./perf probe /lib/libc.so.6 malloc .fi .if n .RE .sp Add a uprobe to a target process running in a different mount namespace .sp .if n .RS 4 .nf \&./perf probe \-\-target\-ns \-x /lib64/libc.so.6 malloc .fi .if n .RE .sp Add a USDT probe to a target process running in a different mount namespace .sp .if n .RS 4 .nf \&./perf probe \-\-target\-ns \-x /usr/lib/jvm/java\-1.8.0\-openjdk\-1.8.0.121\-0.b13.el7_3.x86_64/jre/lib/amd64/server/libjvm.so %sdt_hotspot:thread__sleep__end .fi .if n .RE .sp Add a probe on specific versioned symbol by backslash escape .sp .if n .RS 4 .nf \&./perf probe \-x /lib64/libc\-2.25.so \(aqmalloc_get_state\(rs@GLIBC_2.2.5\(aq .fi .if n .RE .sp Add a probe in a source file using special characters by backslash escape .sp .if n .RS 4 .nf \&./perf probe \-x /opt/test/a.out \(aqfoo\(rs+bar.c:4\(aq .fi .if n .RE .SH "SEE ALSO" .sp perf\-trace(1), perf\-record(1), perf\-buildid\-cache(1)