LLDB from the command line

Before IDEs and all current eye-candy stuff, everything was done like this:
  • Compile a sample.cpp program with debug symbols
    $ clang++ -g sample.cpp
    
  • Star the debugger
    $ lldb
    
  • Create a target to start the debug session
    $ target create a.out
    
  • Setup your breakpoints
    # breakpoing set --file sample.cpp --line 7
    $ b sample.cpp:7
    
  • List breakpoints
    $ breakpoint list
    
  • Set a condition to a preakpoint (conditional breakpoint). Use list to get the breakpoint number and replace it with N.
    $ condition N (int)[[myObj name] isEqualToString:@"Bar"]
    
  • Run the target
    $ run a.out
    
  • Step in
    $ s
    
  • Step over (next)
    $ n
    
  • Print the stack trace
    $ st
    
From now do as usual...
More Commands on lldb-gdb table

2016/01/23 Example: Debug Nodejs

We download nodejs from github and build it with the DEBUG configuration
git clone https://github.com/nodejs/node.git
cd node/
./configure
make -C out BUILDTYPE=Debug # I got this information by reading the Makefile :)
At this point we have a binary with debug information in out/Debug/. Let's start the lldb on it
cd out/Debug
lldb
On lldb, create a target, set some breakpoints and run it
(lldb) target create node
(lldb) b /Users/ignacio/Documents/github/node/src/node.cc:4127
(lldb) run node /Users/ignacio/Downloads/node-js-bug--debug-gets-stuck-on-two-c-commands/perlito5.js

Now keep on debugging :)

This work is licensed under BSD Zero Clause License | nacho4d ®