summaryrefslogtreecommitdiff
path: root/view/sharedcache/core/SharedCache.h
diff options
context:
space:
mode:
authorMark Rowe <mrowe@bdash.net.nz>2025-02-19 18:48:50 -0800
committerMason Reed <mason@vector35.com>2025-04-02 05:36:54 -0400
commit721d24be648eccae72fe97f89f0fbd18de36af8a (patch)
treedf60eb436a7af5d5a19aaf37645e1456636ae5af /view/sharedcache/core/SharedCache.h
parentc67eecce0d87c3738c9a133e3d2f502ce28f37dd (diff)
[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`.
Diffstat (limited to 'view/sharedcache/core/SharedCache.h')
-rw-r--r--view/sharedcache/core/SharedCache.h7
1 files changed, 7 insertions, 0 deletions
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;
}
};