diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/builtin-top.c | 18 | ||||
-rw-r--r-- | tools/perf/util/map.c | 8 | ||||
-rw-r--r-- | tools/perf/util/map.h | 4 |
3 files changed, 19 insertions, 11 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index e4156bc4566d..befa57e2284d 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -216,7 +216,7 @@ static void parse_source(struct sym_entry *syme) | |||
216 | while (!feof(file)) { | 216 | while (!feof(file)) { |
217 | struct source_line *src; | 217 | struct source_line *src; |
218 | size_t dummy = 0; | 218 | size_t dummy = 0; |
219 | char *c; | 219 | char *c, *sep; |
220 | 220 | ||
221 | src = malloc(sizeof(struct source_line)); | 221 | src = malloc(sizeof(struct source_line)); |
222 | assert(src != NULL); | 222 | assert(src != NULL); |
@@ -235,14 +235,11 @@ static void parse_source(struct sym_entry *syme) | |||
235 | *source->lines_tail = src; | 235 | *source->lines_tail = src; |
236 | source->lines_tail = &src->next; | 236 | source->lines_tail = &src->next; |
237 | 237 | ||
238 | if (strlen(src->line)>8 && src->line[8] == ':') { | 238 | src->eip = strtoull(src->line, &sep, 16); |
239 | src->eip = strtoull(src->line, NULL, 16); | 239 | if (*sep == ':') |
240 | src->eip = map->unmap_ip(map, src->eip); | 240 | src->eip = map__objdump_2ip(map, src->eip); |
241 | } | 241 | else /* this line has no ip info (e.g. source line) */ |
242 | if (strlen(src->line)>8 && src->line[16] == ':') { | 242 | src->eip = 0; |
243 | src->eip = strtoull(src->line, NULL, 16); | ||
244 | src->eip = map->unmap_ip(map, src->eip); | ||
245 | } | ||
246 | } | 243 | } |
247 | pclose(file); | 244 | pclose(file); |
248 | out_assign: | 245 | out_assign: |
@@ -277,6 +274,9 @@ static void record_precise_ip(struct sym_entry *syme, int counter, u64 ip) | |||
277 | goto out_unlock; | 274 | goto out_unlock; |
278 | 275 | ||
279 | for (line = syme->src->lines; line; line = line->next) { | 276 | for (line = syme->src->lines; line; line = line->next) { |
277 | /* skip lines without IP info */ | ||
278 | if (line->eip == 0) | ||
279 | continue; | ||
280 | if (line->eip == ip) { | 280 | if (line->eip == ip) { |
281 | line->count[counter]++; | 281 | line->count[counter]++; |
282 | break; | 282 | break; |
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index af5805f51314..138e3cb2b727 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c | |||
@@ -222,3 +222,11 @@ u64 map__rip_2objdump(struct map *map, u64 rip) | |||
222 | rip; | 222 | rip; |
223 | return addr; | 223 | return addr; |
224 | } | 224 | } |
225 | |||
226 | u64 map__objdump_2ip(struct map *map, u64 addr) | ||
227 | { | ||
228 | u64 ip = map->dso->adjust_symbols ? | ||
229 | addr : | ||
230 | map->unmap_ip(map, addr); /* RIP -> IP */ | ||
231 | return ip; | ||
232 | } | ||
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h index 9cee9c788dbf..86f77cb1d060 100644 --- a/tools/perf/util/map.h +++ b/tools/perf/util/map.h | |||
@@ -61,9 +61,9 @@ static inline u64 identity__map_ip(struct map *map __used, u64 ip) | |||
61 | } | 61 | } |
62 | 62 | ||
63 | 63 | ||
64 | /* rip -> addr suitable for passing to `objdump --start-address=` */ | 64 | /* rip/ip <-> addr suitable for passing to `objdump --start-address=` */ |
65 | u64 map__rip_2objdump(struct map *map, u64 rip); | 65 | u64 map__rip_2objdump(struct map *map, u64 rip); |
66 | 66 | u64 map__objdump_2ip(struct map *map, u64 addr); | |
67 | 67 | ||
68 | struct symbol; | 68 | struct symbol; |
69 | struct mmap_event; | 69 | struct mmap_event; |