[llvm-bugs] [Bug 45944] New: LLDB print wrong value for a parameter at Og

via llvm-bugs llvm-bugs at lists.llvm.org
Fri May 15 06:43:27 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=45944

            Bug ID: 45944
           Summary: LLDB print wrong value for a parameter at Og
           Product: lldb
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Keywords: wrong-debug
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: lldb-dev at lists.llvm.org
          Reporter: massarelli at diag.uniroma1.it
                CC: ditaliano at apple.com, jdevlieghere at apple.com,
                    llvm-bugs at lists.llvm.org

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 (https://github.com/llvm/llvm-project.git
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 at 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 at 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

-- 
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/20200515/5450eb21/attachment-0001.html>


More information about the llvm-bugs mailing list