问题描述
我无法在 gdb 中转储 STL 无序映射容器值.变量类型是std::unordered_map<>var;
I am not able to dump STL unordered map container values in gdb. variable type is std::unordered_map<> var;
我的 gdb 版本 - 7.7.1gdb 配置:
my gdb version - 7.7.1 Gdb configuration:
configure --host=x86_64-linux-gnu --target=x86_64-linux-gnu
--with-auto-load-dir=$debugdir:$datadir/auto-load
--with-auto-load-safe-path=$debugdir:$datadir/auto-load
--with-expat
--with-gdb-datadir=/usr/local/share/gdb (relocatable)
--with-jit-reader-dir=/usr/local/lib/gdb (relocatable)
--without-libunwind-ia64
--with-lzma
--with-separate-debug-dir=/usr/local/lib/debug (relocatable)
--with-system-gdbinit=/etc/gdb/gdbinit
--with-zlib
--without-babeltrace
g++ (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4
g++ (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4
打印 STL 容器值 n gdb 的正确方法是什么?
what is right way to print STL container values n gdb?
地图容器的gdb输出:
p 变量
$3 = {<std::__allow_copy_cons<true>> = {<No data fields>}, [13/5219]
_M_h = {<std::__detail::_Hashtable_base<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<ch
ar> > const, Metrics_s*>, std::__detail::_Select1st, std::equal_to<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::hash<std::basic_string<char, std::ch
ar_traits<char>, std::allocator<char> > >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Hashtable_traits<true, false, true> >> = {<std::__detail::
_Hash_code_base<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, Metric
s_s*>, std::__detail::_Select1st, std::hash<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >
推荐答案
您的 gdb --configuration
输出缺少 --with-python
子句,所以我假设您的gdb 真的不能使用 python 扩展.根据这个 SO 答案 gdb 漂亮的打印不起作用 似乎有必要让漂亮的打印工作.
Your gdb --configuration
output is missing --with-python
clause, so I assume your gdb really cannot use python extensions. According to this SO answer gdb pretty printing is not working it seems to be necessary for pretty-print to work.
我在 docker 中的 ubuntu 14.04 带有漂亮的打印功能,并且 gdb 是使用 --with-python 配置的.看来,您的 gdb 安装是以某种方式定制的.您可以使用正确的选项从源重新编译 gdb,或者尝试从您的分发包中清除重新安装 gdb.
My ubuntu 14.04 in docker comes with pretty-print working as well as gdb is configured using --with-python. It seems, your gdb installation is somehow customized. You can either recompile the gdb from sources with correct options or try to clean reinstall gdb from your distribution packages.
这篇关于如何在 gdb 中转储 STL 容器数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!