Skip to content

Commit eebc509

Browse files
mhiramatacmel
authored andcommitted
perf probe: Fix --funcs to show correct symbols for offline module
Fix --funcs (-F) option to show correct symbols for offline module. Since previous perf-probe uses machine__findnew_module_map() for offline module, even if user passes a module file (with full path) which is for other architecture, perf-probe always tries to load symbol map for current kernel module. This fix uses dso__new_map() to load the map from given binary as same as a map for user applications. Signed-off-by: Masami Hiramatsu <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/148350053478.19001.15435255244512631545.stgit@devbox Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 7934c98 commit eebc509

File tree

1 file changed

+6
-19
lines changed

1 file changed

+6
-19
lines changed

tools/perf/util/probe-event.c

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ static struct map *kernel_get_module_map(const char *module)
163163

164164
/* A file path -- this is an offline module */
165165
if (module && strchr(module, '/'))
166-
return machine__findnew_module_map(host_machine, 0, module);
166+
return dso__new_map(module);
167167

168168
if (!module)
169169
module = "kernel";
@@ -173,6 +173,7 @@ static struct map *kernel_get_module_map(const char *module)
173173
if (strncmp(pos->dso->short_name + 1, module,
174174
pos->dso->short_name_len - 2) == 0 &&
175175
module[pos->dso->short_name_len - 2] == '\0') {
176+
map__get(pos);
176177
return pos;
177178
}
178179
}
@@ -188,15 +189,6 @@ struct map *get_target_map(const char *target, bool user)
188189
return kernel_get_module_map(target);
189190
}
190191

191-
static void put_target_map(struct map *map, bool user)
192-
{
193-
if (map && user) {
194-
/* Only the user map needs to be released */
195-
map__put(map);
196-
}
197-
}
198-
199-
200192
static int convert_exec_to_group(const char *exec, char **result)
201193
{
202194
char *ptr1, *ptr2, *exec_copy;
@@ -412,7 +404,7 @@ static int find_alternative_probe_point(struct debuginfo *dinfo,
412404
}
413405

414406
out:
415-
put_target_map(map, uprobes);
407+
map__put(map);
416408
return ret;
417409

418410
}
@@ -2869,7 +2861,7 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev,
28692861
}
28702862

28712863
out:
2872-
put_target_map(map, pev->uprobes);
2864+
map__put(map);
28732865
free(syms);
28742866
return ret;
28752867

@@ -3362,10 +3354,7 @@ int show_available_funcs(const char *target, struct strfilter *_filter,
33623354
return ret;
33633355

33643356
/* Get a symbol map */
3365-
if (user)
3366-
map = dso__new_map(target);
3367-
else
3368-
map = kernel_get_module_map(target);
3357+
map = get_target_map(target, user);
33693358
if (!map) {
33703359
pr_err("Failed to get a map for %s\n", (target) ? : "kernel");
33713360
return -EINVAL;
@@ -3397,9 +3386,7 @@ int show_available_funcs(const char *target, struct strfilter *_filter,
33973386
}
33983387

33993388
end:
3400-
if (user) {
3401-
map__put(map);
3402-
}
3389+
map__put(map);
34033390
exit_probe_symbol_maps();
34043391

34053392
return ret;

0 commit comments

Comments
 (0)