问题描述
我想检查GDB中 std :: vector
的内容,该怎么做?假设为了简单起见,这是一个 std :: vector< int>
。
I want to examine the contents of a std::vector
in GDB, how do I do it? Let's say it's a std::vector<int>
for the sake of simplicity.
推荐答案
要查看向量std :: vector myVector内容,只需键入GDB:
To view vector std::vector myVector contents, just type in GDB:
(gdb) print myVector
这将产生类似于
$1 = std::vector of length 3, capacity 4 = {10, 20, 30}
要实现上述,您需要有gdb 7(我在gdb 7.01上测试过)和一些python漂亮的打印机。这些安装过程在中有所描述。
To achieve above, you need to have gdb 7 (I tested it on gdb 7.01) and some python pretty-printer. Installation process of these is described on gdb wiki.
此外,在安装上述之后,这可以很好地与 Eclipse C ++调试器GUI(以及任何其他使用GDB的IDE一起使用,如我所想)。
What is more, after installing above, this works well with Eclipse C++ debugger GUI (and any other IDE using GDB, as I think).
这篇关于如何在GDB中打印C ++矢量的元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!