Skip to content

Conversation

@augusto2112
Copy link
Contributor

@augusto2112 augusto2112 commented Dec 8, 2025

Explanation: If the MemoryReader can provide a symbol for the context descriptor, use that instead of building the mangle tree from metadata. This shouldn't hurt other clients, and would have a few benefits for LLDB:

  • Small but numerous memory reads can be expensive for LLDB, building the mangle tree from a string should be much faster.

  • For types with private discriminators, this allows LLDB to provide the same private discriminator that's in DWARF and in the swiftmodule (as opposed to using the memory address where the context descriptor lives at). This means that these private types would have the same mangled name in every run. LLDB persistently caches field descriptors by name, but since private discriminators aren't guaranteed to have the same mangled name over multiple runs, LLDB would often need to invalidate its entire cache and rebuild it. Using the stable UUID would solve that issue.
    Scope: This affects RemoteInspection clients that override resolvePointerAsSymbol, which effectively is just LLDB.
    Risk: Low, this only affects LLDB, and the existing code validates that the symbol LLDB provides is valid.
    Problem: rdar://165950673
    Original PR: [RemoteInspection] Read ContextDescriptor from symbol if available #85878 and [RemoteInspection] Factor out buildContextDescriptorManglingForSymbol #85911

@augusto2112 augusto2112 requested a review from a team as a code owner December 8, 2025 19:17
@augusto2112
Copy link
Contributor Author

If the MemoryReader can provide a symbol for the context descriptor, use
that instead of building the mangle tree from metadata. This shouldn't
hurt other clients, and would have a few benefits for LLDB:

- Small but numerous memory reads can be expensive for LLDB, building
  the mangle tree from a string should be much faster.

- For types with private discriminators, this allows LLDB to provide the
  same private discriminator that's in DWARF and in the swiftmodule (as
  opposed to using the memory address where the context descriptor lives
  at). This means that these private types would have the same mangled
  name in every run. LLDB persistently caches field descriptors by name,
  but since private discriminators aren't guaranteed to have the same
  mangled name over multiple runs, LLDB would often need to invalidate
  its entire cache and rebuild it. Using the stable UUID would solve
  that issue.

rdar://165950673
(cherry picked from commit e3c67c9)
A previous commit introduced the usage of buildContextManglingForSymbol
in buildContextDescriptorMangling, which was not quite correct, since
type nodes needed extra handling, which was done in the other version of
buildContextDescriptorMangling. This patch factors out the handling of
building context descriptors mangling from symbols, and updates both
call sites to use the new function instead.

rdar://165950673
(cherry picked from commit ab507be)
@augusto2112
Copy link
Contributor Author

@augusto2112 augusto2112 changed the title [RemoteInspection] Read ContextDescriptor from symbol if available [RemoteInspection] Read ContextDescriptor from symbol if available and [RemoteInspection] Factor out buildContextDescriptorManglingForSymbol Dec 9, 2025
@augusto2112 augusto2112 changed the title [RemoteInspection] Read ContextDescriptor from symbol if available and [RemoteInspection] Factor out buildContextDescriptorManglingForSymbol "[RemoteInspection] Read ContextDescriptor from symbol if available" and "[RemoteInspection] Factor out buildContextDescriptorManglingForSymbol" Dec 9, 2025
@augusto2112
Copy link
Contributor Author

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