| Issue |
178007
|
| Summary |
[DebugInfo] Missed line info
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
DrSergei
|
I found problem in one of `lldb-dap` tests.
main.cpp
```
int main(int argc, char const *argv[]) {
// Test for data breakpoint
int x = 0;
int arr[4] = {1, 2, 3, 4};
for (int i = 0; i < 5; ++i) { // first loop breakpoint
if (i == 1) {
x = i + 1;
} else if (i == 2) {
arr[i] = 42;
}
}
x = 1;
for (int i = 0; i < 10; ++i) { // second loop breakpoint
++x;
}
}
```
When I set watchpoint on `arr[2]` and hit it, LLDB displays wrong location (`main.cpp:0:14`), code compiled using `clang` from main with `-g` option.
lldb.log
```
sergei@DrSergei:~/test$ /home/sergei/llvm-project/build/bin/lldb main.exe
(lldb) target create "main.exe"
Current executable set to '/home/sergei/test/main.exe' (x86_64).
(lldb) br set -f main.cpp -l 5
Breakpoint 1: where = main.exe`main + 47 at main.cpp:5:12, address = 0x000000000000115f
(lldb) run
Process 306545 launched: '/home/sergei/test/main.exe' (x86_64)
Process 306545 stopped
* thread #1, name = 'main.exe', stop reason = breakpoint 1.1
frame #0: 0x000055555555515f main.exe`main(argc=1, argv=0x00007fffffffdbd8) at main.cpp:5:12
2 // Test for data breakpoint
3 int x = 0;
4 int arr[4] = {1, 2, 3, 4};
-> 5 for (int i = 0; i < 5; ++i) { // first loop breakpoint
6 if (i == 1) {
7 x = i + 1;
8 } else if (i == 2) {
(lldb) watchpoint set variable arr[2]
Watchpoint created: Watchpoint 1: addr = 0x7fffffffda88 size = 4 state = enabled type = m
watchpoint spec = 'arr[2]'
watchpoint resources:
#0: addr = 0x7fffffffda88 size = 4
Watchpoint 1 hit:
new value: 3
(lldb) c
Process 306545 resuming
Watchpoint 1 hit:
old value: 3
new value: 42
Process 306545 stopped
* thread #1, name = 'main.exe', stop reason = watchpoint 1
frame #0: 0x000055555555518f main.exe`main(argc=1, argv=0x00007fffffffdbd8) at main.cpp:0:14
-> 1 int main(int argc, char const *argv[]) {
2 // Test for data breakpoint
3 int x = 0;
4 int arr[4] = {1, 2, 3, 4};
5 for (int i = 0; i < 5; ++i) { // first loop breakpoint
6 if (i == 1) {
7 x = i + 1;
note: This address is not associated with a specific line of code. This may be due to compiler optimizations.
(lldb) bt
* thread #1, name = 'main.exe', stop reason = watchpoint 1
* frame #0: 0x000055555555518f main.exe`main(argc=1, argv=0x00007fffffffdbd8) at main.cpp:0:14
frame #1: 0x00007ffff7c2a1ca libc.so.6`__libc_start_call_main(main=(main.exe`main at main.cpp:1), argc=1, argv=0x00007fffffffdbd8) at libc_start_call_main.h:58:16
frame #2: 0x00007ffff7c2a28b libc.so.6`__libc_start_main_impl(main=(main.exe`main at main.cpp:1), argc=1, argv=0x00007fffffffdbd8, init=<unavailable>, fini=<unavailable>, rtld_fini=<unavailable>, stack_end=0x00007fffffffdbc8) at libc-start.c:360:3
frame #3: 0x0000555555555065 main.exe`_start + 37
(lldb)
```
Also, `llvm-debuginfo-analyser` shows the same problem:
```
Logical View:
{File} 'main.exe'
{CompileUnit} 'main.cpp'
{Array} 'int [4]'
1 {Function} extern not_inlined 'main' -> 'int'
{Block}
5 {Variable} 'i' -> 'int'
5 {Line}
{Code} 'movl $0x0, -0x34(%rbp)'
5 {Line}
{Code} 'cmpl $0x5, -0x34(%rbp)'
5 {Line}
{Code} 'jge 0x32'
6 {Line}
{Code} 'cmpl $0x1, -0x34(%rbp)'
{Code} 'jne 0xb'
7 {Line}
{Code} 'movl -0x34(%rbp), %eax'
7 {Line}
{Code} 'addl $0x1, %eax'
7 {Line}
{Code} 'movl %eax, -0x14(%rbp)'
8 {Line}
{Code} 'jmp 0x14'
8 {Line}
{Code} 'cmpl $0x2, -0x34(%rbp)'
{Code} 'jne 0xc'
9 {Line}
{Code} 'movslq -0x34(%rbp), %rax'
9 {Line}
{Code} 'movl $0x2a, -0x30(%rbp,%rax,4)' <---- move 42
- {Line}
{Code} 'jmp 0x0'
11 {Line}
{Code} 'jmp 0x0'
5 {Line}
{Code} 'movl -0x34(%rbp), %eax'
{Code} 'addl $0x1, %eax'
{Code} 'movl %eax, -0x34(%rbp)'
5 {Line}
{Code} 'jmp -0x38'
{Block}
14 {Variable} 'i' -> 'int'
14 {Line}
{Code} 'movl $0x0, -0x38(%rbp)'
14 {Line}
{Code} 'cmpl $0xa, -0x38(%rbp)'
14 {Line}
{Code} 'jge 0x14'
15 {Line}
{Code} 'movl -0x14(%rbp), %eax'
{Code} 'addl $0x1, %eax'
{Code} 'movl %eax, -0x14(%rbp)'
14 {Line}
{Code} 'movl -0x38(%rbp), %eax'
{Code} 'addl $0x1, %eax'
{Code} 'movl %eax, -0x38(%rbp)'
14 {Line}
{Code} 'jmp -0x1a'
1 {Parameter} 'argc' -> 'int'
1 {Parameter} 'argv' -> '* * const char'
3 {Variable} 'x' -> 'int'
4 {Variable} 'arr' -> 'int [4]'
1 {Line}
{Code} 'pushq %rbp'
{Code} 'movq %rsp, %rbp'
{Code} 'movl $0x0, -0x4(%rbp)'
{Code} 'movl %edi, -0x8(%rbp)'
{Code} 'movq %rsi, -0x10(%rbp)'
3 {Line}
{Code} 'movl $0x0, -0x14(%rbp)'
4 {Line}
{Code} 'movq 0xec0(%rip), %rax'
{Code} 'movq %rax, -0x30(%rbp)'
{Code} 'movq 0xebd(%rip), %rax'
{Code} 'movq %rax, -0x28(%rbp)'
13 {Line}
{Code} 'movl $0x1, -0x14(%rbp)'
17 {Line}
{Code} 'movl -0x4(%rbp), %eax'
17 {Line}
{Code} 'popq %rbp'
{Code} 'retq'
17 {Line}
```
gcc has the same behavior, is it bug or not?
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs