Files
swift-mirror/test/Backtracing/SymbolicatedBacktracePDB.swift
Alastair Houghton 042861d752 [Backtracing][PDB] Fix a couple of tests.
We can't test the alternate image support for ELF, because that's been
removed in favour of `SymbolLocator`/`SymbolSource`.

Also we must pass `/opt:icf` in the symbolicated backtrace test when
using PDB, otherwise we corrupt the metadata.

Finally fix a mistake in `Utils.swift` where we were crashing if the
environment variable in question wasn't set.

rdar://168454023
2026-02-17 18:51:17 +00:00

56 lines
1.4 KiB
Swift

// RUN: %empty-directory(%t)
// RUN: %target-build-swift -g -debug-info-format=codeview -Xlinker /debug -Xlinker /opt:icf %s -parse-as-library -Xfrontend -disable-availability-checking -g -Onone -o %t/symbolicated.exe
// RUN: %target-codesign %t/symbolicated.exe
// RUN: %target-run %t/symbolicated.exe | %FileCheck %s
// UNSUPPORTED: use_os_stdlib
// UNSUPPORTED: back_deployment_runtime
// REQUIRES: executable_test
// REQUIRES: backtracing
// REQUIRES: OS=windows-msvc
import Runtime
func kablam() {
kerpow()
}
func kerpow() {
whap()
}
func whap() {
zonk()
}
func zonk() {
splat()
}
func splat() {
pow()
}
func pow() {
let backtrace = try! Backtrace.capture().symbolicated(
options: [ .showInlineFrames, .showSourceLocations ]
)!
// CHECK: 0{{[ \t]+}}0x{{[0-9a-f]+}} [ra] [0] symbolicated.exe pow()
// CHECK: 1{{[ \t]+}}0x{{[0-9a-f]+}} [ra] [0] symbolicated.exe splat()
// CHECK: 2{{[ \t]+}}0x{{[0-9a-f]+}} [ra] [0] symbolicated.exe zonk()
// CHECK: 3{{[ \t]+}}0x{{[0-9a-f]+}} [ra] [0] symbolicated.exe whap()
// CHECK: 4{{[ \t]+}}0x{{[0-9a-f]+}} [ra] [0] symbolicated.exe kerpow()
// CHECK: 5{{[ \t]+}}0x{{[0-9a-f]+}} [ra] [0] symbolicated.exe kablam()
// CHECK: 6{{[ \t]+}}0x{{[0-9a-f]+}} [ra] [0] symbolicated.exe static SymbolicatedBacktrace.main()
print(backtrace)
}
@main
struct SymbolicatedBacktrace {
static func main() {
kablam()
}
}