diff options
| author | Namhyung Kim <namhyung@kernel.org> | 2025-12-02 15:57:17 -0800 |
|---|---|---|
| committer | Namhyung Kim <namhyung@kernel.org> | 2025-12-02 21:59:14 -0800 |
| commit | 4fba95fc383f9231ba486512ee1c9d60b8f4a9a4 (patch) | |
| tree | ac2d94e9d2cf0a77cc3e25c51d61858f490efe44 /tools/perf | |
| parent | 295d8a03ca04858d956efdaf4ac2a3be3fc05108 (diff) | |
perf tools: Use machine->root_dir to find /proc/kallsyms
This is for test functions to find the kallsyms correctly. It can find
the machine from the kernel maps and use its root_dir. This is helpful
to setup fake /proc directory for testing.
Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Diffstat (limited to 'tools/perf')
| -rw-r--r-- | tools/perf/util/symbol.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index b533fbf17a8b..6ddbf4427c60 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -2002,6 +2002,7 @@ static char *dso__find_kallsyms(struct dso *dso, struct map *map) char sbuild_id[SBUILD_ID_SIZE]; bool is_host = false; char path[PATH_MAX]; + struct maps *kmaps = map__kmaps(map); if (!dso__has_build_id(dso)) { /* @@ -2038,8 +2039,13 @@ static char *dso__find_kallsyms(struct dso *dso, struct map *map) return strdup(path); /* Use current /proc/kallsyms if possible */ - if (is_host) { proc_kallsyms: + if (kmaps) { + struct machine *machine = maps__machine(kmaps); + + scnprintf(path, sizeof(path), "%s/proc/kallsyms", machine->root_dir); + return strdup(path); + } else if (is_host) { return strdup("/proc/kallsyms"); } |
