Lines Matching refs:maps
28 static void __maps__insert(struct maps *maps, struct map *map);
527 void maps__init(struct maps *maps, struct machine *machine) in maps__init() argument
529 maps->entries = RB_ROOT; in maps__init()
530 init_rwsem(&maps->lock); in maps__init()
531 maps->machine = machine; in maps__init()
532 maps->last_search_by_name = NULL; in maps__init()
533 maps->nr_maps = 0; in maps__init()
534 maps->maps_by_name = NULL; in maps__init()
535 refcount_set(&maps->refcnt, 1); in maps__init()
538 static void __maps__free_maps_by_name(struct maps *maps) in __maps__free_maps_by_name() argument
543 zfree(&maps->maps_by_name); in __maps__free_maps_by_name()
544 maps->nr_maps_allocated = 0; in __maps__free_maps_by_name()
547 void maps__insert(struct maps *maps, struct map *map) in maps__insert() argument
549 down_write(&maps->lock); in maps__insert()
550 __maps__insert(maps, map); in maps__insert()
551 ++maps->nr_maps; in maps__insert()
557 kmap->kmaps = maps; in maps__insert()
567 if (maps->maps_by_name) { in maps__insert()
568 if (maps->nr_maps > maps->nr_maps_allocated) { in maps__insert()
569 int nr_allocate = maps->nr_maps * 2; in maps__insert()
570 struct map **maps_by_name = realloc(maps->maps_by_name, nr_allocate * sizeof(map)); in maps__insert()
573 __maps__free_maps_by_name(maps); in maps__insert()
574 up_write(&maps->lock); in maps__insert()
578 maps->maps_by_name = maps_by_name; in maps__insert()
579 maps->nr_maps_allocated = nr_allocate; in maps__insert()
581 maps->maps_by_name[maps->nr_maps - 1] = map; in maps__insert()
582 __maps__sort_by_name(maps); in maps__insert()
584 up_write(&maps->lock); in maps__insert()
587 static void __maps__remove(struct maps *maps, struct map *map) in __maps__remove() argument
589 rb_erase_init(&map->rb_node, &maps->entries); in __maps__remove()
593 void maps__remove(struct maps *maps, struct map *map) in maps__remove() argument
595 down_write(&maps->lock); in maps__remove()
596 if (maps->last_search_by_name == map) in maps__remove()
597 maps->last_search_by_name = NULL; in maps__remove()
599 __maps__remove(maps, map); in maps__remove()
600 --maps->nr_maps; in maps__remove()
601 if (maps->maps_by_name) in maps__remove()
602 __maps__free_maps_by_name(maps); in maps__remove()
603 up_write(&maps->lock); in maps__remove()
606 static void __maps__purge(struct maps *maps) in __maps__purge() argument
610 maps__for_each_entry_safe(maps, pos, next) { in __maps__purge()
611 rb_erase_init(&pos->rb_node, &maps->entries); in __maps__purge()
616 void maps__exit(struct maps *maps) in maps__exit() argument
618 down_write(&maps->lock); in maps__exit()
619 __maps__purge(maps); in maps__exit()
620 up_write(&maps->lock); in maps__exit()
623 bool maps__empty(struct maps *maps) in maps__empty() argument
625 return !maps__first(maps); in maps__empty()
628 struct maps *maps__new(struct machine *machine) in maps__new()
630 struct maps *maps = zalloc(sizeof(*maps)); in maps__new() local
632 if (maps != NULL) in maps__new()
633 maps__init(maps, machine); in maps__new()
635 return maps; in maps__new()
638 void maps__delete(struct maps *maps) in maps__delete() argument
640 maps__exit(maps); in maps__delete()
641 unwind__finish_access(maps); in maps__delete()
642 free(maps); in maps__delete()
645 void maps__put(struct maps *maps) in maps__put() argument
647 if (maps && refcount_dec_and_test(&maps->refcnt)) in maps__put()
648 maps__delete(maps); in maps__put()
651 struct symbol *maps__find_symbol(struct maps *maps, u64 addr, struct map **mapp) in maps__find_symbol() argument
653 struct map *map = maps__find(maps, addr); in maps__find_symbol()
672 struct symbol *maps__find_symbol_by_name(struct maps *maps, const char *name, struct map **mapp) in maps__find_symbol_by_name() argument
677 down_read(&maps->lock); in maps__find_symbol_by_name()
679 maps__for_each_entry(maps, pos) { in maps__find_symbol_by_name()
695 up_read(&maps->lock); in maps__find_symbol_by_name()
699 int maps__find_ams(struct maps *maps, struct addr_map_symbol *ams) in maps__find_ams() argument
702 if (maps == NULL) in maps__find_ams()
704 ams->ms.map = maps__find(maps, ams->addr); in maps__find_ams()
715 size_t maps__fprintf(struct maps *maps, FILE *fp) in maps__fprintf() argument
720 down_read(&maps->lock); in maps__fprintf()
722 maps__for_each_entry(maps, pos) { in maps__fprintf()
731 up_read(&maps->lock); in maps__fprintf()
736 int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp) in maps__fixup_overlappings() argument
742 down_write(&maps->lock); in maps__fixup_overlappings()
744 root = &maps->entries; in maps__fixup_overlappings()
802 __maps__insert(maps, before); in maps__fixup_overlappings()
819 __maps__insert(maps, after); in maps__fixup_overlappings()
833 up_write(&maps->lock); in maps__fixup_overlappings()
840 int maps__clone(struct thread *thread, struct maps *parent) in maps__clone()
842 struct maps *maps = thread->maps; in maps__clone() local
856 err = unwind__prepare_access(maps, new, NULL); in maps__clone()
860 maps__insert(maps, new); in maps__clone()
870 static void __maps__insert(struct maps *maps, struct map *map) in __maps__insert() argument
872 struct rb_node **p = &maps->entries.rb_node; in __maps__insert()
887 rb_insert_color(&map->rb_node, &maps->entries); in __maps__insert()
891 struct map *maps__find(struct maps *maps, u64 ip) in maps__find() argument
896 down_read(&maps->lock); in maps__find()
898 p = maps->entries.rb_node; in maps__find()
911 up_read(&maps->lock); in maps__find()
915 struct map *maps__first(struct maps *maps) in maps__first() argument
917 struct rb_node *first = rb_first(&maps->entries); in maps__first()
954 struct maps *map__kmaps(struct map *map) in map__kmaps()