<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 steps incorrectly for binaries compiled using GCC 6.2 on Ubuntu 16.10"
   href="https://llvm.org/bugs/show_bug.cgi?id=31212">31212</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>LLDB steps incorrectly for binaries compiled using GCC 6.2 on Ubuntu 16.10
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>lldb
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.9
          </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>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>All Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>lldb-dev@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>eldar.abusalimov@jetbrains.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Step-over and step-in skip source lines and behave more like step-out for code
compiled on Ubuntu 16.10 using GCC 6.2, which by default compiles with -pie.
Everything works correctly when using -fno-pie explicitly. The weird thing is,
everything also works fine when compiling on Ubuntu 16.04 using GCC 6.2 from
ppa:ubuntu-toolchain-r/test.

The issue is also reproducible with binaries compiled on Ubuntu 16.10 using GCC
6.2 which are then debugged on another system, like Ubuntu 16.04.

Source code:

    #include <iostream>

    void printHello() {
        std::cout << "Hello, World! from function" << std::endl;
        std::cout << "Hello, World! from function" << std::endl;
        std::cout << "Hello, World! from function" << std::endl;
    }

    int main() {
        printHello();
        std::cout << "Hello, World! from main()" << std::endl;
        std::cout << "Hello, World! from main()" << std::endl;
        std::cout << "Hello, World! from main()" << std::endl;
        return 0;
    }


Debug session:

    $ lldb ClionProjects/bug_test/cmake-build-debug/bug_test
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    ImportError: No module named lldb.embedded_interpreter
    (lldb) target create "ClionProjects/bug_test/cmake-build-debug/bug_test"
    Current executable set to
'ClionProjects/bug_test/cmake-build-debug/bug_test' (x86_64).
    (lldb) b main.cpp:10
    Breakpoint 1: where = bug_test`main + 4 at main.cpp:10, address =
0x0000000000000993
    (lldb) r
    Process 2545 launched:
'/home/user/ClionProjects/bug_test/cmake-build-debug/bug_test' (x86_64)
    Process 2545 stopped
    * thread #1: tid = 2545, 0x0000555555554993 bug_test`main + 4 at
main.cpp:10, name = 'bug_test', stop reason = breakpoint 1.1
        frame #0: 0x0000555555554993 bug_test`main + 4 at main.cpp:10
       7       }
       8       
       9       int main() {
    -> 10          printHello();
       11          std::cout << "Hello, World! from main()" << std::endl;
       12          std::cout << "Hello, World! from main()" << std::endl;
       13          std::cout << "Hello, World! from main()" << std::endl;
    (lldb) s
    Process 2545 stopped
    * thread #1: tid = 2545, 0x0000555555554914 bug_test`printHello() + 4 at
main.cpp:4, name = 'bug_test', stop reason = step in
        frame #0: 0x0000555555554914 bug_test`printHello() + 4 at main.cpp:4
       1       #include <iostream>
       2       
       3       void printHello() {
    -> 4           std::cout << "Hello, World! from function" << std::endl;
       5           std::cout << "Hello, World! from function" << std::endl;
       6           std::cout << "Hello, World! from function" << std::endl;
       7       }
    (lldb) s
    Hello, World! from function
    Hello, World! from function
    Hello, World! from function
    Process 2545 stopped
    * thread #1: tid = 2545, 0x0000555555554998 bug_test`main + 9 at
main.cpp:11, name = 'bug_test', stop reason = step in
        frame #0: 0x0000555555554998 bug_test`main + 9 at main.cpp:11
       8       
       9       int main() {
       10          printHello();
    -> 11          std::cout << "Hello, World! from main()" << std::endl;
       12          std::cout << "Hello, World! from main()" << std::endl;
       13          std::cout << "Hello, World! from main()" << std::endl;
       14          return 0;
    (lldb) s
    Hello, World! from main()
    Hello, World! from main()
    Hello, World! from main()
    Process 2545 stopped
    * thread #1: tid = 2545, 0x00007ffff76a93f1 libc.so.6`__libc_start_main +
241, name = 'bug_test', stop reason = step in
        frame #0: 0x00007ffff76a93f1 libc.so.6`__libc_start_main + 241
    libc.so.6`__libc_start_main:
    ->  0x7ffff76a93f1 <+241>: movl   %eax, %edi
        0x7ffff76a93f3 <+243>: callq  0x7ffff76c3320            ; exit
        0x7ffff76a93f8 <+248>: xorl   %eax, %eax
        0x7ffff76a93fa <+250>: jmp    0x7ffff76a9337            ; <+55>
    (lldb)</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>