<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 show a wrong value for function argument"
   href="https://bugs.llvm.org/show_bug.cgi?id=46181">46181</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>LLDB show a wrong value for function argument
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </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>DebugInfo
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>massarelli@diag.uniroma1.it
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>jdevlieghere@apple.com, keith.walker@arm.com, llvm-bugs@lists.llvm.org, paul_robinson@playstation.sony.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Argument p_8 in func_7 is shown to have a wrong value.
dwarf-dump information seems correct.

$ cat -n a.c
     1  typedef long int64_t;
     2  int a, b, c;
     3  static int func_7(int64_t p_8) {
     4    p_8 &&b;
     5    return a;
     6  }
     7  int main() {
     8    int d = func_7(0xED9A924C00011151);
     9    c = d;
    10  }

$ cat a.c
typedef long int64_t;
int a, b, c;
static int func_7(int64_t p_8) {
  p_8 &&b;
  return a;
}
int main() {
  int d = func_7(0xED9A924C00011151);
  c = d;
}

$ clang -v
clang version 11.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
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

$ llvm-dwarf-dump opt

...

0x0000007a:     DW_TAG_formal_parameter
                DW_AT_const_value     (-1325586285191949999)
                DW_AT_name    ("p_8")
                DW_AT_decl_file       ("a.c")
                DW_AT_decl_line       (3)
                DW_AT_type    (0x0000008c "int64_t")
...

$ lldb opt
(lldb) target create "opt"
Current executable set to 'opt' (x86_64).
(lldb) b main
Breakpoint 1: where = opt`main + 1 at a.c:8:11, address = 0x0000000000400481
(lldb) r
Process 460 launched: 'opt' (x86_64)
Process 460 stopped
* thread #1, name = 'opt', stop reason = breakpoint 1.1
    frame #0: 0x0000000000400481 opt`main at a.c:8:11
   5      return a;
   6    }
   7    int main() {
-> 8      int d = func_7(0xED9A924C00011151);
   9      c = d;
   10   }
(lldb) s
Process 460 stopped
* thread #1, name = 'opt', stop reason = step in
    frame #0: 0x0000000000400490 opt`func_7(p_8=-2147413679) at a.c:5:10
   2    int a, b, c;
   3    static int func_7(int64_t p_8) {
   4      p_8 &&b;
-> 5      return a;
   6    }
   7    int main() {
   8      int d = func_7(0xED9A924C00011151);
(lldb) s
Process 460 stopped
* thread #1, name = 'opt', stop reason = step in
    frame #0: 0x0000000000400486 opt`main at a.c:9:5
   6    }
   7    int main() {
   8      int d = func_7(0xED9A924C00011151);
-> 9      c = d;
   10   }
(lldb) s
Process 460 stopped
* thread #1, name = 'opt', stop reason = step in
    frame #0: 0x000000000040048c opt`main at a.c:10:1
   7    int main() {
   8      int d = func_7(0xED9A924C00011151);
   9      c = d;
-> 10   }

$ gdb opt
(gdb) b main
Breakpoint 1 at 0x400481: file a.c, line 8.
(gdb) r
Starting program: opt
Breakpoint 1, main () at a.c:8
8         int d = func_7(0xED9A924C00011151);
(gdb) s
func_7 (p_8=-1325586285191949999) at a.c:5
5         return a;
(gdb)</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>