如何调试应用程序的根在Eclipse在Ubuntu? [英] how to debug application as root in eclipse in Ubuntu?
问题描述
我使用libpcap的编程。当我调试在正常模式下的应用,PCAP不能得到网络设备。看来,我必须调试根应用程序。
如何调试根应用?我有root密码。
我认为日食具有可用于调试应用程序添加根这样的选择,但我不知道该怎么做。
请帮忙。
- 启用您的用户运行 GDB 作为root没有被要求为已任
密码:结果须藤visudo命令
结果
添加以下行所有其他规则后:结果< youruser> ALL =(根)NOPASSWD:在/ usr / bin中/ GDB
- 创建或修改调试配置在蚀运行GDB作为root结果
例如在运行>调试配置> C / C ++应用程序> YourProject调试:结果
从更改GDB
调试>首页> GDB调试器sudo的-u< youruser> GDB
更新(和警告!):
在他的评论中nategoose指出,这个答案应该有一个警告:
启用用户使用须藤
为 GDB
就像我的回答提出的其实给了管理员权限给他/她的的,在许多情况下可能是不希望的副作用。因此,我认为答案相应的在它没有假设用户将试图损害系统的环境中(例如,它是你自己的个人计算机或虚拟机)
有关的多(非信任)用户环境,我想这可能是一个更好的idead利用 UNIX'文件的能力,使 GDB
来,而不需要管理员权限
I'm programming application using libpcap. when I debug the application in normal mode, pcap cannot get the network device. it seems that I have to debug the application in root. How can I debug the application in root? I have the root password. I think eclipse has such an option that can add root for the debugging application,but I don't know how to do it. please help.
- Enable your user to run gdb as root without being asked for any
password:
sudo visudo
Add the following line after all other rules:
<youruser> ALL=(root) NOPASSWD:/usr/bin/gdb
- Create or modify a debug configuration in eclipse to run gdb as root
e.g. in Run > Debug Configurations > C/C++ Application > YourProject Debug:
change Debugger > Main > GDB debugger fromgdb
tosudo -u <youruser> gdb
Update (and warning!):
In his comment nategoose pointed out that this answer should come with a warning:
Enabling a user to use sudo
for gdb
like suggested in my answer in fact gives admin privileges to him/her which in many cases might be an undesired side effect. I therefore consider the answer appropriate in an environment where it's not assumed that the user would try to harm the system (e.g. it's your own personal computer or a virtual machine)
For a multi-(non-trusted)-user environment I think it might be a better idead to utilize unix' file capabilities to enable gdb
to debug an application without the need of admin privileges
这篇关于如何调试应用程序的根在Eclipse在Ubuntu?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!