<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 step-in misses internal breakpoint and continues execution"
   href="https://llvm.org/bugs/show_bug.cgi?id=27800">27800</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>LLDB step-in misses internal breakpoint and continues execution
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </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>progers7@gatech.edu
          </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>Created <span class=""><a href="attachment.cgi?id=16383" name="attach_16383" title="Reproduction test files">attachment 16383</a> <a href="attachment.cgi?id=16383&action=edit" title="Reproduction test files">[details]</a></span>
Reproduction test files

lldb-340.4.70
llvm 7.0.0 (clang-700.0.72) (also occurs at trunk@r268813)

Reproduction steps:
1. Compile
  g++ -O1 -gdwarf-4 -c TestClass.cpp
  g++ -gdwarf-4 lldbBug.cpp TestClass.o -o lldbBug -lm

2. Launch lldb and break at TestSubclass::reproStepBug()
  lldb lldbBug
  breakpoint set --name TestSubclass::reproStepBug
  run

3. Once the breakpoint is hit, try stepping
  thread step-in
  [bug!!]

The bug is that lldb's internal step breakpoint is skipped over due to
optimizations. Because the optimized code is linked in, there is no warning
about stepping with optimizations.

In multithreaded programs, this bug results in the current thread continuing
out from underneath lldb. From the user's perspective, the thread just becomes
invalid:
Process 37950 stopped ...
(lldb) thread step-in
(lldb) thread step-in
error: invalid thread
(lldb) thread step-in
error: invalid thread


--------------TestClass.cpp--------------
#include "TestClass.h"

__attribute__ ((optnone)) static bool getMember(const TestClass* testObject) {
    return testObject->member;
}

void TestClass::callMember() const
{
    if (getMember(this))
        member->callMember();
}

---------------TestClass.h---------------
class TestClass {
public:
    explicit TestClass(TestClass* m) : member(m) { }
    void callMember() const;
    TestClass* member;
};

class TestSubclass : public TestClass {
public:
    explicit TestSubclass() : TestClass(0) { }

    // To repro, break at this function and then step through the two calls.
    void reproStepBug() {
        callMember();
        callMember();
    }
};

--------------lldbBug.cpp--------------
#include "TestClass.h"

int main(int argc, char *argv[]) {
    TestSubclass object;
    object.reproStepBug();
    return 0;
}</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>