c++ - 在 eclipse 4.16.0 中启用 pretty-print 在 Windows 10 上不起作用

标签 c++ eclipse vector gdb

我在 Windows 10 上使用 eclipse 4.16.0 和 Mingw-w64。我的 gdb(8.1) 版本支持 python。我的机器上有 python 2.7.9(与我在 Mingw-w64 文件夹中找到的 python 版本兼容)。问题是当我在eclipse中检查“在变量/表达式树中启用 pretty-print ”选项时;这不起作用,因为我仍然无法在调试器窗口中看到 std::vector 的元素。我搜索并找到了这个页面:https://wiki.eclipse.org/CDT/User/FAQ#How_can_I_inspect_the_contents_of_STL_containers.3F作为指导,但我认为这没有更新,因为 pretty-print 选项已经存在于 Eclipse 中。
当我运行 info pretty-printers在 gdb 中;事情看起来不错!所有容器和迭代器都会出现。我还检查了 gdbinit 的内容,它包含:

python
import sys
sys.path.insert(0, sys.path[0] + '/../../gcc-8.1.0/python')
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
end
所以,我认为这https://sourceware.org/gdb/wiki/STLSupport不应该这样做。我对吗?
如果有人能帮助我找出问题所在,我将不胜感激。

最佳答案

我找到了解决方案!
事实上,即使使用最新版本的 eclipse 和支持 python 的 Mingw-w64,也有一些事情需要手动完成。
首先,确保您的系统上正确安装了 python 2.7(与 Mingw 支持的版本兼容)。这意味着将 python 路径添加到系统的环境中。
其次,在我的情况下,唯一应该做的是在以下目录中修改 .gdbint :
C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\etc
修改成indisde ''是python 27的路径
我的 .gdbint 现在包含:
Python
导入系统
sys.path.insert(0, 'C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\share\gcc-8.1.0\python')
从 libstdcxx.v6.printers 导入 register_libstdcxx_printers
register_libstdcxx_printers(无)
结尾
然后,最后一步是调试配置;编辑配置/调试器
您只需按以下方式更改 gdb 命令文件:
C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\etc\gdbinit

关于c++ - 在 eclipse 4.16.0 中启用 pretty-print 在 Windows 10 上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63649565/

相关文章:

c++ - Qt:对于生产者-消费者模式中的消费者来说,这是正确的退出方式吗?

java - 如何在本地运行 DropWizard/Jersey 服务器而无需重新启动和重新打包以获取 Assets 文件更新?

java - 如何将多个 Java 文件漂亮地打印到单个页面上?

使用线程 : can it be optimized further? 对 HUGE vector 的 C++ 操作

c++ - 候选函数不可行:没有已知的从 std::vector 到 std::vector 的转换

c++ - 使用循环遍历三角形内的所有点

C++ 数学问题和 5/4*pi 与 5*pi/4

c++ - 如何在 OpenCV 2.3.1 中使用轮廓?

c++ - 类初始化中的静态 lambda

eclipse - 如何在 Eclipse 插件中指定和读取属性