[lldb/DWARF] Reland: Use DW_AT_call_pc to determine artificial frame address

Reland with changes: the test modified in this change originally failed
on a Debian/x86_64 builder, and I suspect the cause was that lldb looked
up the line location for an artificial frame by subtracting 1 from the
frame's address. For artificial frames, the subtraction must not happen
because the address is already exact.

---

lldb currently guesses the address to use when creating an artificial
frame (i.e., a frame constructed by determining the sequence of (tail)
calls which must have happened).

Guessing the address creates problems -- use the actual address provided
by the DW_AT_call_pc attribute instead.

Depends on D76336.

rdar://60307600

Differential Revision: https://reviews.llvm.org/D76337
This commit is contained in:
Vedant Kumar
2020-03-17 17:59:08 -07:00
parent e8d67ada2d
commit 03e29e2c19
5 changed files with 99 additions and 42 deletions

View File

@@ -3,19 +3,28 @@ volatile int x;
void __attribute__((noinline)) sink() {
x++; //% self.filecheck("bt", "main.cpp", "-implicit-check-not=artificial")
// CHECK: frame #0: 0x{{[0-9a-f]+}} a.out`sink() at main.cpp:[[@LINE-1]]:4 [opt]
// CHECK-NEXT: frame #1: 0x{{[0-9a-f]+}} a.out`func3{{.*}} [opt] [artificial]
// CHECK-NEXT: frame #2: 0x{{[0-9a-f]+}} a.out`func2{{.*}} [opt]
// CHECK-NEXT: frame #3: 0x{{[0-9a-f]+}} a.out`func1{{.*}} [opt] [artificial]
// CHECK-NEXT: frame #1: 0x{{[0-9a-f]+}} a.out`func3() at main.cpp:14:3 [opt] [artificial]
// CHECK-NEXT: frame #2: 0x{{[0-9a-f]+}} a.out`func2() {{.*}} [opt]
// CHECK-NEXT: frame #3: 0x{{[0-9a-f]+}} a.out`func1() at main.cpp:23:3 [opt] [artificial]
// CHECK-NEXT: frame #4: 0x{{[0-9a-f]+}} a.out`main{{.*}} [opt]
}
void __attribute__((noinline)) func3() { sink(); /* tail */ }
void __attribute__((noinline)) func3() {
x++;
sink(); /* tail */
}
void __attribute__((disable_tail_calls, noinline)) func2() { func3(); /* regular */ }
void __attribute__((disable_tail_calls, noinline)) func2() {
func3(); /* regular */
}
void __attribute__((noinline)) func1() { func2(); /* tail */ }
void __attribute__((noinline)) func1() {
x++;
func2(); /* tail */
}
int __attribute__((disable_tail_calls)) main() {
// DEBUG: self.runCmd("log enable lldb step -f /tmp/lldbstep.log")
func1(); /* regular */
return 0;
}