Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
a272583
test: keep the projected opaque member fixture building on Xcode 27
Mx-Iris Sep 26, 2026
2a398f8
build(deps): raise the MachOKitExtensions floor to 0.1.2
Mx-Iris Sep 26, 2026
5a916b7
Merge branch 'fix/image-cache-membership' into next
Mx-Iris Sep 26, 2026
3b6672e
Merge remote-tracking branch 'origin/main' into merge/main-into-next
Mx-Iris Sep 27, 2026
28c0e6c
feat: print @objc(Name) on classes renamed for the ObjC runtime
Mx-Iris Sep 27, 2026
a951036
test: pin renamed-class recovery with an on-the-fly fixture
Mx-Iris Sep 27, 2026
b521c33
docs: document renamed-class recovery (evolution objc-custom-class-name)
Mx-Iris Sep 27, 2026
1791515
docs: add evolution proposal draft-shared-cache-composition-and-evict…
Mx-Iris Sep 28, 2026
c1508c9
fix(MachOCaches): trap on same-thread re-entrant builds instead of ha…
Mx-Iris Sep 28, 2026
cecf914
perf(MachOCaches): key cache entries on SharedCacheKey instead of a b…
Mx-Iris Sep 28, 2026
f07d238
refactor(MachOCaches): compose SharedCache instead of subclassing it
Mx-Iris Sep 28, 2026
3842897
refactor(MachOCaches): move per-image eviction into SharedCacheRegist…
Mx-Iris Sep 28, 2026
deec176
test(MachOCaches): prove distinct-key overlap with two builds, not eight
Mx-Iris Sep 28, 2026
d4b4d29
docs: document the per-image cache primitive and its eviction registry
Mx-Iris Sep 28, 2026
8e2aea7
refactor(MachOCaches): make SharedCacheEvictionGroup an open type dec…
Mx-Iris Sep 28, 2026
30bf459
test(MachOCaches): run the distinct-key rendezvous on dedicated threads
Mx-Iris Sep 28, 2026
500f3cc
fix(printing): read initializer failability off the initializer's own…
Mx-Iris Sep 28, 2026
15313ae
feat(interface): build class vtable members from their method descrip…
Mx-Iris Sep 28, 2026
04f3d73
chore(scripts): point the rendering A/B harness at the 26.6.2 archive…
Mx-Iris Sep 28, 2026
284b39b
docs: document descriptor-only vtable members (evolution interface-de…
Mx-Iris Sep 28, 2026
c5433fc
build(deps): raise the swift-capstone floor to 6.0.1
Mx-Iris Sep 28, 2026
05eb8f5
docs: record the local-type context names gap as a roadmap item
Mx-Iris Sep 28, 2026
e9ad5bb
docs: drop a duplicated 0050 decision row and fix a stale proposal link
Mx-Iris Sep 28, 2026
ac9da4c
Merge remote-tracking branch 'origin/feature/shared-cache-composition…
Mx-Iris Sep 28, 2026
1437925
Merge remote-tracking branch 'origin/feature/interface-vtable-members…
Mx-Iris Sep 28, 2026
8fb9deb
docs: number the three landed proposals for 0.21.0
Mx-Iris Sep 29, 2026
3303cbf
release: 0.21.0
Mx-Iris Sep 29, 2026
8de6062
Merge branch 'release/0.21.0' into next
Mx-Iris Sep 29, 2026
f1a2e2a
test(MachOCaches): stop three SharedCache tests from freezing a 3-thr…
Mx-Iris Sep 29, 2026
5e14663
ci: re-run the SharedCache suites on a one-thread pool; time the job out
Mx-Iris Sep 29, 2026
a8dba48
docs: record the 3-core CI stall and the cooperative-thread rule for …
Mx-Iris Sep 29, 2026
389b4a5
Merge branch 'fix/shared-cache-tests-cooperative-pool-starvation' int…
Mx-Iris Sep 29, 2026
f46850b
test(SwiftSpecialization): mark the candidate-path metadata identity …
Mx-Iris Sep 29, 2026
5552b07
Merge branch 'test/specializer-candidate-path-known-issue' into next
Mx-Iris Sep 29, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion .github/workflows/macOS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ jobs:
macos_test:
name: Execute tests on macOS
runs-on: ${{ matrix.os }}
# A healthy job takes 8-26 minutes. Without a limit a stalled test run
# sits until GitHub's 360-minute default (it did on 2026-09-29).
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -117,4 +120,26 @@ jobs:
-c ${{ matrix.configuration }} \
--enable-experimental-prebuilts \
--build-path .build-test-${{ matrix.configuration }} \
--filter '\.(SymbolTestsCoreDumpSnapshotTests|SymbolTestsCoreInterfaceSnapshotTests|SymbolTestsCoreCoverageInvariantTests|STCoreE2ETests|STCoreTests|GenericSpecializationTests|MultiPayloadEnumTests|SymbolicDemanglerDemanglingTests|MalformedSymbolValueTests|ContinuousIntegrationTestFilterTests|DependencyLoadNameTests|DependencyClosureTests|FileDependencyLocatorTests|SwiftInterfaceBuilderDependenciesTests|ManglingPrefixTests|MethodDescriptorTests|MethodOverrideDescriptorTests|MethodDefaultOverrideDescriptorTests|ProtocolRequirementTests|ResilientWitnessTests|LargeStackTaskExecutionTests|BoundedConcurrentMapTests|SwiftEvolutionInterfaceBuilderTests|EvolutionCommandValidationTests|DiffCommandValidationTests|ObjCSectionCommandTests|ObjCAPICommandParsingTests|ObjCDumpDiagnosticsTests)(/|$)'
--filter '\.(SymbolTestsCoreDumpSnapshotTests|SymbolTestsCoreInterfaceSnapshotTests|SymbolTestsCoreCoverageInvariantTests|STCoreE2ETests|STCoreTests|GenericSpecializationTests|MultiPayloadEnumTests|SymbolicDemanglerDemanglingTests|MalformedSymbolValueTests|ContinuousIntegrationTestFilterTests|MachOImageCacheMembershipTests|SharedCacheResolveTests|SharedCacheResolveSwiftConcurrencyTests|SharedCacheKeyTests|SharedCacheRegistryTests|DependencyLoadNameTests|DependencyClosureTests|FileDependencyLocatorTests|SwiftInterfaceBuilderDependenciesTests|ManglingPrefixTests|MethodDescriptorTests|MethodOverrideDescriptorTests|MethodDefaultOverrideDescriptorTests|ProtocolRequirementTests|ResilientWitnessTests|LargeStackTaskExecutionTests|BoundedConcurrentMapTests|SwiftEvolutionInterfaceBuilderTests|EvolutionCommandValidationTests|DiffCommandValidationTests|ObjCSectionCommandTests|ObjCAPICommandParsingTests|ObjCDumpDiagnosticsTests)(/|$)'

- name: Run the SharedCache suites on a one-thread cooperative pool (${{ matrix.configuration }})
# The runner has 3 cores, so the Swift Concurrency cooperative pool is
# 3 threads wide. On 2026-09-29 three tests each blocked one of those
# threads waiting for work that itself needed a thread, and the whole
# test process froze. With the pool forced down to one thread, a test
# that blocks a pool thread on such work hangs here on every run —
# rather than only when three of them happen to line up — and the
# step timeout turns the hang into a failure. The two
# `differentKeysParallelVia…` tests are skipped: they prove overlap,
# which needs two pool threads by design.
timeout-minutes: 5
env:
LIBDISPATCH_COOPERATIVE_POOL_STRICT: 1
run: |
swift test \
-c ${{ matrix.configuration }} \
--skip-build \
--enable-experimental-prebuilts \
--build-path .build-test-${{ matrix.configuration }} \
--filter '\.(SharedCacheResolveTests|SharedCacheResolveSwiftConcurrencyTests)/' \
--skip 'differentKeysParallelVia'
18 changes: 15 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ One or two lines each; the linked document is the authority.

- **Demangling** (upstream package) — mangled symbol → `Node` AST → printed Swift, plus the remangler. `Node.Kind` covers ~200 mangling node kinds.
- **MachOSwiftSection** — the ABI model: the `__swift5_*` sections, every descriptor shape in them, and Swift's position-independent relative pointers. Self-contained — `MachOBase` only, no symbol index, no demangler; a descriptor exposes an implementation's *offset* and `SwiftInspection` attributes the name ([SelfContainedABILayer.md](Documentations/Internal/SelfContainedABILayer.md)).
- **SwiftInspection** — runtime metadata analysis, and where ABI-layer symbol attribution lives: `SymbolicDemangler` (names carrying symbolic references; also demanglings built straight from descriptors), `SymbolicManglingIndex` (each symbolic reference in the mangled names the image's `_symbolic` symbols name, paired with the referent the compiler spelled for it — where a system image's private discriminators come from; [SymbolicManglingSymbols.md](Documentations/Internal/SymbolicManglingSymbols.md)), `RuntimeMetadataTypeBuilder` (node → live metadata), `EnumLayoutCalculator` + `RuntimeEnumCaseProjector`, `ClassHierarchyDumper`, `ObjCImplementationClassIndex` (SE-0436 `@objc @implementation` classes, recognized from `__objc_classlist` joined with the symbol table — [ObjCImplementationClassRecognition.md](Documentations/Internal/ObjCImplementationClassRecognition.md)), `ObjCClassHierarchy` + `ObjCClassHierarchyProviding` / `ObjCClassHierarchyProviderStore` (the per-image seam through which a host hands over the ObjC class hierarchies it already indexed — RuntimeViewer's indexer, or `SwiftIndexing`'s adapter over `ObjCIndexing.ObjCInterfaceIndexer`) with `ObjCClassMethodIndex` as the library's own lazy reader behind it (class, metaclass and same-image category method lists, the ancestor chain, the adopted protocols' selectors) and `ObjCAncestorResolver` / `ObjCAncestorResolverStore` following a standalone file's bound superclass or category target by name into its dependency closure (export trie first, then the class list; the indexer and `dump` register one per image over the configured search paths, an unregistered file defaults to the system cache, an in-process image needs none — so a file's chain reaches libobjc's `NSObject` like a cache image's does), `ObjCMember` / `ObjCMemberTable` (the per-class ObjC member table: every method-table entry tied to its Swift member — the `@objc`, `override` and explicit-selector facts in one place) and `ObjCMemberShape` (a member's selector shape: the importer's naming rules applied as a forward CHECK, and the compiler's own selector derivation ported for the explicit-selector verdict) — [ObjCMemberRecovery.md](Documentations/Internal/ObjCMemberRecovery.md).
- **SwiftInspection** — runtime metadata analysis, and where ABI-layer symbol attribution lives: `SymbolicDemangler` (names carrying symbolic references; also demanglings built straight from descriptors), `SymbolicManglingIndex` (each symbolic reference in the mangled names the image's `_symbolic` symbols name, paired with the referent the compiler spelled for it — where a system image's private discriminators come from; [SymbolicManglingSymbols.md](Documentations/Internal/SymbolicManglingSymbols.md)), `RuntimeMetadataTypeBuilder` (node → live metadata), `EnumLayoutCalculator` + `RuntimeEnumCaseProjector`, `ClassHierarchyDumper`, `ObjCImplementationClassIndex` (SE-0436 `@objc @implementation` classes, recognized from `__objc_classlist` joined with the symbol table — [ObjCImplementationClassRecognition.md](Documentations/Internal/ObjCImplementationClassRecognition.md)), `SwiftClassObjectIndex` (the Swift classes a source renamed for the ObjC runtime — `@objc(NSScrollPocket)` — joined to their descriptor through the class metadata, since their runtime name demangles to nothing; every name-keyed ObjC-side lookup of a Swift class falls back to it on a miss — [CustomObjCClassNames.md](Documentations/Internal/CustomObjCClassNames.md)), `ObjCClassHierarchy` + `ObjCClassHierarchyProviding` / `ObjCClassHierarchyProviderStore` (the per-image seam through which a host hands over the ObjC class hierarchies it already indexed — RuntimeViewer's indexer, or `SwiftIndexing`'s adapter over `ObjCIndexing.ObjCInterfaceIndexer`) with `ObjCClassMethodIndex` as the library's own lazy reader behind it (class, metaclass and same-image category method lists, the ancestor chain, the adopted protocols' selectors) and `ObjCAncestorResolver` / `ObjCAncestorResolverStore` following a standalone file's bound superclass or category target by name into its dependency closure (export trie first, then the class list; the indexer and `dump` register one per image over the configured search paths, an unregistered file defaults to the system cache, an in-process image needs none — so a file's chain reaches libobjc's `NSObject` like a cache image's does), `ObjCMember` / `ObjCMemberTable` (the per-class ObjC member table: every method-table entry tied to its Swift member — the `@objc`, `override` and explicit-selector facts in one place) and `ObjCMemberShape` (a member's selector shape: the importer's naming rules applied as a forward CHECK, and the compiler's own selector derivation ported for the explicit-selector verdict) — [ObjCMemberRecovery.md](Documentations/Internal/ObjCMemberRecovery.md).
- **SwiftDump** — high-level wrappers (`Struct`, `Enum`, `Class`, `Protocol`, `ProtocolConformance`, `AssociatedType`, `ObjCImplementationClass`) and the `dump` output path.
- **SwiftDeclaration** — the shared declaration model every higher module reads and writes, plus the `SwiftIndexEvents` namespace. [Modules/SwiftDeclaration.md](Documentations/Internal/Modules/SwiftDeclaration.md).
- **SwiftDeclarationRendering** — the comment engine shared by dump and interface (`FieldLayoutRenderer`, opaque-type rewriting, specialized-metadata substitution), reader-specialized: live metadata in-process, SwiftLayout offline ([FieldLayoutRendererReaderSpecialization.md](Documentations/Internal/FieldLayoutRendererReaderSpecialization.md)).
Expand All @@ -64,9 +64,9 @@ One or two lines each; the linked document is the authority.
- **MachOReading / MachOResolving** — reading abstractions; address/offset resolution. `MachOResolving` also holds the symbol *value* types (`Symbol`, `Symbols`, `SymbolOrElement`), which carry no lookup behavior — "the symbols at this offset" is a query, not a read.
- **MachOPointers** — relative and indirect pointer types, plus `SymbolOrElementPointer`.
- **MachOSymbols** — the symbol *index*: table parsing, demangling, the per-image node stores, and `LargeStackTaskExecution`; also collects the image's `_symbolic` symbols into a table of their own that no offset or name query sees (`symbolicManglingSymbols(in:)`). [Modules/MachOSymbols.md](Documentations/Internal/Modules/MachOSymbols.md).
- **MachOCaches** — dyld shared cache support.
- **MachOCaches** — the per-image cache primitive, NOT dyld shared cache support (that is `MachOKitExtensions` and `MachODependencies`): `SharedCache` (get-or-build per image, one build shared by concurrent callers, the build closure supplied at the call site), `SharedCacheKey` (hashes a file on its UUID alone) and `SharedCacheRegistry` + `SharedCacheEvictionGroup` (which caches an indexer claims for an image and what its last live instance evicts). [Modules/MachOCaches.md](Documentations/Internal/Modules/MachOCaches.md).
- **MachODependencies** — the one dependency-resolution implementation every feature shares (`DependencyClosure`, the in-process and file locators, `DependencySearchPath`, `SharedDependencyClosure` for consumers of one root that resolve lazily). The file locator filters dyld-cache candidates by platform (`DependencyPlatforms`, from `LC_BUILD_VERSION`): the host's macOS cache is every root's default search path and carries Mac Catalyst UIKit / SwiftUI under `/System/iOSSupport`, which an iOS root used to resolve to by bare name. [Modules/MachODependencies.md](Documentations/Internal/Modules/MachODependencies.md).
- **MachOKitExtensions** (external sibling, `../MachOKitExtensions`) — MachOKit extensions. Two behaviors this repo's tests still pin live there: legacy `LC_DYLD_INFO` bind resolution (`LegacyDyldInfoBindTests`) and ranked dyld-cache image name lookup (`DyldCacheImageSearchTests`). It cannot move back in-repo — `MachOObjCSection` depends on it, which would make a package-level cycle.
- **MachOKitExtensions** (external sibling, `../MachOKitExtensions`) — MachOKit extensions. Three behaviors this repo's tests still pin live there: legacy `LC_DYLD_INFO` bind resolution (`LegacyDyldInfoBindTests`), ranked dyld-cache image name lookup (`DyldCacheImageSearchTests`), and whether an in-process image is in the shared cache — read from its header flag, never from its load address (`MachOImageCacheMembershipTests`). It cannot move back in-repo — `MachOObjCSection` depends on it, which would make a package-level cycle.

Printing and indexing are peers; neither depends on the other.

Expand Down Expand Up @@ -133,6 +133,7 @@ python3 Scripts/test-run-rendering-ab-verification.py
<important if="you are writing or modifying tests">

- Swift Testing runs test bodies on **512 KB cooperative threads**. A test calling a library entry point gets the large-stack executor from that entry's own `LargeStackTaskExecution.run`; a test driving the demangler or printer *directly* in deep recursion does not — wrap such a body in `LargeStackTaskExecution.run` when the hop cost or the 8 MB pool depth is what is being measured. "The suite passed" is not evidence the executor was used.
- **Never block a cooperative thread with an untimed wait on work that itself needs a pool thread** — a `DispatchQueue.global()` block, a `Task`. The CI runner has 3 cores, so the pool is 3 threads wide: on 2026-09-29 three such tests froze the whole test process there, while a 10-core machine never lines three up. Give the counterpart a `Thread { … }.start()` of its own, or run the blocking side on one. CI re-runs the `SharedCache` suites on a one-thread pool (`LIBDISPATCH_COOPERATIVE_POOL_STRICT=1`) to catch this; a new suite that blocks on purpose belongs in that step. [FixtureTestingAndContinuousIntegration.md](Documentations/Internal/FixtureTestingAndContinuousIntegration.md).
- **A suite asserting on whole-process state derived from an image must declare `ExclusiveImageAccess(.TheFixture)` — and so must every other suite touching that image.** A one-sided declaration excludes nothing. `.serialized` does not work (it orders within one container only, and `swift test` links everything into one process) and neither does a global actor (these tests are `async`, and `await` yields the actor). Do not assert exclusivity in a doc comment: `grep ExclusiveImageAccess` finds every declared user, grepping a fixture name does not.
- **A `swift test` process never enforces pointer authentication, even built and reported as arm64e** — auth fixups are strip-applied there, so signed slots read back bare. Any "verified because the suite passed as arm64e" claim is a placebo; verify by spawning a real arm64e child process, as `Arm64eSignedVWTPointerTests` does.
- **`SymbolTestsCore` must not enable the CoroutineAccessors feature** — it would move every implementation offset the ABI baselines pin. A suite needing a `…Twc` compiles its own fixture and asserts structurally.
Expand Down Expand Up @@ -197,6 +198,17 @@ Detail: [Modules/MachOSymbols.md](Documentations/Internal/Modules/MachOSymbols.m

</important>

<important if="you are adding a per-image cache, evicting one, or handling memory pressure">

- **Every per-image cache is a `SharedCache` with a `SharedCacheEvictionGroup`, held by composition** — never a hand-written lock plus `[key: value]` dictionary, never a subclass. The build closure goes at the call site; re-type the reader once through `swiftSectionReader` / `objcImplementationClassReader` (SwiftInspection) instead of an `as? MachOFile` / `as? MachOImage` split.
- **A build closure must not query the entry it is building.** On the builder's own thread that traps with the key; after a thread hop (`withLargeStack`) it hangs, undetected.
- **Eviction belongs to the registry**: the indexer claims what its `prepare()` found absent and its last live instance evicts it plus every group that `follows` it. `MachOCaches` declares no group: a module declares its own in a `SharedCacheEvictionGroup+<Module>.swift` extension, and a cache whose entries point into another group's storage says `follows:` at creation. The three `removeCache` helpers are the explicit form and forward to `SharedCacheRegistry.evict(groups:for:)`.
- **The library never reacts to memory pressure.** The per-instance monitors that used to `removeAll()` bypassed the ownership rules and freed nothing (live `NodeReference`s pin the storage). A host sheds state by calling `SharedCacheRegistry.shared.evictImagesWithoutLiveOwners()`.

[Modules/MachOCaches.md](Documentations/Internal/Modules/MachOCaches.md).

</important>

<important if="you are reading offsets in an image inside a dyld shared cache">

Every offset in `MachOSwiftSection` is `unslidVirtualAddress - sharedRegionStart`, **not a file offset**. Three other accountings coexist and mixing them fails silently — `adrp` computes its page base from the instruction's own address, so a sub-page error still yields a computable, plausible-looking address pointing into a neighbouring image:
Expand Down
2 changes: 1 addition & 1 deletion AgentPlugins/swift-section/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "swift-section",
"version": "0.20.0",
"version": "0.21.0",
"description": "Teaches coding agents to drive the swift-section CLI: Swift and Objective-C declarations, memory layout and ABI diffs recovered from a Mach-O binary or a dyld shared cache.",
"author": {
"name": "MxIris-Reverse-Engineering",
Expand Down
2 changes: 1 addition & 1 deletion AgentPlugins/swift-section/.codex-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "swift-section",
"version": "0.20.0",
"version": "0.21.0",
"description": "Teaches coding agents to drive the swift-section CLI: Swift and Objective-C declarations, memory layout and ABI diffs recovered from a Mach-O binary or a dyld shared cache.",
"author": {
"name": "MxIris-Reverse-Engineering",
Expand Down
Loading
Loading