How to dump STL container data in gdb?(如何在 gdb 中转储 STL 容器数据?)
问题描述
我无法在 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 容器数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 gdb 中转储 STL 容器数据?


基础教程推荐
- 设计字符串本地化的最佳方法 2022-01-01
- 如何在 C++ 中处理或避免堆栈溢出 2022-01-01
- 您如何将 CreateThread 用于属于类成员的函数? 2021-01-01
- 调用std::Package_TASK::Get_Future()时可能出现争用情况 2022-12-17
- C++ 程序在执行 std::string 分配时总是崩溃 2022-01-01
- 运算符重载的基本规则和习语是什么? 2022-10-31
- C++ 标准:取消引用 NULL 指针以获取引用? 2021-01-01
- C++,'if' 表达式中的变量声明 2021-01-01
- 如何定义双括号/双迭代器运算符,类似于向量的向量? 2022-01-01
- 什么是T&&(双与号)在 C++11 中是什么意思? 2022-11-04