Skip to contentSkip to conversation

perf auxtrace: Fix address filter symbol name match for modules

PATCH Applied Adrian Hunter 2 participants 2 messages Oct 26, 2022 perf events

lore
Share & tools
lore

Adrian Hunter

author reviewer
#0 lore raw

PATCH 1/1 perf auxtrace: Fix address filter symbol name match for modules

For modules, names from kallsyms__parse() contain the module name which meant that module symbols did not match exactly by name.

Fix by matching the name string up to the separating tab character.

Fixes 1b36c03e3569 ("perf record: Add support for using symbols in address filters")
---
 tools/perf/util/auxtrace.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
tools/perf/util/auxtrace.c +9 -1
index b59c278fe9ed..c50eb2bfc518 100644
@@ -2321,11 +2321,19 @@ struct sym_args {
 	bool		near;
 };
 
+static bool kern_sym_name_match(const char *kname, const char *name)
+{
+	size_t n = strlen(name);
+
+	return !strcmp(kname, name) ||
+	       (!strncmp(kname, name, n) && kname[n] == '\t');
+}
+
 static bool kern_sym_match(struct sym_args *args, const char *name, char type)
 {
 	/* A function with the same name, and global or the n'th found or any */
 	return kallsyms__is_function(type) &&
-	       !strcmp(name, args->name) &&
+	       kern_sym_name_match(name, args->name) &&
 	       ((args->global && isupper(type)) ||
 		(args->selected && ++(args->cnt) == args->idx) ||
 		(!args->global && !args->selected));
Signature · 1 line
2.34.1
maintainer Applied
#1 lore raw

Em Wed, Oct 26, 2022 at 10:27:36AM +0300, Adrian Hunter escreveu:

Quoted 4 lines

For modules, names from kallsyms__parse() contain the module name which meant that module symbols did not match exactly by name.

Fix by matching the name string up to the separating tab character.

Thanks, applied.

- Arnaldo

Quoted 34 lines
Fixes 1b36c03e3569 ("perf record: Add support for using symbols in address filters")
---
 tools/perf/util/auxtrace.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
tools/perf/util/auxtrace.c +9 -1
index b59c278fe9ed..c50eb2bfc518 100644
@@ -2321,11 +2321,19 @@ struct sym_args {
 	bool		near;
 };
 
+static bool kern_sym_name_match(const char *kname, const char *name)
+{
+	size_t n = strlen(name);
+
+	return !strcmp(kname, name) ||
+	       (!strncmp(kname, name, n) && kname[n] == '\t');
+}
+
 static bool kern_sym_match(struct sym_args *args, const char *name, char type)
 {
 	/* A function with the same name, and global or the n'th found or any */
 	return kallsyms__is_function(type) &&
-	       !strcmp(name, args->name) &&
+	       kern_sym_name_match(name, args->name) &&
 	       ((args->global && isupper(type)) ||
 		(args->selected && ++(args->cnt) == args->idx) ||
 		(!args->global && !args->selected));
Signature · 1 line
2.34.1
Signature · 1 line
- Arnaldo