From: Namhyung Kim <namhy...@kernel.org> Find correct thread/map/symbol using proper functions.
Cc: Frederic Weisbecker <fweis...@gmail.com> Link: http://lkml.kernel.org/n/tip-k02mlrexo1h3bsezgrr7y...@git.kernel.org Signed-off-by: Namhyung Kim <namhy...@kernel.org> Signed-off-by: Jiri Olsa <jo...@kernel.org> --- tools/perf/util/machine.c | 18 +++++++++++------- tools/perf/util/unwind-libdw.c | 6 ++++-- tools/perf/util/unwind-libunwind-local.c | 11 +++++++---- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 0c576a01697e..dc46a7967e10 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -2101,7 +2101,8 @@ static int add_callchain_ip(struct thread *thread, bool branch, struct branch_flags *flags, struct iterations *iter, - u64 branch_from) + u64 branch_from, + u64 timestamp) { struct addr_location al; int nr_loop_iter = 0; @@ -2111,7 +2112,8 @@ static int add_callchain_ip(struct thread *thread, al.filtered = 0; al.sym = NULL; if (!cpumode) { - thread__find_cpumode_addr_location(thread, ip, &al); + thread__find_cpumode_addr_location_by_time(thread, ip, + &al, timestamp); } else { if (ip >= PERF_CONTEXT_MAX) { switch (ip) { @@ -2136,7 +2138,8 @@ static int add_callchain_ip(struct thread *thread, } return 0; } - thread__find_symbol(thread, *cpumode, ip, &al); + thread__find_symbol_by_time(thread, *cpumode, ip, &al, + timestamp); } if (al.sym != NULL) { @@ -2333,7 +2336,7 @@ static int resolve_lbr_callchain_sample(struct thread *thread, err = add_callchain_ip(thread, cursor, parent, root_al, &cpumode, ip, branch, flags, NULL, - branch_from); + branch_from, sample->time); if (err) return (err < 0) ? err : 0; } @@ -2356,6 +2359,7 @@ static int thread__resolve_callchain_sample(struct thread *thread, int chain_nr = 0; u8 cpumode = PERF_RECORD_MISC_USER; int i, j, err, nr_entries; + u64 timestamp = sample->time; int skip_idx = -1; int first_call = 0; @@ -2429,13 +2433,13 @@ static int thread__resolve_callchain_sample(struct thread *thread, root_al, NULL, be[i].to, true, &be[i].flags, - NULL, be[i].from); + NULL, be[i].from, timestamp); if (!err) err = add_callchain_ip(thread, cursor, parent, root_al, NULL, be[i].from, true, &be[i].flags, - &iter[i], 0); + &iter[i], 0, timestamp); if (err == -EINVAL) break; if (err) @@ -2469,7 +2473,7 @@ static int thread__resolve_callchain_sample(struct thread *thread, err = add_callchain_ip(thread, cursor, parent, root_al, &cpumode, ip, - false, NULL, NULL, 0); + false, NULL, NULL, 0, timestamp); if (err) return (err < 0) ? err : 0; diff --git a/tools/perf/util/unwind-libdw.c b/tools/perf/util/unwind-libdw.c index 6f318b15950e..c22c1030a8ad 100644 --- a/tools/perf/util/unwind-libdw.c +++ b/tools/perf/util/unwind-libdw.c @@ -32,7 +32,8 @@ static int __report_module(struct addr_location *al, u64 ip, * Some callers will use al->sym, so we can't just use the * cheaper thread__find_map() here. */ - thread__find_symbol(ui->thread, PERF_RECORD_MISC_USER, ip, al); + thread__find_symbol_by_time(ui->thread, PERF_RECORD_MISC_USER, ip, + al, ui->sample->time); if (al->map) dso = al->map->dso; @@ -104,7 +105,8 @@ static int access_dso_mem(struct unwind_info *ui, Dwarf_Addr addr, struct addr_location al; ssize_t size; - if (!thread__find_map(ui->thread, PERF_RECORD_MISC_USER, addr, &al)) { + if (!thread__find_map_by_time(ui->thread, PERF_RECORD_MISC_USER, + addr, &al, ui->sample->time)) { pr_debug("unwind: no map for %lx\n", (unsigned long)addr); return -1; } diff --git a/tools/perf/util/unwind-libunwind-local.c b/tools/perf/util/unwind-libunwind-local.c index 79f521a552cf..da6f39315b47 100644 --- a/tools/perf/util/unwind-libunwind-local.c +++ b/tools/perf/util/unwind-libunwind-local.c @@ -366,7 +366,9 @@ static int read_unwind_spec_debug_frame(struct dso *dso, static struct map *find_map(unw_word_t ip, struct unwind_info *ui) { struct addr_location al; - return thread__find_map(ui->thread, PERF_RECORD_MISC_USER, ip, &al); + + return thread__find_map_by_time(ui->thread, PERF_RECORD_MISC_USER, ip, + &al, ui->sample->time); } static int @@ -568,13 +570,14 @@ static void put_unwind_info(unw_addr_space_t __maybe_unused as, pr_debug("unwind: put_unwind_info called\n"); } -static int entry(u64 ip, struct thread *thread, +static int entry(u64 ip, struct thread *thread, u64 timestamp, unwind_entry_cb_t cb, void *arg) { struct unwind_entry e; struct addr_location al; - e.sym = thread__find_symbol(thread, PERF_RECORD_MISC_USER, ip, &al); + e.sym = thread__find_symbol_by_time(thread, PERF_RECORD_MISC_USER, ip, + &al, timestamp); e.ip = ip; e.map = al.map; @@ -700,7 +703,7 @@ static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb, if (callchain_param.order == ORDER_CALLER) j = max_stack - i - 1; - ret = ips[j] ? entry(ips[j], ui->thread, cb, arg) : 0; + ret = ips[j] ? entry(ips[j], ui->thread, ui->sample->time, cb, arg) : 0; } return ret; -- 2.17.1