流程
- 通過mac 電腦生成帶有訪問權(quán)限的debugserver 可執(zhí)行文件;
- 登錄手機(jī)設(shè)置 debugserver 綁定某一個某一個端口 用于某一個進(jìn)程;
- 在mac端中使用 lldb 遠(yuǎn)程連接手機(jī);
可能會遇到的問題
- Failed to get connection from a remote gdb process
解答:使用我的debugserver.entitlements 文件覆蓋你的 - failed to attach to process named: “”
解答:這個就是進(jìn)程名不對,如果不知道進(jìn)程名 可以額通過 ps -A 查詢到你想要調(diào)試的應(yīng)用進(jìn)程名 - error: failed to get reply to handshake packet
解答方案:
debugserver *:10011 -a pinduoduo
變?yōu)?
debugserver localhost:10011 -a pinduoduo
實(shí)現(xiàn)
1.通過mac 電腦生成帶有訪問權(quán)限的debugserver 可執(zhí)行文件;
通過ifunbox 訪問越獄手機(jī)拿到/Developer/usr/bin/debugserver
把手機(jī)端的debugserver 文件copy 到mac 電腦中
通過ldid 給 debugserver 添加權(quán)限
# 3.1 這個是倒出可執(zhí)行文件 debugserver 的權(quán)限 覆蓋到 debugserver.entitlements 文件中
ldid -e debugserver > debugserver.entitlements
# 3.2 打開debugserver.entitlements文件并添加如下兩個權(quán)限
key:get-task-allow type:Boolean Value:1
key:task_for_pid-allow type:Boolean Value:1
# 把權(quán)限debugserver.entitlements 簽給可執(zhí)行文件 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>
把添加過權(quán)限的debugserver文件copy 到手機(jī)中的 usr/bin/目錄下面
給debugserver 添加可執(zhí)行權(quán)限
chmod +x debugserver
2. 登錄手機(jī)設(shè)置 debugserver 綁定某一個某一個端口 用于某一個進(jìn)程;
# 讓debugserver附加到某一個app進(jìn)程
debugserver *:端口號 -a 進(jìn)程名
例如: debugserver *:10011 -a pinduoduo
成功截圖:
1.附加到否一個app進(jìn)程.jpeg
3. 在mac端中使用 lldb 遠(yuǎn)程連接手機(jī);
# 1. 啟動LLDB
終端中輸入:lldb
# 2.鏈接debugserver服務(wù)
終端中輸入:(lldb) process connect connect://手機(jī)IP地址:debugserver服務(wù)端口號
例如: process connect connect://localhost:10011
# 3.使用LLDB的命令讓程序繼續(xù)運(yùn)行起來
終端中輸入:(lldb) c
例如: c
成功截圖:
2.通過lldb連接到debugserver.jpeg