-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Open
Labels
Description
After #159104, if a function is optimized-out, DIEs for static local variables referenced from the function's inlined instance go to the function's abstract DIE. gdb can discover such variables, but lldb cannot, apparently.
Example source file:
➜ cat ../test-static-local.cpp
__attribute__((always_inline))
static int foo() {
static int x = 35;
int y = 25;
return x;
}
int main() {
foo();
return foo();
}
➜ bin/clang ../test-static-local.cpp -g -o test-static-local -O0
LLDB and gdb behavior:
➜ bin/lldb test-static-local
(lldb) b foo
Breakpoint 1: 2 locations.
(lldb) r
Process 38232 launched: '/home/parallels/llvm/build/native/test-static-local' (aarch64)
Process 38232 stopped
* thread #1, name = 'test-static-loc', stop reason = breakpoint 1.1
frame #0: 0x0000aaaaaaaa06f4 test-static-local`foo() at test-static-local.cpp:4:9 [inlined]
-> 4 int y = 25;
(lldb) p y
(int) 4980991
(lldb) p x
˄
╰─ error: use of undeclared identifier 'x'
(lldb) q
➜ gdb test-static-local
GNU gdb (Ubuntu 16.2-8ubuntu1) 16.2
(gdb) b foo
Breakpoint 1 at 0x6f4: foo. (2 locations)
(gdb) r
Breakpoint 1.1, foo () at ../test-static-local.cpp:4
4 int y = 25;
(gdb) p x
$1 = 35
(gdb) p y
$2 = 5701887
Dwarfdump: https://gist.github.com/dzhidzhoev/b4ca1d74014b25642de6621fb677c35b