[llvm-bugs] [Bug 47239] New: Wrong line information at Og

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Aug 19 12:42:50 PDT 2020


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

            Bug ID: 47239
           Summary: Wrong line information 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

After setting a breakpoint at func_10 and running line 5 is hit. However, from
disassembly, it seems that line 7 is being executed.

$ cat -n a.c
     1  int a;
     2  int *b;
     3  int *func_10() {
     4    int *c = &a;
     5    int i, j;
     6  d:
     7    if (*c)
     8      goto d;
     9    i = 0;
    10    for (; i;)
    11      j = &c;
    12    return c;
    13  }
    14  int main() { b = func_10(); }

$ cat a.c
int a;
int *b;
int *func_10() {
  int *c = &a;
  int i, j;
d:
  if (*c)
    goto d;
  i = 0;
  for (; i;)
    j = &c;
  return c;
}
int main() { b = func_10(); }

$ clang -v
clang version 12.0.0 (https://github.com/llvm/llvm-project.git
bc8be3054067ac822fc6d9f4f8e64c841f530f16)
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

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

$ lldb opt
lldb opt 
(lldb) target create "opt"
Current executable set to opt' (x86_64).
(lldb) b func_10
Breakpoint 1: where = opt`func_10 + 7 at a.c:5:3, address = 0x0000000000400487
(lldb) r
Process 24746 launched: 'opt' (x86_64)
Process 24746 stopped
* thread #1, name = 'opt', stop reason = breakpoint 1.1
    frame #0: 0x0000000000400487 opt`func_10 at a.c:5:3
   2    int *b;
   3    int *func_10() {
   4      int *c = &a;
-> 5      int i, j;
   6    d:
   7      if (*c)
   8        goto d;
(lldb) di
opt`func_10:
    0x400480 <+0>:  cmpl   $0x0, 0x200ba9(%rip)      ; opt.PT_LOAD[1]..bss + 7
->  0x400487 <+7>:  je     0x400492                  ; <+18> at a.c:12:3
    0x400489 <+9>:  nopl   (%rax)
    0x400490 <+16>: jmp    0x400490                  ; <+16> at a.c:7:7
    0x400492 <+18>: movl   $0x601030, %eax           ; imm = 0x601030 
    0x400497 <+23>: retq   
(lldb)

-- 
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/20200819/663c57a0/attachment-0001.html>


More information about the llvm-bugs mailing list