如何更改 eclipse 在 linux 中调用 gdb 的方式?
简而言之,我需要了解如何配置 eclipse 来运行“optirun gbd”而不是“gdb”。下面是我想要完成的具体任务的解释。
我需要在 eclipse 中运行我的调试应用程序,以便它将使用 nvidia optimus 卡而不是集成卡。我的应用程序需要 opengl 支持,只能通过这种方式获得。
我有一台带有 nvidia optimus 显卡的笔记本电脑。我正在运行Linux(ubuntu)。我已经成功设置了 bumblebee,这样我就可以利用 optimus 技术了。这要求,要使用 nvidia 卡,我需要使用程序“optirun:”optirun foo
运行给定的程序“foo”。
我需要配置 Eclipse 以在 optirun 下以调试模式启动我的程序。如果我从命令行运行:optirun gdb app
一切都会按预期工作。
编辑:将调试配置中的“GDB 调试器”字段更改为 optirun gdb 不起作用。然而,通过 optirun eclipse
启动 eclipse 确实如此。但这会损害电池寿命。
In short, I need to understand how to configure eclipse to run "optirun gbd" instead of "gdb". An explanation of what exactly I'm trying to accomplish follows.
I need to run my debug app in eclipse such that it will use the nvidia optimus card instead of the integrated card. My app requires opengl support that is only available this way.
I've got a laptop with an nvidia optimus video card. I'm running linux (ubuntu). I've successfully set up bumblebee such that I can take advantage of the optimus technology. This requires that, to use the nvidia card, I run a given program "foo" with the program "optirun:" optirun foo
.
I need to configure eclipse to launch my program in debug mode under optirun. If I run from command line: optirun gdb app
everything works as expected.
Edit: Changing the "GDB Debugger" field inside the debug configuration to optirun gdb
does not work. Lanching eclipse by optirun eclipse
does, however. But this is a detriment to battery life.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
转到“调试配置”,打开“调试器”选项卡。将“GDB 调试器”从
gdb
更改为optirun gdb
。适用于 Eclipse Juno、Ubuntu 12.04。
Go to "Debug Configurations", open "Debugger" tab. Change "GDB debugger" from
gdb
tooptirun gdb
.Works in Eclipse Juno, Ubuntu 12.04.
由于我确信 Eclipse 使用 shell 来执行程序,因此解决方法是在
~/.bashrc
中将gdb
别名为optirun gdb
Since I'm sure eclipse uses the shell to execute the program, a workaround is to alias
gdb
tooptirun gdb
in~/.bashrc
我今天研究了这个问题,找到了另一个解决方案。只要您安装了 Bumblebee (http://www.bumblebee-project.org/) 并且您知道可以将 optirun 附加到可执行文件(例如尝试使用 glxgears),您就可以将其附加到 cuda-gdb。
我所做的是创建一个脚本:
并将其保存到 /usr/local/cuda/bin 或其他无关紧要的地方,并具有适当的执行权限(755)。
它的作用非常简单,它运行 optirun cuda-gdb args,其中 args 是命令行发送给它的任何内容。
在终端中,只需运行带或不带参数的 opti_cuda-gdb 即可。
例如,我将其命名为 opti_cuda-gdb 并将其放置在该目录中(如果正确配置了 CUDA,则可以方便地将其添加到路径中)。
如果您使用 IDE 进行开发(例如 Netbeans),请将调试器可执行文件指向该脚本。
我已经使用 CuSparse 和 CuBlas 以及在配备 Nvidia Optimus 和 Ubuntu 11.04 和 11.10 的 SAMSUNG SF410 中运行的 NetBeans 成功编译和调试了代码。
如果您认为我遗漏了某些内容,我愿意提供更多详细信息。
I look into this issue today and I found another solution. As long as you have Bumblebee installed (http://www.bumblebee-project.org/) and you know you can attach optirun to an executable (try with glxgears for example) you can attach it to cuda-gdb.
What I did is create a script:
And save it to /usr/local/cuda/bin or somewhere else it doesn't matter, with the appropriate permissions for execution (755).
What it does is very simple, it runs optirun cuda-gdb args where args is whatever the command line sends it.
In terminal just run opti_cuda-gdb with or without arguments.
For example I named it opti_cuda-gdb and placed it in that directory (which conveniently is added to the path if CUDA is properly configured).
If you use an IDE to develop, like say Netbeans, point the debbuger executable to that script.
I've been successfully compiled and debbuged code using CuSparse and CuBlas with NetBeans running in a SAMSUNG SF410 with Nvidia Optimus and Ubuntu 11.04 and 11.10.
I'm open to provide further details if you think I omitted something.