Skip to content

Commit fb1eead

Browse files
authored
Stub out symbolication on platforms without dynamic linking/loading. (#758)
For instance, WASI doesn't have symbolication, so this code is dead there. ### Checklist: - [x] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [x] If public symbols are renamed or modified, DocC references should be updated.
1 parent 0f37af2 commit fb1eead

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Sources/Testing/SourceAttribution/Backtrace+Symbolication.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ extension Backtrace {
6161
public func symbolicate(_ mode: SymbolicationMode) -> [SymbolicatedAddress] {
6262
var result = addresses.map { SymbolicatedAddress(address: $0) }
6363

64+
#if !SWT_NO_DYNAMIC_LINKING
6465
#if SWT_TARGET_OS_APPLE
6566
for (i, address) in addresses.enumerated() {
6667
var info = Dl_info()
@@ -94,8 +95,6 @@ extension Backtrace {
9495
}
9596
}
9697
}
97-
#elseif os(WASI)
98-
// WASI does not currently support backtracing let alone symbolication.
9998
#else
10099
#warning("Platform-specific implementation missing: backtrace symbolication unavailable")
101100
#endif
@@ -109,6 +108,7 @@ extension Backtrace {
109108
return symbolicatedAddress
110109
}
111110
}
111+
#endif
112112

113113
return result
114114
}

Tests/TestingTests/BacktraceTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ struct BacktraceTests {
150150
}
151151
#endif
152152

153+
#if !SWT_NO_DYNAMIC_LINKING
153154
@Test("Symbolication", arguments: [Backtrace.SymbolicationMode.mangled, .demangled])
154155
func symbolication(mode: Backtrace.SymbolicationMode) {
155156
let backtrace = Backtrace.current()
@@ -159,4 +160,5 @@ struct BacktraceTests {
159160
print(symbolNames.map(String.init(describingForTest:)).joined(separator: "\n"))
160161
}
161162
}
163+
#endif
162164
}

0 commit comments

Comments
 (0)