[llvm-bugs] [Bug 46015] New: Odd Stepping Behaviour

via llvm-bugs llvm-bugs at lists.llvm.org
Thu May 21 05:22:00 PDT 2020


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

            Bug ID: 46015
           Summary: Odd Stepping Behaviour
           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: dblaikie at gmail.com, ditaliano at apple.com,
                    jdevlieghere at apple.com, jeremy.morse.llvm at gmail.com,
                    keith.walker at arm.com, llvm-bugs at lists.llvm.org,
                    paul_robinson at playstation.sony.com

>From the debugger it seems that func_1 is called twice.

$ cat a.c
static int a;
static int *b = &a;
static int *func_2() {
  *b = 0;
  return &a;
}
void func_1() { func_2(); }
int main() { func_1(); }

$ clang -v
clang version 11.0.0 (https://github.com/llvm/llvm-project.git
268fa40daa151d3b4bff1df12b62e5dae94685d7)
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 268fa40daa151d3b4bff1df12b62e5dae94685d7
  llvm revision 268fa40daa151d3b4bff1df12b62e5dae94685d7

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

$ 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:14, address = 0x0000000000400491
(lldb) r
Process 60 launched: 'opt' (x86_64)
Process 60 stopped
* thread #1, name = 'opt', stop reason = breakpoint 1.1
    frame #0: 0x0000000000400491 opt`main at a.c:8:14
   5      return &a;
   6    }
   7    void func_1() { func_2(); }
-> 8    int main() { func_1(); }
(lldb) s
Process 60 stopped
* thread #1, name = 'opt', stop reason = step in
    frame #0: 0x0000000000400481 opt`func_1 at a.c:7:17
   4      *b = 0;
   5      return &a;
   6    }
-> 7    void func_1() { func_2(); }
   8    int main() { func_1(); }
(lldb) s
Process 60 stopped
* thread #1, name = 'opt', stop reason = step in
    frame #0: 0x00000000004004a0 opt`func_2 at a.c:8:24
   5      return &a;
   6    }
   7    void func_1() { func_2(); }
-> 8    int main() { func_1(); }
(lldb) s
Process 60 stopped
* thread #1, name = 'opt', stop reason = step in
    frame #0: 0x0000000000400486 opt`func_1 at a.c:7:27
   4      *b = 0;
   5      return &a;
   6    }
-> 7    void func_1() { func_2(); }
   8    int main() { func_1(); }
(lldb) s
Process 60 stopped
* thread #1, name = 'opt', stop reason = step in
    frame #0: 0x0000000000400496 opt`main at a.c:8:24
   5      return &a;
   6    }
   7    void func_1() { func_2(); }
-> 8    int main() { func_1(); }
(lldb) s
Process 60 stopped
* thread #1, name = 'opt', stop reason = step in
    frame #0: 0x00007ffff7a05b97 libc.so.6`__libc_start_main + 231
libc.so.6`__libc_start_main:
->  0x7ffff7a05b97 <+231>: movl   %eax, %edi
    0x7ffff7a05b99 <+233>: callq  0x7ffff7a27120            ; exit
    0x7ffff7a05b9e <+238>: movq   0x3ced23(%rip), %rax
    0x7ffff7a05ba5 <+245>: rorq   $0x11, %rax
(lldb) ^Z

-- 
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/20200521/4f268140/attachment.html>


More information about the llvm-bugs mailing list