perf thread: Make thread__find_map() search all maps

We still have the split internally, but users don't see it anymore,
simplifying the growing number of cases where we end up searching
in the MAP__VARIABLE maps.

This further paves the way for ditching the split.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-86mfxrztf310konutxvhr5ua@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 117d3c24
...@@ -927,8 +927,8 @@ static int ip__fprintf_sym(uint64_t addr, struct thread *thread, ...@@ -927,8 +927,8 @@ static int ip__fprintf_sym(uint64_t addr, struct thread *thread,
memset(&al, 0, sizeof(al)); memset(&al, 0, sizeof(al));
if (!thread__find_map(thread, cpumode, addr, &al)) thread__find_map(thread, cpumode, addr, &al);
__thread__find_map(thread, cpumode, MAP__VARIABLE, addr, &al);
if ((*lastsym) && al.addr >= (*lastsym)->start && al.addr < (*lastsym)->end) if ((*lastsym) && al.addr >= (*lastsym)->start && al.addr < (*lastsym)->end)
return 0; return 0;
......
...@@ -1488,8 +1488,8 @@ int perf_event__process(struct perf_tool *tool __maybe_unused, ...@@ -1488,8 +1488,8 @@ int perf_event__process(struct perf_tool *tool __maybe_unused,
return machine__process_event(machine, event, sample); return machine__process_event(machine, event, sample);
} }
struct map *__thread__find_map(struct thread *thread, u8 cpumode, enum map_type type, static struct map *__thread__find_map(struct thread *thread, u8 cpumode, enum map_type type,
u64 addr, struct addr_location *al) u64 addr, struct addr_location *al)
{ {
struct map_groups *mg = thread->mg; struct map_groups *mg = thread->mg;
struct machine *machine = mg->machine; struct machine *machine = mg->machine;
...@@ -1565,12 +1565,18 @@ struct map *__thread__find_map(struct thread *thread, u8 cpumode, enum map_type ...@@ -1565,12 +1565,18 @@ struct map *__thread__find_map(struct thread *thread, u8 cpumode, enum map_type
return al->map; return al->map;
} }
struct map *thread__find_map(struct thread *thread, u8 cpumode, u64 addr,
struct addr_location *al)
{
struct map *map = __thread__find_map(thread, cpumode, MAP__FUNCTION, addr, al);
return map ?: __thread__find_map(thread, cpumode, MAP__VARIABLE, addr, al);
}
struct symbol *thread__find_symbol(struct thread *thread, u8 cpumode, struct symbol *thread__find_symbol(struct thread *thread, u8 cpumode,
u64 addr, struct addr_location *al) u64 addr, struct addr_location *al)
{ {
al->sym = NULL; al->sym = NULL;
if (__thread__find_map(thread, cpumode, MAP__FUNCTION, addr, al) || if (thread__find_map(thread, cpumode, addr, al))
__thread__find_map(thread, cpumode, MAP__VARIABLE, addr, al))
al->sym = map__find_symbol(al->map, al->addr); al->sym = map__find_symbol(al->map, al->addr);
return al->sym; return al->sym;
} }
...@@ -1668,10 +1674,7 @@ bool sample_addr_correlates_sym(struct perf_event_attr *attr) ...@@ -1668,10 +1674,7 @@ bool sample_addr_correlates_sym(struct perf_event_attr *attr)
void thread__resolve(struct thread *thread, struct addr_location *al, void thread__resolve(struct thread *thread, struct addr_location *al,
struct perf_sample *sample) struct perf_sample *sample)
{ {
if (!thread__find_map(thread, sample->cpumode, sample->addr, al)) { thread__find_map(thread, sample->cpumode, sample->addr, al);
__thread__find_map(thread, sample->cpumode, MAP__VARIABLE,
sample->addr, al);
}
al->cpu = sample->cpu; al->cpu = sample->cpu;
al->sym = NULL; al->sym = NULL;
......
...@@ -92,14 +92,8 @@ size_t thread__fprintf(struct thread *thread, FILE *fp); ...@@ -92,14 +92,8 @@ size_t thread__fprintf(struct thread *thread, FILE *fp);
struct thread *thread__main_thread(struct machine *machine, struct thread *thread); struct thread *thread__main_thread(struct machine *machine, struct thread *thread);
struct map *__thread__find_map(struct thread *thread, u8 cpumode, enum map_type type, struct map *thread__find_map(struct thread *thread, u8 cpumode, u64 addr,
u64 addr, struct addr_location *al); struct addr_location *al);
static inline struct map *thread__find_map(struct thread *thread, u8 cpumode,
u64 addr, struct addr_location *al)
{
return __thread__find_map(thread, cpumode, MAP__FUNCTION, addr, al);
}
struct symbol *thread__find_symbol(struct thread *thread, u8 cpumode, struct symbol *thread__find_symbol(struct thread *thread, u8 cpumode,
u64 addr, struct addr_location *al); u64 addr, struct addr_location *al);
......
...@@ -105,16 +105,6 @@ static int access_dso_mem(struct unwind_info *ui, Dwarf_Addr addr, ...@@ -105,16 +105,6 @@ static int access_dso_mem(struct unwind_info *ui, Dwarf_Addr addr,
ssize_t size; ssize_t size;
if (!thread__find_map(ui->thread, PERF_RECORD_MISC_USER, addr, &al)) { if (!thread__find_map(ui->thread, PERF_RECORD_MISC_USER, addr, &al)) {
/*
* We've seen cases (softice) where DWARF unwinder went
* through non executable mmaps, which we need to lookup
* in MAP__VARIABLE tree.
*/
__thread__find_map(ui->thread, PERF_RECORD_MISC_USER,
MAP__VARIABLE, addr, &al);
}
if (!al.map) {
pr_debug("unwind: no map for %lx\n", (unsigned long)addr); pr_debug("unwind: no map for %lx\n", (unsigned long)addr);
return -1; return -1;
} }
......
...@@ -366,17 +366,7 @@ static int read_unwind_spec_debug_frame(struct dso *dso, ...@@ -366,17 +366,7 @@ static int read_unwind_spec_debug_frame(struct dso *dso,
static struct map *find_map(unw_word_t ip, struct unwind_info *ui) static struct map *find_map(unw_word_t ip, struct unwind_info *ui)
{ {
struct addr_location al; struct addr_location al;
return thread__find_map(ui->thread, PERF_RECORD_MISC_USER, ip, &al);
if (!thread__find_map(ui->thread, PERF_RECORD_MISC_USER, ip, &al)) {
/*
* We've seen cases (softice) where DWARF unwinder went
* through non executable mmaps, which we need to lookup
* in MAP__VARIABLE tree.
*/
__thread__find_map(ui->thread, PERF_RECORD_MISC_USER,
MAP__VARIABLE, ip, &al);
}
return al.map;
} }
static int static int
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment