Skip to content

Commit 1b36c03

Browse files
ahunter6acmel
authored andcommitted
perf record: Add support for using symbols in address filters
Symbols come from either the DSO or /proc/kallsyms for the kernel. Details of the functionality can be found in Documentation/perf-record.txt. Signed-off-by: Adrian Hunter <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Masami Hiramatsu <[email protected]> Cc: Mathieu Poirier <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent cd67f99 commit 1b36c03

File tree

4 files changed

+857
-3
lines changed

4 files changed

+857
-3
lines changed

tools/perf/Documentation/perf-record.txt

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,62 @@ OPTIONS
8989

9090
--filter=<filter>::
9191
Event filter. This option should follow a event selector (-e) which
92-
selects tracepoint event(s). Multiple '--filter' options are combined
92+
selects either tracepoint event(s) or a hardware trace PMU
93+
(e.g. Intel PT or CoreSight).
94+
95+
- tracepoint filters
96+
97+
In the case of tracepoints, multiple '--filter' options are combined
9398
using '&&'.
9499

100+
- address filters
101+
102+
A hardware trace PMU advertises its ability to accept a number of
103+
address filters by specifying a non-zero value in
104+
/sys/bus/event_source/devices/<pmu>/nr_addr_filters.
105+
106+
Address filters have the format:
107+
108+
filter|start|stop|tracestop <start> [/ <size>] [@<file name>]
109+
110+
Where:
111+
- 'filter': defines a region that will be traced.
112+
- 'start': defines an address at which tracing will begin.
113+
- 'stop': defines an address at which tracing will stop.
114+
- 'tracestop': defines a region in which tracing will stop.
115+
116+
<file name> is the name of the object file, <start> is the offset to the
117+
code to trace in that file, and <size> is the size of the region to
118+
trace. 'start' and 'stop' filters need not specify a <size>.
119+
120+
If no object file is specified then the kernel is assumed, in which case
121+
the start address must be a current kernel memory address.
122+
123+
<start> can also be specified by providing the name of a symbol. If the
124+
symbol name is not unique, it can be disambiguated by inserting #n where
125+
'n' selects the n'th symbol in address order. Alternately #0, #g or #G
126+
select only a global symbol. <size> can also be specified by providing
127+
the name of a symbol, in which case the size is calculated to the end
128+
of that symbol. For 'filter' and 'tracestop' filters, if <size> is
129+
omitted and <start> is a symbol, then the size is calculated to the end
130+
of that symbol.
131+
132+
If <size> is omitted and <start> is '*', then the start and size will
133+
be calculated from the first and last symbols, i.e. to trace the whole
134+
file.
135+
136+
If symbol names (or '*') are provided, they must be surrounded by white
137+
space.
138+
139+
The filter passed to the kernel is not necessarily the same as entered.
140+
To see the filter that is passed, use the -v option.
141+
142+
The kernel may not be able to configure a trace region if it is not
143+
within a single mapping. MMAP events (or /proc/<pid>/maps) can be
144+
examined to determine if that is a possibility.
145+
146+
Multiple filters can be separated with space or comma.
147+
95148
--exclude-perf::
96149
Don't record events issued by perf itself. This option should follow
97150
a event selector (-e) which selects tracepoint event(s). It adds a

tools/perf/builtin-record.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,6 +1581,18 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused)
15811581
if (err)
15821582
goto out;
15831583

1584+
/*
1585+
* Allow aliases to facilitate the lookup of symbols for address
1586+
* filters. Refer to auxtrace_parse_filters().
1587+
*/
1588+
symbol_conf.allow_aliases = true;
1589+
1590+
symbol__init(NULL);
1591+
1592+
err = auxtrace_parse_filters(rec->evlist);
1593+
if (err)
1594+
goto out;
1595+
15841596
if (dry_run)
15851597
goto out;
15861598

@@ -1594,8 +1606,6 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused)
15941606

15951607
err = -ENOMEM;
15961608

1597-
symbol__init(NULL);
1598-
15991609
if (symbol_conf.kptr_restrict)
16001610
pr_warning(
16011611
"WARNING: Kernel address maps (/proc/{kallsyms,modules}) are restricted,\n"

0 commit comments

Comments
 (0)