aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-inject.c4
-rw-r--r--tools/perf/builtin-script.c14
-rw-r--r--tools/perf/tests/code-reading.c3
-rw-r--r--tools/perf/util/build-id.c4
-rw-r--r--tools/perf/util/cs-etm.c4
-rw-r--r--tools/perf/util/event.c16
-rw-r--r--tools/perf/util/intel-bts.c3
-rw-r--r--tools/perf/util/intel-pt.c6
-rw-r--r--tools/perf/util/thread.h10
-rw-r--r--tools/perf/util/unwind-libdw.c3
-rw-r--r--tools/perf/util/unwind-libunwind-local.c3
11 files changed, 28 insertions, 42 deletions
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index 92677d8f9eae..a3b346359ba0 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -440,9 +440,7 @@ static int perf_event__inject_buildid(struct perf_tool *tool,
440 goto repipe; 440 goto repipe;
441 } 441 }
442 442
443 thread__find_map(thread, sample->cpumode, sample->ip, &al); 443 if (thread__find_map(thread, sample->cpumode, sample->ip, &al)) {
444
445 if (al.map != NULL) {
446 if (!al.map->dso->hit) { 444 if (!al.map->dso->hit) {
447 al.map->dso->hit = 1; 445 al.map->dso->hit = 1;
448 if (map__load(al.map) >= 0) { 446 if (map__load(al.map) >= 0) {
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index ffd02faee87b..07cb083ac89c 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -809,12 +809,12 @@ static int perf_sample__fprintf_brstackoff(struct perf_sample *sample,
809 from = br->entries[i].from; 809 from = br->entries[i].from;
810 to = br->entries[i].to; 810 to = br->entries[i].to;
811 811
812 thread__find_map(thread, sample->cpumode, from, &alf); 812 if (thread__find_map(thread, sample->cpumode, from, &alf) &&
813 if (alf.map && !alf.map->dso->adjust_symbols) 813 !alf.map->dso->adjust_symbols)
814 from = map__map_ip(alf.map, from); 814 from = map__map_ip(alf.map, from);
815 815
816 thread__find_map(thread, sample->cpumode, to, &alt); 816 if (thread__find_map(thread, sample->cpumode, to, &alt) &&
817 if (alt.map && !alt.map->dso->adjust_symbols) 817 !alt.map->dso->adjust_symbols)
818 to = map__map_ip(alt.map, to); 818 to = map__map_ip(alt.map, to);
819 819
820 printed += fprintf(fp, " 0x%"PRIx64, from); 820 printed += fprintf(fp, " 0x%"PRIx64, from);
@@ -877,8 +877,7 @@ static int grab_bb(u8 *buffer, u64 start, u64 end,
877 return 0; 877 return 0;
878 } 878 }
879 879
880 thread__find_map(thread, *cpumode, start, &al); 880 if (!thread__find_map(thread, *cpumode, start, &al) || !al.map->dso) {
881 if (!al.map || !al.map->dso) {
882 pr_debug("\tcannot resolve %" PRIx64 "-%" PRIx64 "\n", start, end); 881 pr_debug("\tcannot resolve %" PRIx64 "-%" PRIx64 "\n", start, end);
883 return 0; 882 return 0;
884 } 883 }
@@ -928,8 +927,7 @@ static int ip__fprintf_sym(uint64_t addr, struct thread *thread,
928 927
929 memset(&al, 0, sizeof(al)); 928 memset(&al, 0, sizeof(al));
930 929
931 thread__find_map(thread, cpumode, addr, &al); 930 if (!thread__find_map(thread, cpumode, addr, &al))
932 if (!al.map)
933 __thread__find_map(thread, cpumode, MAP__VARIABLE, addr, &al); 931 __thread__find_map(thread, cpumode, MAP__VARIABLE, addr, &al);
934 if ((*lastsym) && al.addr >= (*lastsym)->start && al.addr < (*lastsym)->end) 932 if ((*lastsym) && al.addr >= (*lastsym)->start && al.addr < (*lastsym)->end)
935 return 0; 933 return 0;
diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c
index 5b0a55499486..afa4ce21ba7c 100644
--- a/tools/perf/tests/code-reading.c
+++ b/tools/perf/tests/code-reading.c
@@ -236,8 +236,7 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode,
236 236
237 pr_debug("Reading object code for memory address: %#"PRIx64"\n", addr); 237 pr_debug("Reading object code for memory address: %#"PRIx64"\n", addr);
238 238
239 thread__find_map(thread, cpumode, addr, &al); 239 if (!thread__find_map(thread, cpumode, addr, &al) || !al.map->dso) {
240 if (!al.map || !al.map->dso) {
241 if (cpumode == PERF_RECORD_MISC_HYPERVISOR) { 240 if (cpumode == PERF_RECORD_MISC_HYPERVISOR) {
242 pr_debug("Hypervisor address can not be resolved - skipping\n"); 241 pr_debug("Hypervisor address can not be resolved - skipping\n");
243 return 0; 242 return 0;
diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
index b512dc8fa6c3..04b1d53e4bf9 100644
--- a/tools/perf/util/build-id.c
+++ b/tools/perf/util/build-id.c
@@ -47,9 +47,7 @@ int build_id__mark_dso_hit(struct perf_tool *tool __maybe_unused,
47 return -1; 47 return -1;
48 } 48 }
49 49
50 thread__find_map(thread, sample->cpumode, sample->ip, &al); 50 if (thread__find_map(thread, sample->cpumode, sample->ip, &al))
51
52 if (al.map != NULL)
53 al.map->dso->hit = 1; 51 al.map->dso->hit = 1;
54 52
55 thread__put(thread); 53 thread__put(thread);
diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
index 8fe573d040b6..6533b1adb50b 100644
--- a/tools/perf/util/cs-etm.c
+++ b/tools/perf/util/cs-etm.c
@@ -269,9 +269,7 @@ static u32 cs_etm__mem_access(struct cs_etm_queue *etmq, u64 address,
269 thread = etmq->etm->unknown_thread; 269 thread = etmq->etm->unknown_thread;
270 } 270 }
271 271
272 thread__find_map(thread, cpumode, address, &al); 272 if (!thread__find_map(thread, cpumode, address, &al) || !al.map->dso)
273
274 if (!al.map || !al.map->dso)
275 return 0; 273 return 0;
276 274
277 if (al.map->dso->data.status == DSO_DATA_STATUS_ERROR && 275 if (al.map->dso->data.status == DSO_DATA_STATUS_ERROR &&
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 2d860fbeb227..48e4b252f6ff 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -1489,8 +1489,8 @@ int perf_event__process(struct perf_tool *tool __maybe_unused,
1489 return machine__process_event(machine, event, sample); 1489 return machine__process_event(machine, event, sample);
1490} 1490}
1491 1491
1492void __thread__find_map(struct thread *thread, u8 cpumode, enum map_type type, 1492struct map *__thread__find_map(struct thread *thread, u8 cpumode, enum map_type type,
1493 u64 addr, struct addr_location *al) 1493 u64 addr, struct addr_location *al)
1494{ 1494{
1495 struct map_groups *mg = thread->mg; 1495 struct map_groups *mg = thread->mg;
1496 struct machine *machine = mg->machine; 1496 struct machine *machine = mg->machine;
@@ -1504,7 +1504,7 @@ void __thread__find_map(struct thread *thread, u8 cpumode, enum map_type type,
1504 1504
1505 if (machine == NULL) { 1505 if (machine == NULL) {
1506 al->map = NULL; 1506 al->map = NULL;
1507 return; 1507 return NULL;
1508 } 1508 }
1509 1509
1510 if (cpumode == PERF_RECORD_MISC_KERNEL && perf_host) { 1510 if (cpumode == PERF_RECORD_MISC_KERNEL && perf_host) {
@@ -1532,7 +1532,7 @@ void __thread__find_map(struct thread *thread, u8 cpumode, enum map_type type,
1532 !perf_host) 1532 !perf_host)
1533 al->filtered |= (1 << HIST_FILTER__HOST); 1533 al->filtered |= (1 << HIST_FILTER__HOST);
1534 1534
1535 return; 1535 return NULL;
1536 } 1536 }
1537try_again: 1537try_again:
1538 al->map = map_groups__find(mg, type, al->addr); 1538 al->map = map_groups__find(mg, type, al->addr);
@@ -1562,14 +1562,15 @@ try_again:
1562 map__load(al->map); 1562 map__load(al->map);
1563 al->addr = al->map->map_ip(al->map, al->addr); 1563 al->addr = al->map->map_ip(al->map, al->addr);
1564 } 1564 }
1565
1566 return al->map;
1565} 1567}
1566 1568
1567void __thread__find_symbol(struct thread *thread, u8 cpumode, 1569void __thread__find_symbol(struct thread *thread, u8 cpumode,
1568 enum map_type type, u64 addr, 1570 enum map_type type, u64 addr,
1569 struct addr_location *al) 1571 struct addr_location *al)
1570{ 1572{
1571 __thread__find_map(thread, cpumode, type, addr, al); 1573 if (__thread__find_map(thread, cpumode, type, addr, al))
1572 if (al->map != NULL)
1573 al->sym = map__find_symbol(al->map, al->addr); 1574 al->sym = map__find_symbol(al->map, al->addr);
1574 else 1575 else
1575 al->sym = NULL; 1576 al->sym = NULL;
@@ -1668,8 +1669,7 @@ bool sample_addr_correlates_sym(struct perf_event_attr *attr)
1668void thread__resolve(struct thread *thread, struct addr_location *al, 1669void thread__resolve(struct thread *thread, struct addr_location *al,
1669 struct perf_sample *sample) 1670 struct perf_sample *sample)
1670{ 1671{
1671 thread__find_map(thread, sample->cpumode, sample->addr, al); 1672 if (!thread__find_map(thread, sample->cpumode, sample->addr, al)) {
1672 if (!al->map) {
1673 __thread__find_map(thread, sample->cpumode, MAP__VARIABLE, 1673 __thread__find_map(thread, sample->cpumode, MAP__VARIABLE,
1674 sample->addr, al); 1674 sample->addr, al);
1675 } 1675 }
diff --git a/tools/perf/util/intel-bts.c b/tools/perf/util/intel-bts.c
index ea0ce8572bf2..7f0c83b6332b 100644
--- a/tools/perf/util/intel-bts.c
+++ b/tools/perf/util/intel-bts.c
@@ -335,8 +335,7 @@ static int intel_bts_get_next_insn(struct intel_bts_queue *btsq, u64 ip)
335 if (!thread) 335 if (!thread)
336 return -1; 336 return -1;
337 337
338 thread__find_map(thread, cpumode, ip, &al); 338 if (!thread__find_map(thread, cpumode, ip, &al) || !al.map->dso)
339 if (!al.map || !al.map->dso)
340 goto out_put; 339 goto out_put;
341 340
342 len = dso__data_read_addr(al.map->dso, al.map, machine, ip, buf, 341 len = dso__data_read_addr(al.map->dso, al.map, machine, ip, buf,
diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
index 441e681a46a0..a272b35f6c5a 100644
--- a/tools/perf/util/intel-pt.c
+++ b/tools/perf/util/intel-pt.c
@@ -442,8 +442,7 @@ static int intel_pt_walk_next_insn(struct intel_pt_insn *intel_pt_insn,
442 } 442 }
443 443
444 while (1) { 444 while (1) {
445 thread__find_map(thread, cpumode, *ip, &al); 445 if (!thread__find_map(thread, cpumode, *ip, &al) || !al.map->dso)
446 if (!al.map || !al.map->dso)
447 return -EINVAL; 446 return -EINVAL;
448 447
449 if (al.map->dso->data.status == DSO_DATA_STATUS_ERROR && 448 if (al.map->dso->data.status == DSO_DATA_STATUS_ERROR &&
@@ -596,8 +595,7 @@ static int __intel_pt_pgd_ip(uint64_t ip, void *data)
596 if (!thread) 595 if (!thread)
597 return -EINVAL; 596 return -EINVAL;
598 597
599 thread__find_map(thread, cpumode, ip, &al); 598 if (!thread__find_map(thread, cpumode, ip, &al) || !al.map->dso)
600 if (!al.map || !al.map->dso)
601 return -EINVAL; 599 return -EINVAL;
602 600
603 offset = al.map->map_ip(al.map, ip); 601 offset = al.map->map_ip(al.map, ip);
diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h
index b69e65c821f9..1961e4bc1c2c 100644
--- a/tools/perf/util/thread.h
+++ b/tools/perf/util/thread.h
@@ -92,13 +92,13 @@ size_t thread__fprintf(struct thread *thread, FILE *fp);
92 92
93struct thread *thread__main_thread(struct machine *machine, struct thread *thread); 93struct thread *thread__main_thread(struct machine *machine, struct thread *thread);
94 94
95void __thread__find_map(struct thread *thread, u8 cpumode, enum map_type type, 95struct map *__thread__find_map(struct thread *thread, u8 cpumode, enum map_type type,
96 u64 addr, struct addr_location *al); 96 u64 addr, struct addr_location *al);
97 97
98static inline void thread__find_map(struct thread *thread, u8 cpumode, 98static inline struct map *thread__find_map(struct thread *thread, u8 cpumode,
99 u64 addr, struct addr_location *al) 99 u64 addr, struct addr_location *al)
100{ 100{
101 __thread__find_map(thread, cpumode, MAP__FUNCTION, addr, al); 101 return __thread__find_map(thread, cpumode, MAP__FUNCTION, addr, al);
102} 102}
103 103
104void __thread__find_symbol(struct thread *thread, u8 cpumode, enum map_type type, 104void __thread__find_symbol(struct thread *thread, u8 cpumode, enum map_type type,
diff --git a/tools/perf/util/unwind-libdw.c b/tools/perf/util/unwind-libdw.c
index bdc22f1864df..17401922cd42 100644
--- a/tools/perf/util/unwind-libdw.c
+++ b/tools/perf/util/unwind-libdw.c
@@ -104,8 +104,7 @@ static int access_dso_mem(struct unwind_info *ui, Dwarf_Addr addr,
104 struct addr_location al; 104 struct addr_location al;
105 ssize_t size; 105 ssize_t size;
106 106
107 thread__find_map(ui->thread, PERF_RECORD_MISC_USER, addr, &al); 107 if (!thread__find_map(ui->thread, PERF_RECORD_MISC_USER, addr, &al)) {
108 if (!al.map) {
109 /* 108 /*
110 * We've seen cases (softice) where DWARF unwinder went 109 * We've seen cases (softice) where DWARF unwinder went
111 * through non executable mmaps, which we need to lookup 110 * through non executable mmaps, which we need to lookup
diff --git a/tools/perf/util/unwind-libunwind-local.c b/tools/perf/util/unwind-libunwind-local.c
index 0007c64f3220..4662590ef091 100644
--- a/tools/perf/util/unwind-libunwind-local.c
+++ b/tools/perf/util/unwind-libunwind-local.c
@@ -367,8 +367,7 @@ static struct map *find_map(unw_word_t ip, struct unwind_info *ui)
367{ 367{
368 struct addr_location al; 368 struct addr_location al;
369 369
370 thread__find_map(ui->thread, PERF_RECORD_MISC_USER, ip, &al); 370 if (!thread__find_map(ui->thread, PERF_RECORD_MISC_USER, ip, &al)) {
371 if (!al.map) {
372 /* 371 /*
373 * We've seen cases (softice) where DWARF unwinder went 372 * We've seen cases (softice) where DWARF unwinder went
374 * through non executable mmaps, which we need to lookup 373 * through non executable mmaps, which we need to lookup