LLDB动态调试
LLDB准备工作
复制debugserver文件(这里必须从当前连接手机中复制,不然后面会出错)
scp -P 2222 root@localhost:/Developer/usr/bin/debugserver ./
新建签名文件 env.plist
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>com.apple.springboard.debugapplications</key> <true/> <key>get-task-allow</key> <true/> <key>task_for_pid-allow</key> <true/> <key>run-unsigned-code</key> <true/> </dict> </plist>
使用codesign签名
codesign -s - —entitlements env.plist -f debugserver
把debugserver放回手机,并给予权限
scp -P 2222 ./debugserver root@localhost:/usr/bin/debugserver
开始动态调试
- ps aux查看启动的进程
- debugserver *:1234 -a XXXX(名称或者进程ID)
- mac端终端输入lldb,
- 然后输入process connect connect://<手机IP>:1234 (或者先iproxy 1234 1234转发端口 process connect connect://localhost:1234)
- 按c继续 control + c暂停
image list -o -f 查看程序在内存中的信息
第二列是内存中加载的基地址,第三列是模块全路径和模块真正加载的地址(起始地址+模块在虚拟地址中的内存偏移)
打断点
- b + 内存地址(偏移后的)
- b s -a 偏移地址 + 初始地址
- po $x1…….
- 其它LLDB命令有待实践