如何在Ubuntu中的eclipse中以root身份调试应用程序? [英] how to debug application as root in eclipse in Ubuntu?
问题描述
如何在根目录中调试应用程序?我有root密码
我认为eclipse有一个可以为调试应用程序添加root的选项,但是我不知道如何做。
请帮忙。
- 让您的用户运行 gdb 作为root用户,而不需要任何
密码:
sudo visudo
在所有其他规则之后添加以下行:
< youruser> ALL =(root)NOPASSWD:/ usr / bin / gdb
- 在 eclipse 以root身份运行gdb
eg在运行>调试配置> C / C ++应用程序> YourProject Debug:
更改Debugger> Main> GDB调试器从gdb
到sudo -u< youruser> gdb
更新(和警告!):
他的评论中指出,这个答案应该会出现警告:
使用户可以使用 sudo
for gdb
像我的答案中所建议的实际上给予他/她的管理员权限,这在许多情况下可能是不利的副作用。因此,我认为在不假定用户会试图伤害系统的环境中(例如,您自己的个人计算机或虚拟机),答案是适当的。
一个多(不可信)的用户环境,我认为使用 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
这篇关于如何在Ubuntu中的eclipse中以root身份调试应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!