gdb & lldb

the same debugging moves in both. lldb ships gdb-style aliases, so b r c n s si bt p finish mostly work either way --; the tables show the native lldb command in parentheses where it differs.

jump to: running · breakpoints · stepping · inspecting · stack

running

task            gdb                lldb
run             run                run   (process launch)
run with args   run a b            run a b
attach to pid   attach 123         attach -p 123
open a core     gdb prog core      lldb -c core prog

breakpoints

task            gdb                lldb
at function     b main             b main   (breakpoint set -n main)
at file:line    b file.c:42        b file.c:42   (breakpoint set -f file.c -l 42)
conditional     b f if x==5        breakpoint set -n f -c 'x==5'
list            info breakpoints   breakpoint list
delete #2       delete 2           breakpoint delete 2
watch a var     watch v            watchpoint set variable v

stepping

task            gdb        lldb
continue        c          c
step into       s          s    (thread step-in)
step over       n          n    (thread step-over)
step instr      si         si   (thread step-inst)
step out        finish     finish   (thread step-out)

inspecting

task            gdb              lldb
print expr      p x              p x   (expression x)
print as hex    p/x x            p/x x
examine mem     x/16xb addr      x/16xb addr   (memory read)
all registers   info registers   register read
one register    p $rax           p $rax
locals          info locals      frame variable
disassemble     disassemble      disassemble   (di)
list source     l                l    (source list)

stack & frames

task            gdb          lldb
backtrace       bt           bt   (thread backtrace)
select frame 2  f 2          f 2  (frame select 2)
up / down       up / down    up / down
frame info      info frame   frame info