Did you know that you can navigate the posts by swiping left and right?
1.What's and why lldb?
2.LLDB commands usage.
3.Applications
4.Python lldb
5.References ### What's and why lldb?
LLVM(Low Level Virtual Machine)是一个编译器基础架构的工程。其旨在通过提供一组带有良好定义接口可充用的库,用于编译器前端和后端的开发。 经典编译器3阶段设计: ![Class compiler three-phases](https://raw.githubusercontent.com/kangwang1988/kangwang1988.github.io/master/img/classic-compiler-three-phase.png) LLVM的3阶段设计 ![LLVM three-phases](https://raw.githubusercontent.com/kangwang1988/kangwang1988.github.io/master/img/llvm-compiler-three-phases.png)
process connect connect://10.0.77.165:1234
attach/detach,
continue/interrupt,
load/unload,
launch/signal/kill
set/list/enable/disable/delete
add/dump/list/load/lookup
打印层次:
po [aView recursiveDescription]
更改UI:
expression [self.tableView setBackgroundColor:[UIColor redColor]
expression (void)[CATransaction flush]
Create/Init/push a VC is also available.
Approach 1:
Method Swizzle(hook).
Approach 2:
breakpoint set -r “initWithTitle:*” ![Application:Alert from3](https://raw.githubusercontent.com/kangwang1988/kangwang1988.github.io/master/img/lldb-application-br-initwithtitle.png)
Approach 1:
Override Setter
Approach 2:
KVO
Approach3:
watchpoint set expression self.dataModel->_dataSource ![Application:Data changed3](https://raw.githubusercontent.com/kangwang1988/kangwang1988.github.io/master/img/lldb-application-watchpoint-who-changed-the-data2.png)
debugserver是用于辅助gdb或者lldb远程调试的命令行APP。当iOS设备用于开发时其会被安装。Xcode 调试时,会触发此进程用于远程调试。
越狱设备调试时,首先拷贝debugserver到越狱机,然后使用debugserver启动需要调试的APP, lldb(gdb)使用gdb-remote协议,在debugserver的协助下,实现调试功能。
Mac
target create /bin/ls
breakpoint set --name malloc
process launch /bin/ls
或process attach —pid 123/—name Safari
iOS
远程调试:
ssh(越狱)
debugserver(ios)
lldb(mac)
代码:
Write Python module with a command function like:
def <function>(debugger, command, result, internal_dict)
使用:
Import module into LLDB(~/.lldbinit)
(Bind Python function to command) ![Python Plugin](https://github.com/kangwang1988/kangwang1988.github.io/raw/master/img/lldb-python-plugin-for-lld.png)
SBDebugger:(SB is abbr for Scripting bridge)
The command interpreter,Always be one.
SBTarget:
Represents the target program under debugger.
SBProcess:
Contains the process of the selected target.
SBThread:
Contains the process of the currently select thread.
SBFrame:
Contains the selected frame.
SBValue:
An object that encapsulates data objects.
LLDB tutorials in Raywenderlich