* [PATCH] perf auxtrace: Fix address filter duplicate symbol selection
@ 2023-01-10 18:56 Adrian Hunter
2023-01-11 13:16 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 2+ messages in thread
From: Adrian Hunter @ 2023-01-10 18:56 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Jiri Olsa, Namhyung Kim, Ian Rogers, Dmitry Dolgov, linux-kernel,
linux-perf-users
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
Reported-by: Dmitry Dolgov <9erthalion6@gmail.com>
Fixes: 1b36c03e3569 ("perf record: Add support for using symbols in address filters")
Cc: stable@vger.kernel.org
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
tools/perf/util/auxtrace.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
index 265d20cc126b..c2e323cd7d49 100644
--- a/tools/perf/util/auxtrace.c
+++ b/tools/perf/util/auxtrace.c
@@ -2611,7 +2611,7 @@ static int find_dso_sym(struct dso *dso, const char *sym_name, u64 *start,
*size = sym->start - *start;
if (idx > 0) {
if (*size)
- return 1;
+ return 0;
} else if (dso_sym_match(sym, sym_name, &cnt, idx)) {
print_duplicate_syms(dso, sym_name);
return -EINVAL;
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] perf auxtrace: Fix address filter duplicate symbol selection
2023-01-10 18:56 [PATCH] perf auxtrace: Fix address filter duplicate symbol selection Adrian Hunter
@ 2023-01-11 13:16 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 2+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-01-11 13:16 UTC (permalink / raw)
To: Adrian Hunter
Cc: Jiri Olsa, Namhyung Kim, Ian Rogers, Dmitry Dolgov, linux-kernel,
linux-perf-users
Em Tue, Jan 10, 2023 at 08:56:59PM +0200, Adrian Hunter escreveu:
> 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
>
> Reported-by: Dmitry Dolgov <9erthalion6@gmail.com>
> Fixes: 1b36c03e3569 ("perf record: Add support for using symbols in address filters")
> Cc: stable@vger.kernel.org
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Thanks, applied.
Dmitry, can I have your Tested-by? Checking the original thread...
- Arnaldo
> ---
> tools/perf/util/auxtrace.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
> index 265d20cc126b..c2e323cd7d49 100644
> --- a/tools/perf/util/auxtrace.c
> +++ b/tools/perf/util/auxtrace.c
> @@ -2611,7 +2611,7 @@ static int find_dso_sym(struct dso *dso, const char *sym_name, u64 *start,
> *size = sym->start - *start;
> if (idx > 0) {
> if (*size)
> - return 1;
> + return 0;
> } else if (dso_sym_match(sym, sym_name, &cnt, idx)) {
> print_duplicate_syms(dso, sym_name);
> return -EINVAL;
> --
> 2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-01-11 13:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-10 18:56 [PATCH] perf auxtrace: Fix address filter duplicate symbol selection Adrian Hunter
2023-01-11 13:16 ` Arnaldo Carvalho de Melo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).