[llvm-bugs] [Bug 46191] New: Wrong variable value shown during debugging at Og

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jun 4 00:30:12 PDT 2020


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

            Bug ID: 46191
           Summary: Wrong variable value shown during debugging at Og
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: DebugInfo
          Assignee: unassignedbugs at nondot.org
          Reporter: massarelli at diag.uniroma1.it
                CC: jdevlieghere at apple.com, keith.walker at arm.com,
                    llvm-bugs at lists.llvm.org,
                    paul_robinson at playstation.sony.com

At the second iteration of the for loop at line 9, a wrong value is shown for
variable p_24. The same behaviour is visible with gdb.

$ cat -n a.c
     1  typedef int int32_t;
     2  int32_t g, m;
     3  short h, i, j, k, l;
     4  char n;
     5  long(a)(b, c) { return b + c; }
     6  char(d)(e, f) { return e - f; }
     7  void func_20(int32_t p_24) {
     8    h = 0;
     9    for (; h < 6; h = a(h, 3)) {
    10      int32_t a = k = 1 != p_24;
    11      i &= g;
    12      m |= a;
    13      l++;
    14      n = d(g, a);
    15    }
    16  }
    17  int main() { func_20(j); }

$ cat a.c
typedef int int32_t;
int32_t g, m;
short h, i, j, k, l;
char n;
long(a)(b, c) { return b + c; }
char(d)(e, f) { return e - f; }
void func_20(int32_t p_24) {
  h = 0;
  for (; h < 6; h = a(h, 3)) {
    int32_t a = k = 1 != p_24;
    i &= g;
    m |= a;
    l++;
    n = d(g, a);
  }
}
int main() { func_20(j); }

$ clang -v
clang version 11.0.0 (https://github.com/llvm/llvm-project.git
d4ef654673a921878ba5aedb9725b2ac32681f01)
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
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Candidate multilib: .;@m64
Selected multilib: .;@m64

$ lldb -v
lldb version 11.0.0
  clang revision d4ef654673a921878ba5aedb9725b2ac32681f01
  llvm revision d4ef654673a921878ba5aedb9725b2ac32681f01

$ gdb -v
GNU gdb (Ubuntu 8.1-0ubuntu3.2) 8.1.0.20180409-git

$ clang -Og -g -o opt a.c

$ ldb opt 
(lldb) target create "opt"
Current executable set to 'opt' (x86_64).
(lldb) b -l 9
Breakpoint 1: where = opt`func_20 + 89 at a.c:9:23, address =
0x00000000004004f9
(lldb) c
error: invalid process
(lldb) r
Process 346 launched: 'opt' (x86_64)
Process 346 stopped
* thread #1, name = 'opt', stop reason = breakpoint 1.1
    frame #0: 0x00000000004004f9 opt`func_20(p_24=0) at a.c:9:23
   6    char(d)(e, f) { return e - f; }
   7    void func_20(int32_t p_24) {
   8      h = 0;
-> 9      for (; h < 6; h = a(h, 3)) {
   10       int32_t a = k = 1 != p_24;
   11       i &= g;
   12       m |= a;
(lldb) c
Process 346 resuming
Process 346 stopped
* thread #1, name = 'opt', stop reason = breakpoint 1.1
    frame #0: 0x00000000004004f9 opt`func_20(p_24=0) at a.c:9:23
   6    char(d)(e, f) { return e - f; }
   7    void func_20(int32_t p_24) {
   8      h = 0;
-> 9      for (; h < 6; h = a(h, 3)) {
   10       int32_t a = k = 1 != p_24;
   11       i &= g;
   12       m |= a;
(lldb) s
Process 346 stopped
* thread #1, name = 'opt', stop reason = step in
    frame #0: 0x0000000000400480 opt`a(b=3, c=3) at a.c:5:26
   2    int32_t g, m;
   3    short h, i, j, k, l;
   4    char n;
-> 5    long(a)(b, c) { return b + c; }
   6    char(d)(e, f) { return e - f; }
   7    void func_20(int32_t p_24) {
   8      h = 0;
(lldb) s
Process 346 stopped
* thread #1, name = 'opt', stop reason = step in
    frame #0: 0x0000000000400507 opt`func_20(p_24=0) at a.c:9:21
   6    char(d)(e, f) { return e - f; }
   7    void func_20(int32_t p_24) {
   8      h = 0;
-> 9      for (; h < 6; h = a(h, 3)) {
   10       int32_t a = k = 1 != p_24;
   11       i &= g;
   12       m |= a;
(lldb) s
Process 346 stopped
* thread #1, name = 'opt', stop reason = step in
    frame #0: 0x0000000000400492 opt`d(e=0, f=1) at a.c:6:26
   3    short h, i, j, k, l;
   4    char n;
   5    long(a)(b, c) { return b + c; }
-> 6    char(d)(e, f) { return e - f; }
   7    void func_20(int32_t p_24) {
   8      h = 0;
   9      for (; h < 6; h = a(h, 3)) {
(lldb) s
Process 346 stopped
* thread #1, name = 'opt', stop reason = step in
    frame #0: 0x000000000040052e opt`func_20(p_24=1) at a.c:10:19
   7    void func_20(int32_t p_24) {
   8      h = 0;
   9      for (; h < 6; h = a(h, 3)) {
-> 10       int32_t a = k = 1 != p_24;
   11       i &= g;
   12       m |= a;
   13       l++;

$ gdb opt
(gdb) b -l 9
Breakpoint 1 at 0x4004f9: file a.c, line 9.
(gdb) r
Starting program: /home/stepping/output/opt 

Breakpoint 1, func_20 (p_24=0) at a.c:9
9         for (; h < 6; h = a(h, 3)) {
(gdb) c
Continuing.
Breakpoint 1, func_20 (p_24=0) at a.c:9
9         for (; h < 6; h = a(h, 3)) {
(gdb) s
a (b=3, c=c at entry=3) at a.c:5
5       long(a)(b, c) { return b + c; }
(gdb) s
d (e=e at entry=0, f=f at entry=1) at a.c:6
6       char(d)(e, f) { return e - f; }
(gdb) s
func_20 (p_24=1) at a.c:10
10          int32_t a = k = 1 != p_24;
(gdb)

-- 
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/20200604/8ad6bc95/attachment.html>


More information about the llvm-bugs mailing list