mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-05 23:23:09 +00:00
gdb: use local addrmap_mutable in addrmap selftest
There is no need to allocate the addrmap_mutable on the heap. Change-Id: Ia6ec17101a44ae5eaffbf3382c9639414ce5343e Approved-By: Andrew Burgess <aburgess@redhat.com>
This commit is contained in:
committed by
Simon Marchi
parent
265cdb307f
commit
77307a766b
@@ -427,21 +427,20 @@ test_addrmap ()
|
|||||||
|
|
||||||
/* Create mutable addrmap. */
|
/* Create mutable addrmap. */
|
||||||
auto_obstack temp_obstack;
|
auto_obstack temp_obstack;
|
||||||
auto map = std::make_unique<struct addrmap_mutable> ();
|
addrmap_mutable map;
|
||||||
SELF_CHECK (map != nullptr);
|
|
||||||
|
|
||||||
/* Check initial state. */
|
/* Check initial state. */
|
||||||
check_addrmap_find (*map, array, 0, 19, nullptr);
|
check_addrmap_find (map, array, 0, 19, nullptr);
|
||||||
|
|
||||||
/* Insert address range into mutable addrmap. */
|
/* Insert address range into mutable addrmap. */
|
||||||
map->set_empty (core_addr (&array[10]), core_addr (&array[12]), val1);
|
map.set_empty (core_addr (&array[10]), core_addr (&array[12]), val1);
|
||||||
check_addrmap_find (*map, array, 0, 9, nullptr);
|
check_addrmap_find (map, array, 0, 9, nullptr);
|
||||||
check_addrmap_find (*map, array, 10, 12, val1);
|
check_addrmap_find (map, array, 10, 12, val1);
|
||||||
check_addrmap_find (*map, array, 13, 19, nullptr);
|
check_addrmap_find (map, array, 13, 19, nullptr);
|
||||||
|
|
||||||
/* Create corresponding fixed addrmap. */
|
/* Create corresponding fixed addrmap. */
|
||||||
addrmap_fixed *map2
|
addrmap_fixed *map2
|
||||||
= new (&temp_obstack) addrmap_fixed (&temp_obstack, map.get ());
|
= new (&temp_obstack) addrmap_fixed (&temp_obstack, &map);
|
||||||
SELF_CHECK (map2 != nullptr);
|
SELF_CHECK (map2 != nullptr);
|
||||||
check_addrmap_find (*map2, array, 0, 9, nullptr);
|
check_addrmap_find (*map2, array, 0, 9, nullptr);
|
||||||
check_addrmap_find (*map2, array, 10, 12, val1);
|
check_addrmap_find (*map2, array, 10, 12, val1);
|
||||||
@@ -460,7 +459,7 @@ test_addrmap ()
|
|||||||
SELF_CHECK (false);
|
SELF_CHECK (false);
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
SELF_CHECK (map->foreach (callback) == 0);
|
SELF_CHECK (map.foreach (callback) == 0);
|
||||||
SELF_CHECK (map2->foreach (callback) == 0);
|
SELF_CHECK (map2->foreach (callback) == 0);
|
||||||
|
|
||||||
/* Relocate fixed addrmap. */
|
/* Relocate fixed addrmap. */
|
||||||
@@ -470,11 +469,11 @@ test_addrmap ()
|
|||||||
check_addrmap_find (*map2, array, 14, 19, nullptr);
|
check_addrmap_find (*map2, array, 14, 19, nullptr);
|
||||||
|
|
||||||
/* Insert partially overlapping address range into mutable addrmap. */
|
/* Insert partially overlapping address range into mutable addrmap. */
|
||||||
map->set_empty (core_addr (&array[11]), core_addr (&array[13]), val2);
|
map.set_empty (core_addr (&array[11]), core_addr (&array[13]), val2);
|
||||||
check_addrmap_find (*map, array, 0, 9, nullptr);
|
check_addrmap_find (map, array, 0, 9, nullptr);
|
||||||
check_addrmap_find (*map, array, 10, 12, val1);
|
check_addrmap_find (map, array, 10, 12, val1);
|
||||||
check_addrmap_find (*map, array, 13, 13, val2);
|
check_addrmap_find (map, array, 13, 13, val2);
|
||||||
check_addrmap_find (*map, array, 14, 19, nullptr);
|
check_addrmap_find (map, array, 14, 19, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace selftests */
|
} /* namespace selftests */
|
||||||
|
|||||||
Reference in New Issue
Block a user