mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Prior to this commit, when lowering SIL instructions that should are
"hidden" for the purposes of debugging, the compiler just attaches the
location of the previous instruction in the name of keeping a simpler
line table.
However, this is wrong for many reasons. One such reason is this: at the
start of a basic block, inheriting the previous debug location will
almost certainly cause the instruction to have a random location in the
code, as it will depend on whatever BB was visited previously.
Other examples can be seen in the tests affect by this commit, which
changes lowering to use Line 0 instead of the line number of the
previous instruction.
CodeView doesn't handle line 0 the same way DWARF does, so this commit
preserves the old behavior for the CodeView path.
The test changes here are effectively undoing some of the diffs from
158772c2ab.
rdar://139826231&110187845
55 lines
1.9 KiB
Swift
55 lines
1.9 KiB
Swift
// 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=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-NOT: Current stack trace:
|
|
|
|
// CHECK: *** Program crashed: {{Illegal instruction|System trap}} at 0x{{[0-9a-f]+}} ***
|
|
|
|
// CHECK: Thread 0 {{(".*" )?}}crashed:
|
|
|
|
// CHECK: 0 0x{{[0-9a-f]+}} _assertionFailure(_:_:file:line:flags:) + {{[0-9]+}} in libswiftCore.{{so|dylib}}
|
|
// 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] [system] 0x{{[0-9a-f]+}} main + {{[0-9]+}} in FatalError at {{.*}}/FatalError.swift
|