[llvm-bugs] [Bug 46456] New: Odd stepping behaviour when compiling with gcc O3
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Jun 25 08:12:19 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=46456
Bug ID: 46456
Summary: Odd stepping behaviour when compiling with gcc O3
Product: lldb
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: All Bugs
Assignee: lldb-dev at lists.llvm.org
Reporter: massarelli at diag.uniroma1.it
CC: jdevlieghere at apple.com, llvm-bugs at lists.llvm.org
When compiling with gcc O3 and debugging with lldb function b seems to be
called twice.
$ cat -n a.c
1 int a;
2 void b() { printf("%X\n"); }
3 int main() {
4 a = 1;
5 b();
6 }
$ cat a.c
int a;
void b() { printf("%X\n"); }
int main() {
a = 1;
b();
}
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/bin/../libexec/gcc/x86_64-pc-linux-gnu/11.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ./configure --prefix=/tmp/gcc_build --disable-multilib
--enable-languages=c,c++
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.0.0 20200624 (experimental) (GCC)
$ lldb -v
lldb version 11.0.0
clang revision ee26a31e7b02e124d71091d47f2ae624774e5e0a
llvm revision ee26a31e7b02e124d71091d47f2ae624774e5e0a
$ gcc -O3 -g -o out a.c
$ lldb out
(lldb) target create "out"
Current executable set to 'out' (x86_64).
(lldb) b main
Breakpoint 1: where = out`main at a.c:3:12, address = 0x0000000000400410
(lldb) r
Process 280 launched: '/home/stepping/output/out' (x86_64)
Process 280 stopped
* thread #1, name = 'out', stop reason = breakpoint 1.1
frame #0: 0x0000000000400410 out`main at a.c:3:12
1 int a;
2 void b() { printf("%X\n"); }
-> 3 int main() {
4 a = 1;
5 b();
6 }
(lldb) s
Process 280 stopped
* thread #1, name = 'out', stop reason = step in
frame #0: 0x0000000000400414 out`main at a.c:5
2 void b() { printf("%X\n"); }
3 int main() {
4 a = 1;
-> 5 b();
6 }
(lldb) di
out`main:
0x400410 <+0>: subq $0x8, %rsp
-> 0x400414 <+4>: movl $0x4005c4, %edi ; imm = 0x4005C4
0x400419 <+9>: xorl %eax, %eax
0x40041b <+11>: movl $0x1, 0x200c0f(%rip) ; completed.0
0x400425 <+21>: callq 0x400400 ; symbol stub for: printf
0x40042a <+26>: xorl %eax, %eax
0x40042c <+28>: addq $0x8, %rsp
0x400430 <+32>: retq
(lldb) bt
* thread #1, name = 'out', stop reason = step in
* frame #0: 0x0000000000400414 out`main at a.c:5
frame #1: 0x00007ffff7a05b97 libc.so.6`__libc_start_main + 231
frame #2: 0x000000000040046a out`_start + 42
(lldb) s
Process 280 stopped
* thread #1, name = 'out', stop reason = step in
frame #0: 0x0000000000400414 out`main at a.c:2:12
1 int a;
-> 2 void b() { printf("%X\n"); }
3 int main() {
4 a = 1;
5 b();
6 }
(lldb) di
out`main:
0x400410 <+0>: subq $0x8, %rsp
-> 0x400414 <+4>: movl $0x4005c4, %edi ; imm = 0x4005C4
0x400419 <+9>: xorl %eax, %eax
0x40041b <+11>: movl $0x1, 0x200c0f(%rip) ; completed.0
0x400425 <+21>: callq 0x400400 ; symbol stub for: printf
0x40042a <+26>: xorl %eax, %eax
0x40042c <+28>: addq $0x8, %rsp
0x400430 <+32>: retq
(lldb) bt
* thread #1, name = 'out', stop reason = step in
* frame #0: 0x0000000000400414 out`main at a.c:2:12
frame #1: 0x0000000000400414 out`main at a.c:5
frame #2: 0x00007ffff7a05b97 libc.so.6`__libc_start_main + 231
frame #3: 0x000000000040046a out`_start + 42
(lldb) s
Process 280 stopped
* thread #1, name = 'out', stop reason = step in
frame #0: 0x000000000040041b out`main at a.c:4:5
1 int a;
2 void b() { printf("%X\n"); }
3 int main() {
-> 4 a = 1;
5 b();
6 }
(lldb) di
out`main:
0x400410 <+0>: subq $0x8, %rsp
0x400414 <+4>: movl $0x4005c4, %edi ; imm = 0x4005C4
0x400419 <+9>: xorl %eax, %eax
-> 0x40041b <+11>: movl $0x1, 0x200c0f(%rip) ; completed.0
0x400425 <+21>: callq 0x400400 ; symbol stub for: printf
0x40042a <+26>: xorl %eax, %eax
0x40042c <+28>: addq $0x8, %rsp
0x400430 <+32>: retq
(lldb) bt
* thread #1, name = 'out', stop reason = step in
* frame #0: 0x000000000040041b out`main at a.c:4:5
frame #1: 0x00007ffff7a05b97 libc.so.6`__libc_start_main + 231
frame #2: 0x000000000040046a out`_start + 42
(lldb) s
Process 280 stopped
* thread #1, name = 'out', stop reason = step in
frame #0: 0x0000000000400425 out`main at a.c:5
2 void b() { printf("%X\n"); }
3 int main() {
4 a = 1;
-> 5 b();
6 }
(lldb) di
out`main:
0x400410 <+0>: subq $0x8, %rsp
0x400414 <+4>: movl $0x4005c4, %edi ; imm = 0x4005C4
0x400419 <+9>: xorl %eax, %eax
0x40041b <+11>: movl $0x1, 0x200c0f(%rip) ; completed.0
-> 0x400425 <+21>: callq 0x400400 ; symbol stub for: printf
0x40042a <+26>: xorl %eax, %eax
0x40042c <+28>: addq $0x8, %rsp
0x400430 <+32>: retq
(lldb) bt
* thread #1, name = 'out', stop reason = step in
* frame #0: 0x0000000000400425 out`main at a.c:5
frame #1: 0x00007ffff7a05b97 libc.so.6`__libc_start_main + 231
frame #2: 0x000000000040046a out`_start + 42
(lldb) s
Process 280 stopped
* thread #1, name = 'out', stop reason = step in
frame #0: 0x0000000000400425 out`main at a.c:2:12
1 int a;
-> 2 void b() { printf("%X\n"); }
3 int main() {
4 a = 1;
5 b();
6 }
(lldb) di
out`main:
0x400410 <+0>: subq $0x8, %rsp
0x400414 <+4>: movl $0x4005c4, %edi ; imm = 0x4005C4
0x400419 <+9>: xorl %eax, %eax
0x40041b <+11>: movl $0x1, 0x200c0f(%rip) ; completed.0
-> 0x400425 <+21>: callq 0x400400 ; symbol stub for: printf
0x40042a <+26>: xorl %eax, %eax
0x40042c <+28>: addq $0x8, %rsp
0x400430 <+32>: retq
(lldb) bt
* thread #1, name = 'out', stop reason = step in
* frame #0: 0x0000000000400425 out`main at a.c:2:12
frame #1: 0x0000000000400425 out`main at a.c:5
frame #2: 0x00007ffff7a05b97 libc.so.6`__libc_start_main + 231
frame #3: 0x000000000040046a out`_start + 42
(lldb) s
FFFFE5F8
Process 280 stopped
* thread #1, name = 'out', stop reason = step in
frame #0: 0x000000000040042a out`main at a.c:6:1
3 int main() {
4 a = 1;
5 b();
-> 6 }
(lldb) di
out`main:
0x400410 <+0>: subq $0x8, %rsp
0x400414 <+4>: movl $0x4005c4, %edi ; imm = 0x4005C4
0x400419 <+9>: xorl %eax, %eax
0x40041b <+11>: movl $0x1, 0x200c0f(%rip) ; completed.0
0x400425 <+21>: callq 0x400400 ; symbol stub for: printf
-> 0x40042a <+26>: xorl %eax, %eax
0x40042c <+28>: addq $0x8, %rsp
0x400430 <+32>: retq
(lldb) bt
* thread #1, name = 'out', stop reason = step in
* frame #0: 0x000000000040042a out`main at a.c:6:1
frame #1: 0x00007ffff7a05b97 libc.so.6`__libc_start_main + 231
frame #2: 0x000000000040046a out`_start + 42
(lldb)
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200625/51164aaf/attachment-0001.html>
More information about the llvm-bugs
mailing list