如何让eclipse cdt显示运行时错误(例如分段错误)

发布于 2024-09-24 04:19:19 字数 122 浏览 0 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

够运 2024-10-01 04:19:19

您可以尝试修改运行配置,例如此

  • 选项卡“Main”>“应用程序 = /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

  • tab 'Main' > Application = /bin/sh
  • tab 'Arguments' > 'Program arguments' = -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.

久隐师 2024-10-01 04:19:19

我建议您使用调试器而不是仅仅运行可执行文件!

当我尝试将现有的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文