linux-stable/tools/perf
Adrian Hunter 4bf6e11c34 perf auxtrace: Fix address filter duplicate symbol selection
commit cf129830ee upstream.

When a match has been made to the nth duplicate symbol, return
success not error.

Example:

  Before:

    $ cat file.c
    cat: file.c: No such file or directory
    $ cat file1.c
    #include <stdio.h>

    static void func(void)
    {
            printf("First func\n");
    }

    void other(void);

    int main()
    {
            func();
            other();
            return 0;
    }
    $ cat file2.c
    #include <stdio.h>

    static void func(void)
    {
            printf("Second func\n");
    }

    void other(void)
    {
            func();
    }

    $ gcc -Wall -Wextra -o test file1.c file2.c
    $ perf record -e intel_pt//u --filter 'filter func @ ./test' -- ./test
    Multiple symbols with name 'func'
    #1      0x1149  l       func
                    which is near           main
    #2      0x1179  l       func
                    which is near           other
    Disambiguate symbol name by inserting #n after the name e.g. func #2
    Or select a global symbol by inserting #0 or #g or #G
    Failed to parse address filter: 'filter func @ ./test'
    Filter format is: filter|start|stop|tracestop <start symbol or address> [/ <end symbol or size>] [@<file name>]
    Where multiple filters are separated by space or comma.
    $ perf record -e intel_pt//u --filter 'filter func #2 @ ./test' -- ./test
    Failed to parse address filter: 'filter func #2 @ ./test'
    Filter format is: filter|start|stop|tracestop <start symbol or address> [/ <end symbol or size>] [@<file name>]
    Where multiple filters are separated by space or comma.

  After:

    $ perf record -e intel_pt//u --filter 'filter func #2 @ ./test' -- ./test
    First func
    Second func
    [ perf record: Woken up 1 times to write data ]
    [ perf record: Captured and wrote 0.016 MB perf.data ]
    $ perf script --itrace=b -Ftime,flags,ip,sym,addr --ns
    1231062.526977619:   tr strt                               0 [unknown] =>     558495708179 func
    1231062.526977619:   tr end  call               558495708188 func =>     558495708050 _init
    1231062.526979286:   tr strt                               0 [unknown] =>     55849570818d func
    1231062.526979286:   tr end  return             55849570818f func =>     55849570819d other

Fixes: 1b36c03e35 ("perf record: Add support for using symbols in address filters")
Reported-by: Dmitrii Dolgov <9erthalion6@gmail.com>
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Tested-by: Dmitry Dolgov <9erthalion6@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20230110185659.15979-1-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-01-18 11:42:01 +01:00
..
arch
bench parisc: Align parisc MADV_XXX constants with all other architectures 2023-01-18 11:42:00 +01:00
Documentation
examples/bpf
include/bpf
jvmti
lib
pmu-events perf jevents: Fix event syntax error caused by ExtSel 2022-06-14 18:11:44 +02:00
python tweewide: Fix most Shebang lines 2021-05-22 11:38:30 +02:00
scripts perf scripts python: exported-sql-viewer.py: Fix warning display 2021-06-03 08:59:00 +02:00
tests perf tests: Remove bash construct from record+zstd_comp_decomp.sh 2021-11-26 10:47:18 +01:00
trace perf trace: Add the syscall_arg_fmt pointer to syscall_arg 2023-01-18 11:41:28 +01:00
ui perf hist: Fix memory leak of a perf_hpp_fmt 2021-12-08 09:01:10 +01:00
util perf auxtrace: Fix address filter duplicate symbol selection 2023-01-18 11:42:01 +01:00
.gitignore
Build
builtin-annotate.c
builtin-bench.c
builtin-buildid-cache.c
builtin-buildid-list.c
builtin-c2c.c perf c2c: Fix sorting in percent_rmt_hitm_cmp() 2022-06-14 18:11:56 +02:00
builtin-config.c
builtin-data.c
builtin-diff.c
builtin-evlist.c
builtin-ftrace.c perf ftrace: Fix access to pid in array when setting a pid filter 2021-05-07 10:51:37 +02:00
builtin-help.c
builtin-inject.c perf inject: Close inject.output on exit 2021-07-28 13:31:02 +02:00
builtin-kallsyms.c
builtin-kmem.c
builtin-kvm.c
builtin-list.c
builtin-lock.c perf lock: Don't free "lock_seq_stat" if read_count isn't zero 2020-11-24 13:29:05 +01:00
builtin-mem.c
builtin-probe.c
builtin-record.c
builtin-report.c perf report: Fix memory leaks around perf_tip() 2021-12-08 09:01:10 +01:00
builtin-sched.c
builtin-script.c perf script: Fix CPU filtering of a script's switch events 2022-01-05 12:37:46 +01:00
builtin-stat.c
builtin-timechart.c
builtin-top.c
builtin-trace.c perf trace: Handle failure when trace point folder is missed 2023-01-18 11:41:28 +01:00
builtin-version.c
builtin.h
check-headers.sh x86: xen: insn: Decode Xen and KVM emulate-prefix signature 2022-05-15 19:54:47 +02:00
command-list.txt
CREDITS
design.txt
Makefile
Makefile.config tools build: Filter out options and warnings not supported by clang 2022-04-15 14:18:40 +02:00
Makefile.perf tools: Factor HOSTCC, HOSTLD, HOSTAR definitions 2021-01-30 13:54:10 +01:00
MANIFEST
perf-archive.sh
perf-completion.sh
perf-read-vdso.c
perf-sys.h
perf-with-kcore.sh
perf.c perf tools: Fix perf's libperf_print callback 2022-04-15 14:18:38 +02:00
perf.h