在使用手机里面的/Developer/usr/bin
的debugserver
进行lldb
调试的时候,一直出现如下问题:
我碰到的问题
Listening to port 12345 for a connection from localhost...
Failed to get connection from a remote gdb process.
Exiting.
iPhone:/usr/bin root# debugserver localhost:12345 -a 10658
Killed: 9
找了许久,就是权限的问题,但是具体怎么改,根据不同的系统和Xcode
版本不一样。
首先Mac电脑要装有ldid,可通过brew install ldid
安装
1、将手机上的debugserver拷贝到当前出来,到当前目录下:scp -P 2222 root@localhost:/Developer/usr/bin/debugserver ./
2、使用ldid命令导出entitlements权限文件:ldid -e debugserver > debugserver.entitlements
,然后将权限文件修改成下面的代码部分,找对应的,该添加的添加,该删的删。
3、再使用修改后的权限文件重签debugserver文件:ldid -Sdebugserver.entitlements debugserver
4、最后将重签后的debugserver
文件复制到手机的/usr/bin/
目录下:scp -P 2222 debugserver root@localhost:/usr/bin
,相当于配置环境变量,这样就可以在任意路径下使用debugserver
了
将权限文件修改成下面的:
<?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>platform-application</key>
<true/>
<key>run-unsigned-code</key>
<true/>
<key>com.apple.system-task-ports</key>
<true/>
<key>com.apple.backboardd.launchapplications</key>
<true/>
<key>com.apple.frontboard.debugapplications</key>
<true/>
<key>com.apple.springboard.debugapplications</key>
<true/>
<key>com.apple.security.network.server</key>
<true/>
<key>get-task-allow</key>
<true/>
<key>com.apple.private.memorystatus</key>
<true/>
<key>com.apple.backboardd.debugapplications</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.diagnosticd.diagnostic</key>
<true/>
<key>com.apple.frontboard.launchapplications</key>
<true/>
<key>com.apple.private.cs.debugger</key>
<true/>
<key>task_for_pid-allow</key>
<true/>
</dict>
</plist>
在手机上附加进程,使用命令:debugserver localhost:端口号 -a 进程id
就进入了通过本地服务监听端口状态,如下图:
新建一个终端窗口,进入LLDB调试环境,输入:process connect connect://localhost:端口
,这时可能会出现如下提示Failed to connext port
,此时莫慌,还需要一个端口映射。
笔者是通过sh usbConnect.sh
完成端口映射,因为我配置了:python /Users/psy/.psy/PSYshell/python-client/tcprelay.py -t 12345:12345
执行完端口映射之后,再在LLDB环境中执行:process connect connect://localhost:12345
出现如下图,就成功的进入的debugserver调式了,赶紧马不停蹄试一下pvc,输出了我们想要的结果。
网友评论