LLDB

lldb

顯示 p po

p/t # 2進位
p/x # 16
清單

po x
po $0

p (void)NSLog(@”%@”,[self.view viewWithTag:1001])
p (CGRect)[self.view frame]

修值 expr

1
2
var a = 1
print(a)
1
expr a = 10
宣告值
1
expt $b = 10

執行無回傳值 call

bt

bt # 目前 thread
bt all # 所有 thread

image lookup –address 0x0000000100004af8
im loo -a

frame info # 當前執行的文件行數
frame variable = p

Thread Return NO

別名
command alias ioa image lookup –address %1
ioa 0x0000000100004af8

斷點

執行到下個斷點
process continue = continue = c

下一步 (step over)
thread step-over = next = n

下一步 (step in)
thread step in = step = s

breakpoint list = br li
breakpoint enable
breakpoint disable

python

script # python REPL
command script import ~/myCommands.py
/.lldbinit # 或者將指令放在這

lldb /Projects/Sketch/build/Debug/Sketch.app
$ lldb
(lldb) file /Projects/Sketch/build/Debug/Sketch.app

ty l
(lldb) type lookup ErrorType
protocol ErrorType {
var _domain: Swift.String { get } var _code: Swift.Int { get }
}

expr @import UIKit
touch ~/.lldbinit
echo display @import UIKit >> ~/.lldbinit
echo target stop-hook add -o \”target stop-hook disable\” >> ~/.lldbinit

斷點在 error
br s -E objc
br s -E swift

斷點在 特定 error
br s -E swift -O EnumError

fr v
frame variable
frame variable theYear
frame variable —-format hex theYear

CustomStringConvertible : print()
CustomDebugStringConvertible : debugPrint()
CustomPlaygroundQuickLookable
CustomReflectable : po

1
2
3
4
5
6
7
8
9
extension TemperatureData : CustomReflectable {
func customMirror() -> Mirror {
return Mirror(self, children: [
"Time" : "\(Time)", // CustomStringConvertible from previous slide
"Temp C" : Temperature,
"Temp F" : 1.8*Temperature+32
])
}
}

斷點
fb:chisel
gdb to lldb
縮寫
LLDB调试命令初探
浅谈LLDB调试器