aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/map.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/map.c')
-rw-r--r--tools/perf/util/map.c47
1 files changed, 31 insertions, 16 deletions
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 25c571f4cba6..31b8905dd863 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -12,6 +12,8 @@
12#include "vdso.h" 12#include "vdso.h"
13#include "build-id.h" 13#include "build-id.h"
14#include "util.h" 14#include "util.h"
15#include "debug.h"
16#include "machine.h"
15#include <linux/string.h> 17#include <linux/string.h>
16 18
17const char *map_type__name[MAP__NR_TYPES] = { 19const char *map_type__name[MAP__NR_TYPES] = {
@@ -136,10 +138,10 @@ void map__init(struct map *map, enum map_type type,
136 map->erange_warned = false; 138 map->erange_warned = false;
137} 139}
138 140
139struct map *map__new(struct list_head *dsos__list, u64 start, u64 len, 141struct map *map__new(struct machine *machine, u64 start, u64 len,
140 u64 pgoff, u32 pid, u32 d_maj, u32 d_min, u64 ino, 142 u64 pgoff, u32 pid, u32 d_maj, u32 d_min, u64 ino,
141 u64 ino_gen, u32 prot, u32 flags, char *filename, 143 u64 ino_gen, u32 prot, u32 flags, char *filename,
142 enum map_type type) 144 enum map_type type, struct thread *thread)
143{ 145{
144 struct map *map = malloc(sizeof(*map)); 146 struct map *map = malloc(sizeof(*map));
145 147
@@ -172,9 +174,9 @@ struct map *map__new(struct list_head *dsos__list, u64 start, u64 len,
172 174
173 if (vdso) { 175 if (vdso) {
174 pgoff = 0; 176 pgoff = 0;
175 dso = vdso__dso_findnew(dsos__list); 177 dso = vdso__dso_findnew(machine, thread);
176 } else 178 } else
177 dso = __dsos__findnew(dsos__list, filename); 179 dso = __dsos__findnew(&machine->user_dsos, filename);
178 180
179 if (dso == NULL) 181 if (dso == NULL)
180 goto out_delete; 182 goto out_delete;
@@ -454,6 +456,20 @@ void map_groups__exit(struct map_groups *mg)
454 } 456 }
455} 457}
456 458
459bool map_groups__empty(struct map_groups *mg)
460{
461 int i;
462
463 for (i = 0; i < MAP__NR_TYPES; ++i) {
464 if (maps__first(&mg->maps[i]))
465 return false;
466 if (!list_empty(&mg->removed_maps[i]))
467 return false;
468 }
469
470 return true;
471}
472
457struct map_groups *map_groups__new(void) 473struct map_groups *map_groups__new(void)
458{ 474{
459 struct map_groups *mg = malloc(sizeof(*mg)); 475 struct map_groups *mg = malloc(sizeof(*mg));
@@ -554,8 +570,8 @@ int map_groups__find_ams(struct addr_map_symbol *ams, symbol_filter_t filter)
554 return ams->sym ? 0 : -1; 570 return ams->sym ? 0 : -1;
555} 571}
556 572
557size_t __map_groups__fprintf_maps(struct map_groups *mg, 573size_t __map_groups__fprintf_maps(struct map_groups *mg, enum map_type type,
558 enum map_type type, int verbose, FILE *fp) 574 FILE *fp)
559{ 575{
560 size_t printed = fprintf(fp, "%s:\n", map_type__name[type]); 576 size_t printed = fprintf(fp, "%s:\n", map_type__name[type]);
561 struct rb_node *nd; 577 struct rb_node *nd;
@@ -573,17 +589,16 @@ size_t __map_groups__fprintf_maps(struct map_groups *mg,
573 return printed; 589 return printed;
574} 590}
575 591
576size_t map_groups__fprintf_maps(struct map_groups *mg, int verbose, FILE *fp) 592static size_t map_groups__fprintf_maps(struct map_groups *mg, FILE *fp)
577{ 593{
578 size_t printed = 0, i; 594 size_t printed = 0, i;
579 for (i = 0; i < MAP__NR_TYPES; ++i) 595 for (i = 0; i < MAP__NR_TYPES; ++i)
580 printed += __map_groups__fprintf_maps(mg, i, verbose, fp); 596 printed += __map_groups__fprintf_maps(mg, i, fp);
581 return printed; 597 return printed;
582} 598}
583 599
584static size_t __map_groups__fprintf_removed_maps(struct map_groups *mg, 600static size_t __map_groups__fprintf_removed_maps(struct map_groups *mg,
585 enum map_type type, 601 enum map_type type, FILE *fp)
586 int verbose, FILE *fp)
587{ 602{
588 struct map *pos; 603 struct map *pos;
589 size_t printed = 0; 604 size_t printed = 0;
@@ -600,23 +615,23 @@ static size_t __map_groups__fprintf_removed_maps(struct map_groups *mg,
600} 615}
601 616
602static size_t map_groups__fprintf_removed_maps(struct map_groups *mg, 617static size_t map_groups__fprintf_removed_maps(struct map_groups *mg,
603 int verbose, FILE *fp) 618 FILE *fp)
604{ 619{
605 size_t printed = 0, i; 620 size_t printed = 0, i;
606 for (i = 0; i < MAP__NR_TYPES; ++i) 621 for (i = 0; i < MAP__NR_TYPES; ++i)
607 printed += __map_groups__fprintf_removed_maps(mg, i, verbose, fp); 622 printed += __map_groups__fprintf_removed_maps(mg, i, fp);
608 return printed; 623 return printed;
609} 624}
610 625
611size_t map_groups__fprintf(struct map_groups *mg, int verbose, FILE *fp) 626size_t map_groups__fprintf(struct map_groups *mg, FILE *fp)
612{ 627{
613 size_t printed = map_groups__fprintf_maps(mg, verbose, fp); 628 size_t printed = map_groups__fprintf_maps(mg, fp);
614 printed += fprintf(fp, "Removed maps:\n"); 629 printed += fprintf(fp, "Removed maps:\n");
615 return printed + map_groups__fprintf_removed_maps(mg, verbose, fp); 630 return printed + map_groups__fprintf_removed_maps(mg, fp);
616} 631}
617 632
618int map_groups__fixup_overlappings(struct map_groups *mg, struct map *map, 633int map_groups__fixup_overlappings(struct map_groups *mg, struct map *map,
619 int verbose, FILE *fp) 634 FILE *fp)
620{ 635{
621 struct rb_root *root = &mg->maps[map->type]; 636 struct rb_root *root = &mg->maps[map->type];
622 struct rb_node *next = rb_first(root); 637 struct rb_node *next = rb_first(root);