流程
- 通过mac 电脑生成带有访问权限的debugserver 可执行文件;
- 登录手机设置 debugserver 绑定某一个某一个端口 用于某一个进程;
- 在mac端中使用 lldb 远程连接手机;
可能会遇到的问题
- Failed to get connection from a remote gdb process
解答:使用我的debugserver.entitlements 文件覆盖你的 - failed to attach to process named: “”
解答:这个就是进程名不对,如果不知道进程名 可以额通过 ps -A 查询到你想要调试的应用进程名 - error: failed to get reply to handshake packet
解答方案:
debugserver *:10011 -a pinduoduo
变为:
debugserver localhost:10011 -a pinduoduo
实现
1.通过mac 电脑生成带有访问权限的debugserver 可执行文件;
通过ifunbox 访问越狱手机拿到/Developer/usr/bin/debugserver
把手机端的debugserver 文件copy 到mac 电脑中
通过ldid 给 debugserver 添加权限
# 3.1 这个是倒出可执行文件 debugserver 的权限 覆盖到 debugserver.entitlements 文件中
ldid -e debugserver > debugserver.entitlements
# 3.2 打开debugserver.entitlements文件并添加如下两个权限
key:get-task-allow type:Boolean Value:1
key:task_for_pid-allow type:Boolean Value:1
# 把权限debugserver.entitlements 签给可执行文件 debugserver
ldid -Sdebugserver.entitlements debugserver
debugserver.entitlements 源代码为:
<?xml version="1.0" encoding="UTF-8"?>
<!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.backboardd.debugapplications</key>
<true/>
<key>com.apple.backboardd.launchapplications</key>
<true/>
<key>com.apple.frontboard.debugapplications</key>
<true/>
<key>com.apple.frontboard.launchapplications</key>
<true/>
<key>com.apple.springboard.debugapplications</key>
<true/>
<key>com.apple.system-task-ports</key>
<true/>
<key>get-task-allow</key>
<true/>
<key>platform-application</key>
<true/>
<key>run-unsigned-code</key>
<true/>
<key>task_for_pid-allow</key>
<true/>
</dict>
</plist>
把添加过权限的debugserver文件copy 到手机中的 usr/bin/目录下面
给debugserver 添加可执行权限
chmod +x debugserver
2. 登录手机设置 debugserver 绑定某一个某一个端口 用于某一个进程;
# 让debugserver附加到某一个app进程
debugserver *:端口号 -a 进程名
例如: debugserver *:10011 -a pinduoduo
成功截图:
1.附加到否一个app进程.jpeg
3. 在mac端中使用 lldb 远程连接手机;
# 1. 启动LLDB
终端中输入:lldb
# 2.链接debugserver服务
终端中输入:(lldb) process connect connect://手机IP地址:debugserver服务端口号
例如: process connect connect://localhost:10011
# 3.使用LLDB的命令让程序继续运行起来
终端中输入:(lldb) c
例如: c
成功截图:
2.通过lldb连接到debugserver.jpeg