Skip to content

Commit ad09919

Browse files
mikeashairspeedswift
authored andcommitted
[Runtime] Expose the protocol conformance state as a _swift_debug variable.
Have Remote Mirror look that up instead of the C++ mangled name. rdar://problem/55481578
1 parent b73b325 commit ad09919

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

include/swift/Reflection/ReflectionContext.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -818,12 +818,20 @@ class ReflectionContext
818818

819819
llvm::Optional<std::string> iterateConformances(
820820
std::function<void(StoredPointer Type, StoredPointer Proto)> Call) {
821-
std::string ConformancesName = "__ZL12Conformances";
822-
auto ConformancesAddr = getReader().getSymbolAddress(ConformancesName);
821+
std::string ConformancesPointerName =
822+
"__swift_debug_protocolConformanceStatePointer";
823+
auto ConformancesAddrAddr =
824+
getReader().getSymbolAddress(ConformancesPointerName);
825+
if (!ConformancesAddrAddr)
826+
return "unable to look up debug variable " + ConformancesPointerName;
827+
828+
auto ConformancesAddr =
829+
getReader().readPointer(ConformancesAddrAddr, sizeof(StoredPointer));
823830
if (!ConformancesAddr)
824-
return "unable to look up conformances cache symbol " + ConformancesName;
831+
return "unable to read value of " + ConformancesPointerName;
825832

826-
auto Root = getReader().readPointer(ConformancesAddr, sizeof(StoredPointer));
833+
auto Root = getReader().readPointer(ConformancesAddr->getResolvedAddress(),
834+
sizeof(StoredPointer));
827835
iterateConformanceTree(Root->getResolvedAddress().getAddressData(), Call);
828836
return llvm::None;
829837
}

include/swift/Runtime/Debug.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,9 @@ bool _swift_debug_metadataAllocationIterationEnabled;
237237
SWIFT_RUNTIME_STDLIB_SPI
238238
const void * const _swift_debug_allocationPoolPointer;
239239

240+
SWIFT_RUNTIME_STDLIB_SPI
241+
const void * const _swift_debug_protocolConformanceStatePointer;
242+
240243
SWIFT_RUNTIME_ATTRIBUTE_ALWAYS_INLINE
241244
inline static int swift_asprintf(char **strp, const char *fmt, ...) {
242245
va_list args;

stdlib/public/runtime/ProtocolConformance.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,9 @@ void ConformanceState::verify() const {
315315

316316
static Lazy<ConformanceState> Conformances;
317317

318+
const void * const swift::_swift_debug_protocolConformanceStatePointer =
319+
&Conformances;
320+
318321
static void
319322
_registerProtocolConformances(ConformanceState &C,
320323
const ProtocolConformanceRecord *begin,

0 commit comments

Comments
 (0)