3. Everyone knows that debugging is twice as hard
as writing a program in the first place. So if you're
as clever as you can be when you write it, how
will you ever debug it?
Brian Kerninghan
5. Basic notions
○ Debug bar
○ (de)activate breakpoints
○ Continue execution
○ Step over
○ Execute current line and go to the next
○ Step in
○ “enter” the called method/function
○ Step out
○ “exit” the called method/function
7. Basic notions
○ watchpoint
○ Behaviors like a breakpoint
○ Stop at value change
○ Variable or memory address
○ Command line
○ Click
○ view memory
○ breakpoint navigator
○ edit
○ condition
○ action
8. lldb - low level debugger
○ Have you done that?:
print("log just for debug: (self.object)")
○ Or that?
let n = 0 // self.someMethodThatReturnInteger()
○ Or that?
if true !|| self.someMethodThatReturnBool() {
○ Or that?
func someMethodThatReturnBool() !-> Bool {
return true !//TODO: implement
}
9. lldb - breakpoints
○ Breakpoint stop execution of a instruction
○ Allow add command just for debug
○ May have stop condition
○ Via command
breakpoint set —file ViewController.swift —line 7
○ One shot - code execute just once, automatically removed
breakpoint set —oneshot true —name MyType.myMethod()
○ Via Xcode - just click gutter
17. Expressions
○ Evaluated as code
○ Result is shown and storage in convenience variable ($1, $2, etc)
○ Can do a lot
○ Arithmetic
○ function/method calling
○ type casting
○ Attributions
○ Variable declaration (let variable: Type = value)
18. lldb - mais expressões
(lldb) e let user.name = “John Doe”
(lldb) e let $count = 42
(lldb) po $count
42
(lldb) e let $dict: Dictionary<String, Int> = ["answer": 42]
(lldb) po $dict
▿ 1 element
▿ 0 : 2 elements
- key : "answer"
- value : 42
19. lldb - low level debugger
○ Watchpoint
○ Monitor state/value of a variable
○ Variable inspector
20. lldb - low level debugger
○ Watchpoint
○ Monitor state/value of a variable
○ Since Xcode 10 shown in breakpoint navigator
21. lldb - low level debugger
○ Rule of Thumb - keep it fast
○ “Automatically continue after evaluating”
○ po $arg1
○ Audible breakpoints
○ breakpoint with shell command
○ Command: say
○ Arguments: -v, Zarvox, “Your breakpoint %B has been hit %H times”
23. N Ó S M O V E M O S O M U N D O .
RIO SÃO PAULO BH RECIFE
Centro
Av. Presidente Wilson, 231
29º andar
(21) 2240-2030
Cidade Monções
Av. Nações Unidas, 11.541
3º andar
(11) 4119-0449
Savassi
Av. Getúlio Vargas, 671
Sala 800 - 8º andar
(31) 3360-8900
Ilha do Leite
Rua Sen. José Henrique, 199
2º andar
(81) 3018-6299
W W W. C O N C R E T E . C O M . B R