附加到远程进程进行调试

编程入门 行业动态 更新时间:2024-10-09 10:19:50
本文介绍了附加到远程进程进行调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 在OSX 10.5上使用Xcode 3.1;是否可以将(调试器)附加到正在运行的远程进程?

我知道可以启动和调试远程进程(如 here ),但是如果我可以找到一种方法来附加到已经运行的远程进程,那将是很好的...

编辑添加:谢谢。我向苹果提交了一个错误报告。如果/当我听到他们的话,会更新这个问题。

解决方案

在XCode中没有很好的gui,但是你可以这样做:

  • 通过远程调试从XCode启动程序的第二个实例,
  • 使用控制台中的GDB attach命令
  • 分步说明:

  • 按照Apple的说明设置远程调试:

  • 找出您的程序运行实例的远程框中的:

    sshremotemachine'ps -x -w -w' grepAppName

    (您也可以使用ARD和ActivityMonitor)

  • 将断点您的应用程序主机,并从调试器(在远程框上)启动第二个实例

  • 在GDB控制台(运行/控制台菜单)中输入: p>

    附加 process-id

  • 现在你有XCode附加到运行过程。您现在可以使用图形调试器。

  • (在早期的XCode中,没有GUI附加到本地进程,所以 this技巧/黑客是解决方案... )

    Using Xcode 3.1 on OSX 10.5; is it possible to attach (the debugger) to a running remote process?

    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.

    解决方案

    There is no nice gui for it in XCode but you can do it this way:

  • start a second instance of the program from XCode with remote debugging,
  • use the GDB attach command from the console
  • Step by step instructions:

  • Follow Apple's instructions to set up remote debuging:

  • Find out the process-id of 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.

  • (In early XCode, there was no GUI for attaching to local processes, so this trick/hack was the solution...)

    更多推荐

    附加到远程进程进行调试

    本文发布于:2023-06-02 00:51:55,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/431014.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:进程

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!