diff options
author | Namhyung Kim <namhyung@kernel.org> | 2023-10-30 13:39:28 -0700 |
---|---|---|
committer | Namhyung Kim <namhyung@kernel.org> | 2023-10-30 13:46:27 -0700 |
commit | fed3a1be6433e15833068c701bfde7b422d8b988 (patch) | |
tree | b67a9c17a025004c73d75424808654a224e212e4 /tools/perf/util/dlfilter.c | |
parent | c43c64f8a1c68da370bf8d458ba52e24183a5264 (diff) | |
parent | 4fa008a2db484024a5cb52676a1b1534dc82330c (diff) |
Merge tag 'perf-tools-fixes-for-v6.6-2-2023-10-20' into perf-tools-next
To get the latest fixes in the perf tools including perf stat output,
dlfilter and LLVM feature detection.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Diffstat (limited to 'tools/perf/util/dlfilter.c')
-rw-r--r-- | tools/perf/util/dlfilter.c | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/tools/perf/util/dlfilter.c b/tools/perf/util/dlfilter.c index 5e54832137a9..908e16813722 100644 --- a/tools/perf/util/dlfilter.c +++ b/tools/perf/util/dlfilter.c @@ -284,13 +284,21 @@ static struct perf_event_attr *dlfilter__attr(void *ctx) return &d->evsel->core.attr; } +static __s32 code_read(__u64 ip, struct map *map, struct machine *machine, void *buf, __u32 len) +{ + u64 offset = map__map_ip(map, ip); + + if (ip + len >= map__end(map)) + len = map__end(map) - ip; + + return dso__data_read_offset(map__dso(map), machine, offset, buf, len); +} + static __s32 dlfilter__object_code(void *ctx, __u64 ip, void *buf, __u32 len) { struct dlfilter *d = (struct dlfilter *)ctx; struct addr_location *al; struct addr_location a; - struct map *map; - u64 offset; __s32 ret; if (!d->ctx_valid) @@ -300,27 +308,17 @@ static __s32 dlfilter__object_code(void *ctx, __u64 ip, void *buf, __u32 len) if (!al) return -1; - map = al->map; - - if (map && ip >= map__start(map) && ip < map__end(map) && + if (al->map && ip >= map__start(al->map) && ip < map__end(al->map) && machine__kernel_ip(d->machine, ip) == machine__kernel_ip(d->machine, d->sample->ip)) - goto have_map; + return code_read(ip, al->map, d->machine, buf, len); addr_location__init(&a); + thread__find_map_fb(al->thread, d->sample->cpumode, ip, &a); - if (!a.map) { - ret = -1; - goto out; - } + ret = a.map ? code_read(ip, a.map, d->machine, buf, len) : -1; - map = a.map; -have_map: - offset = map__map_ip(map, ip); - if (ip + len >= map__end(map)) - len = map__end(map) - ip; - ret = dso__data_read_offset(map__dso(map), d->machine, offset, buf, len); -out: addr_location__exit(&a); + return ret; } |