Skip to content

Conversation

adrian-prantl
Copy link
Contributor

This patch adds parsing and extracting of the Swift reflection metadata data segments from within the WebAssembly DATA section and tests it using swift-reflection-dump. This is needed to allow LLDB to acces Swift reflection metadata when attached to WebAssembly processes.

rdar://159217213

@adrian-prantl
Copy link
Contributor Author

@swift-ci test

Copy link
Contributor

@mikeash mikeash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know the WASM stuff but it looks OK. I did find some things to bikeshed on the Swift side.

Copy link
Contributor

@JDevlieghere JDevlieghere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a few more missing return types, but otherwise this LGTM.

@adrian-prantl adrian-prantl force-pushed the wasm-reflection branch 2 times, most recently from f247e52 to 69a2f4b Compare August 26, 2025 21:55
};

/// Decode 32-bit ULEB constants.
auto decodeULEB32 = [&](uint32_t &val) -> bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunate that we have to reimplement these for the umpteenth time. Is there no code object format parsing code in LLVM to reuse here?

Copy link
Contributor

@MaxDesiatov MaxDesiatov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM modulo Wasm binary format parsing ad-hoc reimplementation. I wish we had one source of truth for this and I'm surprised LLVM doesn't seem to provide reusable (or flexible enough) API for this?

@adrian-prantl
Copy link
Contributor Author

LGTM modulo Wasm binary format parsing ad-hoc reimplementation. I wish we had one source of truth for this and I'm surprised LLVM doesn't seem to provide reusable (or flexible enough) API for this?

It has, but the problem here is twofold:

  • ReflectionContext.h also runs in-process as part of the Swift Runtime, which only has access to an extremely limited subset of the the LLVM Support libraries, and it doesn't include libObject.
  • The parser needs to be implemented on top of the MemoryReader API.

@adrian-prantl
Copy link
Contributor Author

@swift-ci test

This patch adds parsing and extracting of the Swift reflection
metadata data segments from within the WebAssembly DATA section and
tests it using swift-reflection-dump. This is needed to allow LLDB to
acces Swift reflection metadata when attached to WebAssembly
processes.

rdar://159217213
@adrian-prantl
Copy link
Contributor Author

@swift-ci test

@adrian-prantl adrian-prantl merged commit d33f478 into swiftlang:rebranch Aug 28, 2025
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants