Search code examples
c++lldb

lldb fails when setting condition


I compiled my file with clang++ -std=c++17 -g try.cpp Now on lldb,

(lldb) b Board.cpp:27
Breakpoint 1: where = a.out`Board::move(Point const&, Point const&, std::__1::vector<std::__1::vector<float, std::__1::allocator<float> >, std::__1::allocator<std::__1::vector<float, std::__1::allocator<float> > > > const&, int, float) + 40 at Board.cpp:27:28, address = 0x0000000100001558
(lldb) b Board.cpp:27 -c 'prob==0.1'
Breakpoint 2: no locations (pending).
WARNING:  Unable to resolve breakpoint to any actual locations

I am using Mojave,

~ lldb --version
lldb-1001.0.13.3
  Swift-5.0

Why is setting -c failed, while omitting it did not?


Solution

  • That's a bug in the b command. The b command isn't the "real" lldb breakpoint setting command - that is break set. b is an lldb "regex" based command that attempts to emulate the gdb breakpoint parser - and then dispatches to break set. It was added so that folks coming from gdb would have an easier time with lldb. But apparently it doesn't handle the -c flag properly. After setting a breakpoint as you specify, you will see:

    (lldb) b Board.cpp:27 -c 'prob==0.1'
    Breakpoint 1: no locations (pending).
    WARNING:  Unable to resolve breakpoint to any actual locations.
    (lldb) break list
    Current breakpoints:    
    1: name = 'Board.cpp:27 -c prob==0.1', locations = 0 (pending)
    

    So b thought you were trying to set a "function name" breakpoint using the entire string. Please file this with http://bugs.llvm.org.

    You can set the breakpoint you were trying to set using break set like:

    (lldb) br s -f Board.cpp -l 27 -c 'prob==0.1'