This is a cheatsheet - starting point to look for things that you can do.
Avoided complex / 3rd party things as they require some additional setup that may not be allowed in certain projects.
Breakpoints
- Breakpoint is user enabled point in code where the application pauses
- Line and column breakpoints
- Pauses the program before the statement on line/column is executed
- Conditions
- Execute walk method just for LadyBug:
self.bugType == 1
- Execute walk method just for LadyBug:
- Actions: Sound, Log message, Debug command
- Symbolic breakpoints: Add breakpoint on a method without source file
[UIImage systemImageNamed:]
-
po $arg1
-> Receiver object -
po $arg2
->po (SEL)$arg2
-> Method name -
po $arg3
-> First argument, and goes
-
- Watch points: Pauses when the value changes
LLDB commands
-
help
: Information about commands -
v
: Does not compile the expression instead it just dumps value from the stack -
p
: Evaluates and prints the output -
po
: Evaluates the print debug output-
description
method - Use
[]
syntax if.
is failing due to typecasting
-
-
expression
: Evaluates and prints, also stores the output in a variable- Expressions in other languages:
expression -l swift/objc -O -- <code>
- Expressions in other languages:
-
alias
: Creates a shortcut for complex commandscommand alias greet p @"Hello World"
Techniques
- Inject code without building it:
expression <sample fix/feature>
expr [bugs addObjectsFromArray:[[self makeAntViews:20] mutableCopy]]
- Short circuit / skip code execution:
- Move the debugger handle
thread jump --by 1
- Early return through a method:
thread return <return value>
- NOTE: This does not always work and can be dangerous
- Print the view hierarchy:
po [self.view recursiveDescription]
- Highlight a view:
(UIColor *)[bug setBackgroundColor:UIColor]
-
(void)[CATransition flush]
: Refreshes UI
- Add delay in code:
expr [NSThread sleepForTimeInterval:2]
- Auto layout debugging:
po [self.view _autolayoutTrace]
References:
Top comments (0)