-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lldb wrongly stopped at a break statement when using step-by-step #45021
Comments
Many thanks for the bug report -- I experience the same behaviour in gdb, so this is probably a compiler issue. I see that when the 'for' loop on line 14 terminates, it exits via the 'break' on line 17, instead of stepping to lines 18 or 19. Worse, this is happening at -O0 too, which should give a perfect debug experience. I'm attaching the IR I get with "-g -O0 -Xclang -disable-llvm-passes" and a recent trunk -- the for loop on line 14 appears to form the blocks "for.cond3", "for.body5", "for.inc" and "for.end". "for.cond3" exits the loop via "for.end", which is given the metadata "!dbg !71":
To me it looks like clang is producing the wrong metadata. (Clang is also way out of my familiarity zone). |
That's definitely where the line table tells lldb the program has landed. If you "step-i" through the function it definitely arrives at a line marked 17, for instance: (lldb)
And there we are at line 17. This is a bug with the debug information. Doesn't look like we have a separate category for clang debug info, however. Not sure where to put this. |
NB: I noticed that in bug 45609 dblaike identified bug 19864 as a long term issue. Reading through 19864, it sounds fairly similar to this one -- the end of a loop is attributed to the end of its scope, but that means stepping onto an unreached line. |
Moving to the debug info component, per the previous comments. |
Yeah, sounds like a dup of 19864 |
Extended Description
$ clang -v
clang version 11.0.0 (/home/yibiao/.cache/yay/llvm-git/llvm-project 871beba)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-pc-linux-gnu/9.3.0
Found candidate GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/9.3.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0
Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/9.3.0
Selected GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/9.3.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
$ lldb -v
lldb version 11.0.0
clang revision 871beba
llvm revision 871beba
$ clang -g small.c; lldb ./a.out
(lldb) target create "./a.out"
Current executable set to '/home/yibiao/a.out' (x86_64).
(lldb) b small.c:14
Breakpoint 1: where = a.out`main + 57 at small.c:14:16, address = 0x0000000000401149
(lldb) run
Process 237374 launched: '/home/yibiao/a.out' (x86_64)
Process 237374 stopped
frame #0: 0x0000000000401149 a.out`main at small.c:14:16
11 for (; g <= 32; ++g)
12 {
13 i = 0;
-> 14 for (; i < 1; i++)
15 while (1 > d)
16 if (c[b])
17 break;
(lldb) step
Process 237374 stopped
frame #0: 0x0000000000401153 a.out`main at small.c:15:9
12 {
13 i = 0;
14 for (; i < 1; i++)
-> 15 while (1 > d)
16 if (c[b])
17 break;
18 L:
(lldb) step
Process 237374 stopped
frame #0: 0x0000000000401193 a.out`main at small.c:14:22
11 for (; g <= 32; ++g)
12 {
13 i = 0;
-> 14 for (; i < 1; i++)
15 while (1 > d)
16 if (c[b])
17 break;
(lldb) step
Process 237374 stopped
frame #0: 0x0000000000401149 a.out`main at small.c:14:16
11 for (; g <= 32; ++g)
12 {
13 i = 0;
-> 14 for (; i < 1; i++)
15 while (1 > d)
16 if (c[b])
17 break;
(lldb) step
Process 237374 stopped
frame #0: 0x00000000004011a1 a.out`main at small.c:17:13
14 for (; i < 1; i++)
15 while (1 > d)
16 if (c[b])
-> 17 break;
18 L:
19 if (j)
20 break;
##################
We can found that, lldb is wrongly stopped at Line:17 when using step command.
However, it behaves as expected when we set breakpoint at line:17 as follows:
$ clang -g small.c; lldb ./a.out
(lldb) target create "./a.out"
Current executable set to '/home/yibiao/a.out' (x86_64).
(lldb) b small.c:17
Breakpoint 1: where = a.out`main + 116 at small.c:17:13, address = 0x0000000000401184
(lldb) run
Process 236754 launched: '/home/yibiao/a.out' (x86_64)
Process 236754 exited with status = 0 (0x00000000)
$ cat small.c
char a;
short b, d = 5, h;
char c[1];
int e, f = 4, g, j;
int main()
{
int i;
for (; f; f = a)
{
g = 0;
for (; g <= 32; ++g)
{
i = 0;
for (; i < 1; i++)
while (1 > d)
if (c[b])
break;
L:
if (j)
break;
}
}
return 0;
}
The text was updated successfully, but these errors were encountered: