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

            Bug ID: 27800
           Summary: LLDB step-in misses internal breakpoint and continues
                    execution
           Product: lldb
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: lldb-...@lists.llvm.org
          Reporter: proge...@gatech.edu
                CC: llvm-bugs@lists.llvm.org
    Classification: Unclassified

Created attachment 16383
  --> https://llvm.org/bugs/attachment.cgi?id=16383&action=edit
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;
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to