Skip to content

Instantly share code, notes, and snippets.

@rchl
Forked from ryanchang/lldb_cheat_sheet.md
Last active March 16, 2016 10:46
Show Gist options
  • Save rchl/cae902d181c3c2f62eda to your computer and use it in GitHub Desktop.
Save rchl/cae902d181c3c2f62eda to your computer and use it in GitHub Desktop.
LLDB Cheat Sheet

LLDB Cheat Sheet

A complete gdb to lldb command map.

Print out

  • Print object
(lldb) po responseObject
(lldb) po [responseObject objectForKey@"state"]
  • p - Print primitive type

Breakpoints

  • List breakpoints
br l
  • br delete - Delete breakpoint
(lldb) br delete 1
  • br e - Enable breakpoint
  • br di - Disable breakpoint
  • b - Add breakpoint
(lldb) b MyViewController.m:30
  • br set - Add symbolic breakpoint
(lldb) br set -n viewDidLoad
  • Conditional break
for(PlayerItem *item in player.inventory) {
    totalValue += item.value;
}

Set a conditional breakpoint that triggers only when totalValue is greater than 1000:

(lldb) b MerchantViewController.m:32
Breakpoint 3: where = lootcollector`-[MerchantViewController] ...
(lldb) br mod -c "totalValue > 1000" 3

Reset the condition:

(lldb) br mod -c "" 3
  • Run a debugger command from a breakpoint
(lldb) br com add 2
Enter your debugger command(s). Type 'DONE' to end.
> bt
> continue
> DONE
  • Resume excution
(lldb) continue
  • Step over
(lldb) n
  • Step in
(lldb) s

Frames

  • Print backtrace
(lldb) bt
  • Select different frame
(lldb) f 12
  • Change to a frame that called current frame
(lldb) up
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment