[llvm-bugs] [Bug 46181] New: LLDB show a wrong value for function argument

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jun 3 02:50:34 PDT 2020


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

            Bug ID: 46181
           Summary: LLDB show a wrong value for function argument
           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

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 (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

$ 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)

-- 
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/20200603/af019141/attachment.html>


More information about the llvm-bugs mailing list