TEST_ASSERT_VAL("wrong map start", map->start == merged[i].start);
TEST_ASSERT_VAL("wrong map end", map->end == merged[i].end);
TEST_ASSERT_VAL("wrong map name", !strcmp(map->dso->name, merged[i].name));
- TEST_ASSERT_VAL("wrong map refcnt", refcount_read(&map->refcnt) == 2);
+ TEST_ASSERT_VAL("wrong map refcnt", refcount_read(&map->refcnt) == 1);
i++;
}
#include "ui/ui.h"
static void __maps__insert(struct maps *maps, struct map *map);
-static void __maps__insert_name(struct maps *maps, struct map *map);
static inline int is_anon_memory(const char *filename, u32 flags)
{
static void maps__init(struct maps *maps)
{
maps->entries = RB_ROOT;
- maps->names = RB_ROOT;
init_rwsem(&maps->lock);
}
maps__for_each_entry_safe(maps, pos, next) {
rb_erase_init(&pos->rb_node, &maps->entries);
map__put(pos);
- rb_erase_init(&pos->rb_node_name, &maps->names);
- map__put(pos);
}
}
static void __map_groups__insert(struct map_groups *mg, struct map *map)
{
__maps__insert(&mg->maps, map);
- __maps__insert_name(&mg->maps, map);
}
int map_groups__fixup_overlappings(struct map_groups *mg, struct map *map, FILE *fp)
map__get(map);
}
-static void __maps__insert_name(struct maps *maps, struct map *map)
-{
- struct rb_node **p = &maps->names.rb_node;
- struct rb_node *parent = NULL;
- struct map *m;
- int rc;
-
- while (*p != NULL) {
- parent = *p;
- m = rb_entry(parent, struct map, rb_node_name);
- rc = strcmp(m->dso->short_name, map->dso->short_name);
- if (rc < 0)
- p = &(*p)->rb_left;
- else
- p = &(*p)->rb_right;
- }
- rb_link_node(&map->rb_node_name, parent, p);
- rb_insert_color(&map->rb_node_name, &maps->names);
- map__get(map);
-}
-
void maps__insert(struct maps *maps, struct map *map)
{
down_write(&maps->lock);
__maps__insert(maps, map);
- __maps__insert_name(maps, map);
up_write(&maps->lock);
}
{
rb_erase_init(&map->rb_node, &maps->entries);
map__put(map);
-
- rb_erase_init(&map->rb_node_name, &maps->names);
- map__put(map);
}
void maps__remove(struct maps *maps, struct map *map)
{
struct maps *maps = &mg->maps;
struct map *map;
- struct rb_node *node;
down_read(&maps->lock);
- for (node = maps->names.rb_node; node; ) {
- int rc;
-
- map = rb_entry(node, struct map, rb_node_name);
-
- rc = strcmp(map->dso->short_name, name);
- if (rc < 0)
- node = node->rb_left;
- else if (rc > 0)
- node = node->rb_right;
- else
-
+ maps__for_each_entry(maps, map)
+ if (strcmp(map->dso->short_name, name) == 0)
goto out_unlock;
- }
map = NULL;