xcode 附加到远程进程以进行调试
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/180987/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Attaching to a remote process for debugging
提问by fuad
Using Xcode 3.1 on OSX 10.5; is it possible to attach (the debugger) to a running remote process?
在 OSX 10.5 上使用 Xcode 3.1;是否可以将(调试器)附加到正在运行的远程进程?
I know that it's possible to start and debug a remote process (as explained here), but it would be great if I could find a way to attach to an already running remote process...
我知道,这是可能的启动和调试远程过程(如解释在这里),但是这将是巨大的,如果我能找到一种方法来连接到一个已经运行的远程过程...
edit to add: Thanks. I've submitted a bug report to Apple. Will update this question if/when I hear back from them.
编辑补充:谢谢。我已向 Apple 提交了错误报告。如果/当我收到他们的回复时会更新这个问题。
回答by mfazekas
There is no nice gui for it in XCode but you can do it this way:
XCode 中没有很好的 gui,但你可以这样做:
- start a second instance of the program from XCode with remote debugging,
- use the GDB attach command from the console
- 通过远程调试从 XCode 启动程序的第二个实例,
- 从控制台使用 GDB attach 命令
Step by step instructions:
分步说明:
Follow Apple's instructionsto set up remote debuging:
Find out the process-idof the running instance of your program on the remote box:
ssh "remotemachine" 'ps -x -w -w' | grep "AppName"
(you can also use ARD and ActivityMonitor)
Put a breakpoint to your app main, and start a second instance from the Debugger (on the remote box)
In the GDB console (Run/Console menu) enter:
attach process-id
Now you have you XCode attached to the running process. You can now use the graphical debugger.
按照 Apple 的说明设置远程调试:
在远程机器上找出正在运行的程序实例的进程 ID:
ssh "远程机器" 'ps -x -w -w' | grep“应用程序名称”
(您也可以使用 ARD 和 ActivityMonitor)
在您的应用程序主程序中放置一个断点,然后从调试器(在远程框上)启动第二个实例
在 GDB 控制台(运行/控制台菜单)中输入:
附加进程ID
现在您已将 XCode 附加到正在运行的进程。您现在可以使用图形调试器。
(In early XCode, there was no GUI for attaching to local processes, so this trick/hack was the solution...)
(在早期的 XCode 中,没有用于附加到本地进程的 GUI,所以这个技巧/hack 是解决方案......)