Skip to content

Instantly share code, notes, and snippets.

@ryanchang
Last active October 31, 2024 21:52
Show Gist options
  • Save ryanchang/a2f738f0c3cc6fbd71fa to your computer and use it in GitHub Desktop.
Save ryanchang/a2f738f0c3cc6fbd71fa 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
  • Print backtrace
(lldb) bt
@rileyrg
Copy link

rileyrg commented Jun 22, 2021

Looking everywhere, can anyone tell me how to stop lldb displaying the source frame after every step? I'm using voltron to display the source so I don't want lldb console repeating it.

@rileyrg
Copy link

rileyrg commented Jun 28, 2021

Looking everywhere, can anyone tell me how to stop lldb displaying the source frame after every step? I'm using voltron to display the source so I don't want lldb console repeating it.

command regex srcb 's/([0-9]+)/settings set stop-line-count-before %1/'
srcb 0
command regex srca 's/([0-9]+)/settings set stop-line-count-after %1/'
srca 0

@Andy0570
Copy link

@joansola
Copy link

joansola commented Jun 29, 2022

Since there is a way to set a breakpoint based on function name:

breakpoint set --name foo

I wonder: is there a way to delete the breakpoint based ALSO on function name? This does not work:

breakpoint delete --name foo

I want to automate these things, so I cannot use

breakpoint delete ID

unless I have a way to extract the ID automatically from the name.

Any idea is welcome!

@jeffron256
Copy link

Appreciate your help man

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment