如何使用GDB 7.x查看STL容器的内容 [英] how to view contents of STL containers using GDB 7.x
本文介绍了如何使用GDB 7.x查看STL容器的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在使用宏解决方案,此处 a>。但是,有一个提到如何查看他们没有宏。
I have been using the macro solution, as it is outlined here. However, there is a mention on how to view them without macros. I am referring to GDB version 7 and above.
感谢
推荐答案
从SVN获取python查看器
Get the python viewers from SVN
svn://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python
将以下内容添加到您的〜/ .gdbinit
Add the following to your ~/.gdbinit
python
import sys
sys.path.insert(0, '/path/to/pretty-printers/dir')
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
end
然后打印应该可以正常工作:
Then print should just work:
std::map<int, std::string> the_map;
the_map[23] = "hello";
the_map[1024] = "world";
在gdb中:
(gdb) print the_map
$1 = std::map with 2 elements = { [23] = "hello", [1024] = "world" }
要返回旧视图,请使用 print / r
(<$ c $
To get back to the old view use print /r
(/r
is for raw).
另请参阅:http://sourceware.org/gdb/wiki/STLSupport
这篇关于如何使用GDB 7.x查看STL容器的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文