Skip to content

Instantly share code, notes, and snippets.

@SheldonWangRJT
Created March 30, 2018 02:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SheldonWangRJT/b9e89696fcae075630bb09b72b436c1d to your computer and use it in GitHub Desktop.
Save SheldonWangRJT/b9e89696fcae075630bb09b72b436c1d to your computer and use it in GitHub Desktop.
iOS Most Useful Debug Tricks
1. objc_exception_throw
When breakpoint auto landed on the assembly page, try to type
(lldb) po $arg1
(lldb) po [$arg1 name]
(lldb) po [$arg1 reason]
This may bring extra info, like "xxx is nil"
[1.1] https://stackoverflow.com/questions/3327828/xcode-lldb-how-to-get-information-about-an-exception-that-was-just-thrown
[1.2] https://www.natashatherobot.com/xcode-debugging-trick/
2. Double click break point to set break conditions & additional actions
3. Add watchpoint to observe a variable changes (assuming we have a variable called "places"). Think this thing similar as the observing mechanical of iOS.
(lldb) watchpoint set variable places
https://developer.apple.com/library/content/documentation/General/Conceptual/lldb-guide/chapters/C3-Breakpoints.html
4. Debug with memory address, it may point out the file and line of the code
(lldb) image lookup --address 0x1000
5. "e" in lldb
other than (lldb) po view, (lldb) e view will give you more info
6. Other lldb commands
LLDB cheat sheet: https://drive.google.com/file/d/0B-SXq8rl5R6RZ0FTekpXX0YwY28/view?usp=sharing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment