Skip to content

Stub out symbolication on platforms without dynamic linking/loading. #758

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ extension Backtrace {
public func symbolicate(_ mode: SymbolicationMode) -> [SymbolicatedAddress] {
var result = addresses.map { SymbolicatedAddress(address: $0) }

#if !SWT_NO_DYNAMIC_LINKING
#if SWT_TARGET_OS_APPLE
for (i, address) in addresses.enumerated() {
var info = Dl_info()
Expand Down Expand Up @@ -94,8 +95,6 @@ extension Backtrace {
}
}
}
#elseif os(WASI)
// WASI does not currently support backtracing let alone symbolication.
#else
#warning("Platform-specific implementation missing: backtrace symbolication unavailable")
#endif
Expand All @@ -109,6 +108,7 @@ extension Backtrace {
return symbolicatedAddress
}
}
#endif

return result
}
Expand Down
2 changes: 2 additions & 0 deletions Tests/TestingTests/BacktraceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ struct BacktraceTests {
}
#endif

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