<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Odd stepping behaviour when compiling with gcc O3"
href="https://bugs.llvm.org/show_bug.cgi?id=46456">46456</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Odd stepping behaviour when compiling with gcc O3
</td>
</tr>
<tr>
<th>Product</th>
<td>lldb
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>All Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>lldb-dev@lists.llvm.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>massarelli@diag.uniroma1.it
</td>
</tr>
<tr>
<th>CC</th>
<td>jdevlieghere@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>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)</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>