Handle image map names that end with ]
The map name ends with ] if it's an anonymous memmap. Add handling
to recognize this.
Test: adb shell imgdiag --zygote-diff-pid=$(pid zygote64) --image-diff-pid=$(pid system_server) --boot-image=/system/framework/boot.art
Bug: 140399904
Change-Id: I45da1e7868e7789d9bbe1f63d595e449be07c2f7
diff --git a/imgdiag/imgdiag.cc b/imgdiag/imgdiag.cc
index 6ee3157..4424209 100644
--- a/imgdiag/imgdiag.cc
+++ b/imgdiag/imgdiag.cc
@@ -1442,7 +1442,10 @@
-> std::optional<backtrace_map_t> {
// Find the memory map for the current boot image component.
for (const backtrace_map_t* map : maps) {
- if (EndsWith(map->name, image_location_base_name)) {
+ // The map name ends with ']' if it's an anonymous memmap. We need to special case that
+ // to find the boot image map in some cases.
+ if (EndsWith(map->name, image_location_base_name) ||
+ EndsWith(map->name, image_location_base_name + "]")) {
if ((map->flags & PROT_WRITE) != 0) {
return *map;
}