<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 - LLDB print wrong value for a parameter at Og"
href="https://bugs.llvm.org/show_bug.cgi?id=45944">45944</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>LLDB print wrong value for a parameter at Og
</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>Keywords</th>
<td>wrong-debug
</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>ditaliano@apple.com, jdevlieghere@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>LLDB show a wrong value at line 10 for parameter val in function ff.
$ cat a.c
typedef int uint32_t;
uint32_t a[256];
uint32_t c, e, f, g, h;
void d(b) {
c = a[(c ^ b) & 255];
}
void ff(uint32_t val) {
d(val >> 8);
c = a[(c ^ 24) & 255];
}
int main() {
ff(47656);
}
$ clang -v
clang version 11.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
c25b20c0f6c13d68dbc2e185764082d61ae4a132)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation:
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/11.0.0
Selected GCC installation: /usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/11.0.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
$ lldb -v
lldb version 11.0.0
clang revision c25b20c0f6c13d68dbc2e185764082d61ae4a132
llvm revision c25b20c0f6c13d68dbc2e185764082d61ae4a132
$ gdb -v
GNU gdb (Ubuntu 8.1-0ubuntu3.2) 8.1.0.20180409-git
$ clang -Og -g -o opt amod.c
$ lldb opt
(lldb) b ff
Breakpoint 1: where = opt`ff + 1 at amod.c:9:9, address = 0x00000000004004a1
(lldb) r
Process 60 launched: 'opt' (x86_64)
Process 60 stopped
* thread #1, name = 'opt', stop reason = breakpoint 1.1
frame #0: 0x00000000004004a1 opt`ff(val=47656) at amod.c:9:9
6 }
7
8 void ff(uint32_t val) {
-> 9 d(val >> 8);
10 c = a[(c ^ 24) & 255];
11 }
12
(lldb) s
Process 60 stopped
* thread #1, name = 'opt', stop reason = step in
frame #0: 0x0000000000400484 opt`d(b=186) at amod.c:5:11
2 uint32_t a[256];
3 uint32_t c, e, f, g, h;
4 void d(b) {
-> 5 c = a[(c ^ b) & 255];
6 }
7
8 void ff(uint32_t val) {
(lldb) s
Process 60 stopped
* thread #1, name = 'opt', stop reason = step in
frame #0: 0x000000000040049a opt`d(b=186) at amod.c:6:1
3 uint32_t c, e, f, g, h;
4 void d(b) {
5 c = a[(c ^ b) & 255];
-> 6 }
7
8 void ff(uint32_t val) {
9 d(val >> 8);
(lldb) s
Process 60 stopped
* thread #1, name = 'opt', stop reason = step in
frame #0: 0x00000000004004a9 opt`ff(val=186) at amod.c:10:10
7
8 void ff(uint32_t val) {
9 d(val >> 8);
-> 10 c = a[(c ^ 24) & 255];
11 }
12
13 int main() {
(lldb) s
Process 60 stopped
* thread #1, name = 'opt', stop reason = step in
frame #0: 0x00000000004004c1 opt`ff(val=186) at amod.c:11:1
8 void ff(uint32_t val) {
9 d(val >> 8);
10 c = a[(c ^ 24) & 255];
-> 11 }
12
13 int main() {
14 ff(47656);
(lldb) s
Process 60 stopped
* thread #1, name = 'opt', stop reason = step in
frame #0: 0x00000000004004db opt`main at amod.c:15:1
12
13 int main() {
14 ff(47656);
-> 15 }
(lldb) s
$ gdb opt
(gdb) b ff
Breakpoint 1 at 0x4004a1: file amod.c, line 9.
(gdb) r
Starting program: opt
Breakpoint 1, ff (val=val@entry=47656) at amod.c:9
9 d(val >> 8);
(gdb) s
d (b=186) at amod.c:5
5 c = a[(c ^ b) & 255];
(gdb) s
d (b=186) at amod.c:6
6 }
(gdb) s
ff (val=val@entry=47656) at amod.c:10
10 c = a[(c ^ 24) & 255];
(gdb) p val
$1 = 47656
(gdb) s
11 }
(gdb) s
main () at amod.c:15
15 }
(gdb) s</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>