Ubuntu 16.04,gcc 6:gdb 7.11 Eclipse中的漂亮打印不起作用

时间:2017-02-03 16:05:10

标签: eclipse debugging gdb ubuntu-16.04

为了使用漂亮的打印进行eclipse调试,我遵循了这个问题的答案:
Ubuntu 14.04, gcc 4.8.4: gdb pretty printing doesn't work because of Python issue
但是我在〜/ .gdbinit文件中插入了命令并且它不起作用。通过使用sh -x运行.gdbinit,我得到语法错误:“(”意外。 它似乎是与python命令相关的bash错误。我搜索和尝试的每个解决方案都没有解决问题(e.x使用单引号或不使用;或者在文件开头使用#!/ usr / bin / python或#!/ usr / bin / env python)。有没有人知道如何处理这个?

1 个答案:

答案 0 :(得分:1)

要在ubuntu 16.04(默认gcc,gdb)上启用漂亮打印,需要使用此脚本:

python
sys.path.insert(0, '/usr/share/gcc-5/python')
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
end

你可能需要gcc-6。

在此之后,您需要在eclipse调试配置的调试器选项卡“gdb命令文件”字段中输入上述脚本的完整路径并应用更改。 eclipse debug configuration dialog

通过此调试配置设置启动并在变量视图中检查容器。

作为参考,here是解释此问题的CDT常见问题解答。