diff options
Diffstat (limited to 'tools/perf/util/map.c')
-rw-r--r-- | tools/perf/util/map.c | 45 |
1 files changed, 20 insertions, 25 deletions
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index 728129ac653a..c662fef95d14 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c | |||
@@ -6,6 +6,7 @@ | |||
6 | #include <string.h> | 6 | #include <string.h> |
7 | #include <stdio.h> | 7 | #include <stdio.h> |
8 | #include <unistd.h> | 8 | #include <unistd.h> |
9 | #include <uapi/linux/mman.h> /* To get things like MAP_HUGETLB even on older libc headers */ | ||
9 | #include "map.h" | 10 | #include "map.h" |
10 | #include "thread.h" | 11 | #include "thread.h" |
11 | #include "strlist.h" | 12 | #include "strlist.h" |
@@ -24,9 +25,10 @@ const char *map_type__name[MAP__NR_TYPES] = { | |||
24 | [MAP__VARIABLE] = "Variables", | 25 | [MAP__VARIABLE] = "Variables", |
25 | }; | 26 | }; |
26 | 27 | ||
27 | static inline int is_anon_memory(const char *filename) | 28 | static inline int is_anon_memory(const char *filename, u32 flags) |
28 | { | 29 | { |
29 | return !strcmp(filename, "//anon") || | 30 | return flags & MAP_HUGETLB || |
31 | !strcmp(filename, "//anon") || | ||
30 | !strncmp(filename, "/dev/zero", sizeof("/dev/zero") - 1) || | 32 | !strncmp(filename, "/dev/zero", sizeof("/dev/zero") - 1) || |
31 | !strncmp(filename, "/anon_hugepage", sizeof("/anon_hugepage") - 1); | 33 | !strncmp(filename, "/anon_hugepage", sizeof("/anon_hugepage") - 1); |
32 | } | 34 | } |
@@ -155,7 +157,7 @@ struct map *map__new(struct machine *machine, u64 start, u64 len, | |||
155 | int anon, no_dso, vdso, android; | 157 | int anon, no_dso, vdso, android; |
156 | 158 | ||
157 | android = is_android_lib(filename); | 159 | android = is_android_lib(filename); |
158 | anon = is_anon_memory(filename); | 160 | anon = is_anon_memory(filename, flags); |
159 | vdso = is_vdso_map(filename); | 161 | vdso = is_vdso_map(filename); |
160 | no_dso = is_no_dso_memory(filename); | 162 | no_dso = is_no_dso_memory(filename); |
161 | 163 | ||
@@ -279,7 +281,7 @@ void map__fixup_end(struct map *map) | |||
279 | 281 | ||
280 | #define DSO__DELETED "(deleted)" | 282 | #define DSO__DELETED "(deleted)" |
281 | 283 | ||
282 | int map__load(struct map *map, symbol_filter_t filter) | 284 | int map__load(struct map *map) |
283 | { | 285 | { |
284 | const char *name = map->dso->long_name; | 286 | const char *name = map->dso->long_name; |
285 | int nr; | 287 | int nr; |
@@ -287,7 +289,7 @@ int map__load(struct map *map, symbol_filter_t filter) | |||
287 | if (dso__loaded(map->dso, map->type)) | 289 | if (dso__loaded(map->dso, map->type)) |
288 | return 0; | 290 | return 0; |
289 | 291 | ||
290 | nr = dso__load(map->dso, map, filter); | 292 | nr = dso__load(map->dso, map); |
291 | if (nr < 0) { | 293 | if (nr < 0) { |
292 | if (map->dso->has_build_id) { | 294 | if (map->dso->has_build_id) { |
293 | char sbuild_id[SBUILD_ID_SIZE]; | 295 | char sbuild_id[SBUILD_ID_SIZE]; |
@@ -312,9 +314,6 @@ int map__load(struct map *map, symbol_filter_t filter) | |||
312 | pr_warning("%.*s was updated (is prelink enabled?). " | 314 | pr_warning("%.*s was updated (is prelink enabled?). " |
313 | "Restart the long running apps that use it!\n", | 315 | "Restart the long running apps that use it!\n", |
314 | (int)real_len, name); | 316 | (int)real_len, name); |
315 | } else if (filter) { | ||
316 | pr_warning("no symbols passed the given filter.\n"); | ||
317 | return -2; /* Empty but maybe by the filter */ | ||
318 | } else { | 317 | } else { |
319 | pr_warning("no symbols found in %s, maybe install " | 318 | pr_warning("no symbols found in %s, maybe install " |
320 | "a debug package?\n", name); | 319 | "a debug package?\n", name); |
@@ -331,19 +330,17 @@ int __weak arch__compare_symbol_names(const char *namea, const char *nameb) | |||
331 | return strcmp(namea, nameb); | 330 | return strcmp(namea, nameb); |
332 | } | 331 | } |
333 | 332 | ||
334 | struct symbol *map__find_symbol(struct map *map, u64 addr, | 333 | struct symbol *map__find_symbol(struct map *map, u64 addr) |
335 | symbol_filter_t filter) | ||
336 | { | 334 | { |
337 | if (map__load(map, filter) < 0) | 335 | if (map__load(map) < 0) |
338 | return NULL; | 336 | return NULL; |
339 | 337 | ||
340 | return dso__find_symbol(map->dso, map->type, addr); | 338 | return dso__find_symbol(map->dso, map->type, addr); |
341 | } | 339 | } |
342 | 340 | ||
343 | struct symbol *map__find_symbol_by_name(struct map *map, const char *name, | 341 | struct symbol *map__find_symbol_by_name(struct map *map, const char *name) |
344 | symbol_filter_t filter) | ||
345 | { | 342 | { |
346 | if (map__load(map, filter) < 0) | 343 | if (map__load(map) < 0) |
347 | return NULL; | 344 | return NULL; |
348 | 345 | ||
349 | if (!dso__sorted_by_name(map->dso, map->type)) | 346 | if (!dso__sorted_by_name(map->dso, map->type)) |
@@ -556,23 +553,22 @@ void map_groups__put(struct map_groups *mg) | |||
556 | 553 | ||
557 | struct symbol *map_groups__find_symbol(struct map_groups *mg, | 554 | struct symbol *map_groups__find_symbol(struct map_groups *mg, |
558 | enum map_type type, u64 addr, | 555 | enum map_type type, u64 addr, |
559 | struct map **mapp, | 556 | struct map **mapp) |
560 | symbol_filter_t filter) | ||
561 | { | 557 | { |
562 | struct map *map = map_groups__find(mg, type, addr); | 558 | struct map *map = map_groups__find(mg, type, addr); |
563 | 559 | ||
564 | /* Ensure map is loaded before using map->map_ip */ | 560 | /* Ensure map is loaded before using map->map_ip */ |
565 | if (map != NULL && map__load(map, filter) >= 0) { | 561 | if (map != NULL && map__load(map) >= 0) { |
566 | if (mapp != NULL) | 562 | if (mapp != NULL) |
567 | *mapp = map; | 563 | *mapp = map; |
568 | return map__find_symbol(map, map->map_ip(map, addr), filter); | 564 | return map__find_symbol(map, map->map_ip(map, addr)); |
569 | } | 565 | } |
570 | 566 | ||
571 | return NULL; | 567 | return NULL; |
572 | } | 568 | } |
573 | 569 | ||
574 | struct symbol *maps__find_symbol_by_name(struct maps *maps, const char *name, | 570 | struct symbol *maps__find_symbol_by_name(struct maps *maps, const char *name, |
575 | struct map **mapp, symbol_filter_t filter) | 571 | struct map **mapp) |
576 | { | 572 | { |
577 | struct symbol *sym; | 573 | struct symbol *sym; |
578 | struct rb_node *nd; | 574 | struct rb_node *nd; |
@@ -582,7 +578,7 @@ struct symbol *maps__find_symbol_by_name(struct maps *maps, const char *name, | |||
582 | for (nd = rb_first(&maps->entries); nd; nd = rb_next(nd)) { | 578 | for (nd = rb_first(&maps->entries); nd; nd = rb_next(nd)) { |
583 | struct map *pos = rb_entry(nd, struct map, rb_node); | 579 | struct map *pos = rb_entry(nd, struct map, rb_node); |
584 | 580 | ||
585 | sym = map__find_symbol_by_name(pos, name, filter); | 581 | sym = map__find_symbol_by_name(pos, name); |
586 | 582 | ||
587 | if (sym == NULL) | 583 | if (sym == NULL) |
588 | continue; | 584 | continue; |
@@ -600,15 +596,14 @@ out: | |||
600 | struct symbol *map_groups__find_symbol_by_name(struct map_groups *mg, | 596 | struct symbol *map_groups__find_symbol_by_name(struct map_groups *mg, |
601 | enum map_type type, | 597 | enum map_type type, |
602 | const char *name, | 598 | const char *name, |
603 | struct map **mapp, | 599 | struct map **mapp) |
604 | symbol_filter_t filter) | ||
605 | { | 600 | { |
606 | struct symbol *sym = maps__find_symbol_by_name(&mg->maps[type], name, mapp, filter); | 601 | struct symbol *sym = maps__find_symbol_by_name(&mg->maps[type], name, mapp); |
607 | 602 | ||
608 | return sym; | 603 | return sym; |
609 | } | 604 | } |
610 | 605 | ||
611 | int map_groups__find_ams(struct addr_map_symbol *ams, symbol_filter_t filter) | 606 | int map_groups__find_ams(struct addr_map_symbol *ams) |
612 | { | 607 | { |
613 | if (ams->addr < ams->map->start || ams->addr >= ams->map->end) { | 608 | if (ams->addr < ams->map->start || ams->addr >= ams->map->end) { |
614 | if (ams->map->groups == NULL) | 609 | if (ams->map->groups == NULL) |
@@ -620,7 +615,7 @@ int map_groups__find_ams(struct addr_map_symbol *ams, symbol_filter_t filter) | |||
620 | } | 615 | } |
621 | 616 | ||
622 | ams->al_addr = ams->map->map_ip(ams->map, ams->addr); | 617 | ams->al_addr = ams->map->map_ip(ams->map, ams->addr); |
623 | ams->sym = map__find_symbol(ams->map, ams->al_addr, filter); | 618 | ams->sym = map__find_symbol(ams->map, ams->al_addr); |
624 | 619 | ||
625 | return ams->sym ? 0 : -1; | 620 | return ams->sym ? 0 : -1; |
626 | } | 621 | } |