From 721d24be648eccae72fe97f89f0fbd18de36af8a Mon Sep 17 00:00:00 2001 From: Mark Rowe Date: Wed, 19 Feb 2025 18:48:50 -0800 Subject: [SharedCache] Make it faster to look up which image contains an address `MemoryRegion` now tracks the start address of the image to which it belongs. `SharedCache::HeaderForAddress` uses the existing address range map to quickly find the `MemoryRegion` for a given address, and from there can look up the image via its start address. Some extra logic is added to `CacheInfo::Load` to populate the image start address on `MemoryRegion` when loading from metadata that predates this change. The result is that `HeaderForAddress` is no longer the most expensive part of `FindSymbolAtAddrAndApplyToAddr`. --- view/sharedcache/core/SharedCache.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'view/sharedcache/core/SharedCache.h') diff --git a/view/sharedcache/core/SharedCache.h b/view/sharedcache/core/SharedCache.h index 97da0880..d696154c 100644 --- a/view/sharedcache/core/SharedCache.h +++ b/view/sharedcache/core/SharedCache.h @@ -41,6 +41,9 @@ namespace SharedCacheCore { std::string prettyName; uint64_t start; uint64_t size; + // Start address of the image this region belongs to. + // 0 if the region does not belong to any image. + uint64_t imageStart = 0; BNSegmentFlag flags; Type type; @@ -55,6 +58,7 @@ namespace SharedCacheCore { MSS(prettyName); MSS(start); MSS(size); + MSS(imageStart); MSS_CAST(flags, uint64_t); MSS_CAST(type, uint8_t); } @@ -67,6 +71,9 @@ namespace SharedCacheCore { region.MSL(size); region.MSL_CAST(flags, uint64_t, BNSegmentFlag); region.MSL_CAST(type, uint8_t, Type); + if (context.doc.HasMember("imageStart")) + region.MSL(imageStart); + return region; } }; -- cgit v1.3.1