[Linux] Enable frame pointers when building Swift libraries.

Turn on frame pointers for the Swift runtime libraries.  This makes
backtraces that go through the runtimes more reliable without having
to parse DWARF data.

rdar://116112040
This commit is contained in:
Alastair Houghton
2023-10-05 16:11:20 +01:00
parent f7a8bc2e04
commit 7b7f77eeaa
2 changed files with 72 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
// RUN: %empty-directory(%t)
// RUN: %target-build-swift %s -parse-as-library -Onone -g -o %t/FatalError
// RUN: %target-codesign %t/FatalError
// RUN: (env SWIFT_BACKTRACE=enable=yes,cache=no %target-run %t/FatalError 2>&1 || true) | %FileCheck %s
// UNSUPPORTED: use_os_stdlib
// UNSUPPORTED: back_deployment_runtime
// UNSUPPORTED: asan
// REQUIRES: executable_test
// REQUIRES: backtracing
// REQUIRES: OS=macosx || OS=linux-gnu
func level1() {
level2()
}
func level2() {
level3()
}
func level3() {
level4()
}
func level4() {
level5()
}
func level5() {
fatalError("Going to crash")
}
@main
struct FatalError {
static func main() {
level1()
}
}
// CHECK: *** Program crashed: Illegal instruction at 0x{{[0-9a-f]+}} ***
// CHECK: Thread 0 "FatalError" crashed:
// CHECK: 0 0x{{[0-9a-f]+}} _assertionFailure(_:_:file:line:flags:) + {{[0-9]+}} in libswiftCore.so at {{.*}}/AssertCommon.swift:{{[0-9]+}}:{{[0-9]+}}
// CHECK-NEXT: 1 [ra] 0x{{[0-9a-f]+}} level5() + {{[0-9]+}} in FatalError at {{.*}}/FatalError.swift:30:3
// CHECK-NEXT: 2 [ra] 0x{{[0-9a-f]+}} level4() + {{[0-9]+}} in FatalError at {{.*}}/FatalError.swift:26:3
// CHECK-NEXT: 3 [ra] 0x{{[0-9a-f]+}} level3() + {{[0-9]+}} in FatalError at {{.*}}/FatalError.swift:22:3
// CHECK-NEXT: 4 [ra] 0x{{[0-9a-f]+}} level2() + {{[0-9]+}} in FatalError at {{.*}}/FatalError.swift:18:3
// CHECK-NEXT: 5 [ra] 0x{{[0-9a-f]+}} level1() + {{[0-9]+}} in FatalError at {{.*}}/FatalError.swift:14:3
// CHECK-NEXT: 6 [ra] 0x{{[0-9a-f]+}} static FatalError.main() + {{[0-9]+}} in FatalError at {{.*}}/FatalError.swift:36:5
// CHECK-NEXT: 7 [ra] [system] 0x{{[0-9a-f]+}} static FatalError.$main() + {{[0-9]+}} in FatalError at {{.*}}/<compiler-generated>
// CHECK-NEXT: 8 [ra] 0x{{[0-9a-f]+}} main + {{[0-9]+}} in FatalError at {{.*}}/FatalError.swift