如何让eclipse cdt显示运行时错误(例如分段错误)
我在 Linux 上的 Eclipse CDT 中开发并运行 C++ 程序。
问题是Eclipse CDT在控制台中没有显示任何运行时错误消息(例如分段错误),而当我直接使用命令行运行程序时可以得到这样的错误消息。
I develop and run C++ program in Eclipse CDT on Linux.
The problem is that Eclipse CDT does't show any runtime error message (e.g. segmentation fault) in console, while I can get such error message when running program directly with command line.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试修改运行配置,例如此
/bin/sh
-c "Debug/name_of_executable arg0 arg1 ... 2> /dev/stdout"
(将“arg0 arg1 ...”替换为您的程序参数(如果有)
Eclipse 控制台将输出 stdout、stderr 和分段错误消息(前缀为“/bin/sh: line 1 ...”)
注意:我在旧版本的 eclipse 上使用了此解决方案症状是相同的。
You could try to modify the run configuration like this
/bin/sh
-c "Debug/name_of_executable arg0 arg1 ... 2> /dev/stdout"
(replace "arg0 arg1 ..." with your program arguments, if any)
The eclipse console will output both stdout, stderr and the segmentation fault message (prefixed with "/bin/sh: line 1 ...")
note: I used this solution on an older release of eclipse for which the symptoms are the same.
我建议您使用调试器而不是仅仅运行可执行文件!
当我尝试将现有的 C++ 解决方案导入 CDT 时,我遇到了同样的问题。我发现 Eclipse 在发生分段错误时没有报告任何内容,这有点奇怪。如果您使用调试器,它会通知您分段错误并指出代码中的正确位置。
I would recommend that you use the debugger instead of just running the executable!
I had the same problem when trying to import an existing c++ solution into CDT. I found it a bit odd that Eclipse didn't report anything in case of an segmentation fault. If you use the debugger, it will notify you of the segmentation faults and point you to the correct place in the code.