为什么gdb需要root权限来调试用户程序? [英] Why is gdb requiring root permission to debug user programs?

查看:1574
本文介绍了为什么gdb需要root权限来调试用户程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经很成功地使用gdb了一段时间,但是最近我升级了我的Ubuntu版本,现在看来我只能让gdb成功运行我的程序,如果我以root身份运行的话。也就是说,

 〜%gdb -q sleep -ex'run 60'
从/ bin / sleep中读取符号...(没有找到调试符号)...完成。
启动程序:/ bin / sleep 60
tcsh:权限被拒绝。
在启动程序中退出代码1.
(gdb)

失败,而

 〜%sudo gdb -q sleep -ex'run 60'
读取/ bin / sleep中的符号。 ..(没有找到调试符号)...完成。
启动程序:/ bin / sleep 60
正在运行.tcshrc
警告:在添加的符号文件系统提供的DSO中找不到可加载部分0x7ffff7ffa000
^ C
程序接收到信号SIGINT,中断。
0x00007ffff7adada0 in __nanosleep_nocancel()at ../sysdeps/unix/syscall-template.S:82
82 ../sysdeps/unix/syscall-template.S:没有这样的文件或目录。
(gdb)

的作品。一个线索是,在第一种情况下,gdb启动不运行我的.tcshrc文件,而在第二种情况下,它启动。

看起来这是一个简单的权限问题,我必须一次性修复这个问题,因为在过去,我从不需要以root身份运行gdb。然而,经过大量的搜索,我无法找到我可能做了什么(如果我确实做了某件事情)。一个可能的修复 - 设置 ptrace权限 - 似乎不起作用。

有没有需要做的事情来允许gdb运行没有root权限的程序?我知道在OSX中,gdb必须进行编码。 Ubuntu / Linux有类似的东西吗?

解决方案

我将登录shell更改为bash,并且gdb不再需要root权限进行调试。这是最新的:



我的 .gdbinit 文件:

 
(bash)〜%more .gdbinit
show environment SHELL
file / bin / echo
运行'.gdbinit'
(bash )〜%

以及运行结果 gdb

 
(bash)〜%gdb -q -batch
SHELL = / bin / bash
正在运行.gdbinit
[Inferior 1(进程3174)正常退出]
(bash)〜%

我仍然不明白为什么tcsh没有工作,但很想知道。所以如果有人有可能的解释,请评论。


I have been using gdb quite successfully for a while, but I recently upgraded my version of Ubuntu, and now it seems that I can only get gdb to successfully run my program if I run as root. That is,

~ %  gdb -q sleep -ex 'run 60'
Reading symbols from /bin/sleep...(no debugging symbols found)...done.
Starting program: /bin/sleep 60
tcsh: Permission denied.
During startup program exited with code 1.
(gdb)

fails, whereas

~ %  sudo gdb -q sleep -ex 'run 60'
Reading symbols from /bin/sleep...(no debugging symbols found)...done.
Starting program: /bin/sleep 60
Running .tcshrc
warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7ffff7ffa000
^C
Program received signal SIGINT, Interrupt.
0x00007ffff7adada0 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:82
82  ../sysdeps/unix/syscall-template.S: No such file or directory.
(gdb)

works. One clue is that in the first case, the gdb startup doesn't run my .tcshrc file, whereas in the second case it does.

It seems that this is a simple permissions issue, which I must have fixed at one time, because in the past, I have never needed to run gdb as root. After much googling, however, I wasn't able to find what I might have done (if I did in fact do something). One possible fix - set ptrace permissions - didn't seem to work.

Is there something that needs to be done to allow gdb to run programs without root privileges? I know in OSX, gdb has to be codesigned. Is there something similar for Ubuntu/Linux?

解决方案

I changed my login shell to bash and gdb no longer needs root permission to debug. Here is the latest :

My .gdbinit file:

(bash) ~ % more .gdbinit
show environment SHELL
file /bin/echo
run 'running .gdbinit'
(bash) ~ % 

and the results of running gdb :

(bash) ~ % gdb -q -batch
SHELL = /bin/bash
running .gdbinit
[Inferior 1 (process 3174) exited normally]
(bash) ~ % 

I still don't understand why tcsh didn't work, though, and am curious to know. So if anyone has a possible explanation, please comment.

这篇关于为什么gdb需要root权限来调试用户程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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