以XCode作为root调试 [英] Debugging in XCode as root

查看:1068
本文介绍了以XCode作为root调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的程序中,我需要创建套接字并绑定它们来监听HTTP端口(80)。该程序工作正常,当我从命令行启动它与sudo,权限升级到根。在XCode下运行在调用绑定函数(asio :: ip :: tcp :: acceptor :: bind())时会出现permission denied错误。





使用XCode 3.1.2在Mac OS X 10.5上使用C ++和boost.asio完成所有操作。

解决方案

更新:对于Xcode 4.5及更高版本,请参阅这个答案






我知道做什么的唯一方法要求以root身份运行Xcode。

 >> sudo /Developer/Applications/Xcode.app/Contents/MacOS/Xcode 

root,从Xcode启动的任何进程也将作为root运行。但请注意,如果您创建或编辑任何文件,它们将由root所有,这意味着您必须 chown ,然后才能将它们编辑为正常的用户第一。



我喜欢Xcode说启动过程作为根的方式,但据我所知,没有这样的功能可用。 / p>

请注意,您还可以在命令行调试器 gdb 中运行应用程序来调试应用程序。运行

 >> sudo gdb / path / to / my / application 

然后你可以保持Xcode打开,并在gdb中调试您的程序。

:未来的读者:请参阅Alexander Stavonin的回答;它谈论如何做到这一点。如果你对ssh密钥没问题,并且在系统上启用root用户,他的回答是要走的路。


In my program I need to create sockets and bind them to listen HTTP port (80). The program works fine when I launch it from command line with sudo, escalating permissions to root. Running under XCode gives a 'permission denied' error on the call to binding function (asio::ip::tcp::acceptor::bind()).

How can I do debugging under XCode?

All done in C++ and boost.asio on Mac OS X 10.5 with XCode 3.1.2.

解决方案

Update: For Xcode 4.5 and later, see this answer instead.


The only way I'm aware of to do what you're asking is to run Xcode as root.

>> sudo /Developer/Applications/Xcode.app/Contents/MacOS/Xcode

Once you're running as root, anything processes launched from Xcode will also run as root. Note, though, that if you create or edit any files, they will be owned by root, which means that you'll have to chown them before you can edit them as your normal user first.

I'd love a way for Xcode to say "Launch process as root", but as far as I know, no such functionality is available.

Note that you can also run the application within the command-line debugger gdb to debug your application. Run

>> sudo gdb /path/to/my/application

Then you could keep Xcode open, modify at will, and debug your program within gdb. This is what I generally do.

EDIT: Readers from the future: see the answer from Alexander Stavonin; it talks about how to do this. If you're okay with ssh keys and enabling the root user on your system, his answer is the way to go.

这篇关于以XCode作为root调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆