如何在 GDB 中漂亮地打印 STL 容器?

新手上路,请多包涵

我已按照 GDB wiki 上 的说明安装用于查看 STL 容器的 python 漂亮打印机。我的 ~/.gdbinit 现在看起来像这样:

 python
import sys
sys.path.insert(0, '/opt/gdb_prettyprint/python')
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
end

但是,当我运行 GDB 并尝试打印 STL 类型时,我得到以下信息:

 print myString
Python Exception <class 'gdb.error'> No type named std::basic_string<char>::_Rep.:
$3 =

任何人都可以对此有所了解吗?我正在运行 GDB 7.4 附带的 Ubuntu 12.04。

原文由 Nick Hutchinson 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 1.2k
1 个回答

类似于在 此处输入链接描述 在 ~/.gdbinit 中为我工作:

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

原文由 Yotam 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题