Skip to content

Add DyldCache.locateValue for cache hierarchy lookup - #297

Open
p-x9 wants to merge 1 commit into
mainfrom
feature/dyld-cache-locate-value
Open

Add DyldCache.locateValue for cache hierarchy lookup#297
p-x9 wants to merge 1 commit into
mainfrom
feature/dyld-cache-locate-value

Conversation

@p-x9

@p-x9 p-x9 commented Jun 24, 2026

Copy link
Copy Markdown
Owner

Summary

  • Introduce DyldCache.locateValue(_:) (@_spi(Support) public) that resolves a value by walking the receiver → mainCache → main cache's subcaches in order, deduplicating by header UUID.
  • Two overloads: a KeyPath<DyldCache, Value?> form for plain optional properties and a rethrows closure form for throwing / computed lookups (e.g. symbolCache).
  • Returns a LocatedValue<Value> struct pairing the resolved value with the cache that produced it — needed because offsets inside the value must be interpreted against that cache.

Notes

  • @inline(__always) is applied to the thin KeyPath overload and the private _resolve helper so the resolver closure specializes; the closure-form body itself is left as-is since cost is dominated by subcache(for:) I/O.
  • Exposed under @_spi(Support) for now to keep flexibility before committing to a fully public API. Symmetric variants on DyldCacheLoaded / FullDyldCache are intentionally deferred.
  • Subcache opening can incur file I/O; doc comment recommends caching the resulting LocatedValue when looking up repeatedly.

Test plan

  • swift build
  • Spot-check via existing DyldCachePrintTests against a local dyld cache (optional, follow-up)

Introduce `@_spi(Support)` helpers that resolve a value across the
receiver, its `mainCache`, and the main cache's subcaches in order,
deduplicating by header UUID. Provides both a KeyPath overload for
non-throwing optional properties and a `rethrows` closure overload for
throwing or computed lookups (e.g. `symbolCache`). Returns a
`LocatedValue<Value>` that pairs the resolved value with the cache it
came from, since offsets contained in the value must be interpreted
against that cache.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant