我无法在gdb中转储STL无序映射容器值。变量类型为std::unordered_map<>变量;
我的gdb版本- 7.7.1 Gdb配置:
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-babeltraceg++ (Ubuntu4.8.4-2 ubuntu1~14.04.3) 4.8.4
打印STL容器值n gdb的正确方法是什么?
map容器的gdb输出:
$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> > >发布于 2017-05-09 10:09:03
您的gdb --configuration输出缺少了--with-python子句,因此我假设您的gdb确实不能使用python。根据这一点,所以回答gdb pretty printing is not working,它似乎是必要的漂亮打印工作。
我在docker中的ubuntu14.04带有漂亮的打印工作,而且gdb是使用- with配置的。似乎,您的gdb安装是以某种方式定制的。可以使用正确的选项从源重新编译gdb,也可以尝试从分发包中重新安装gdb。
发布于 2017-05-12 11:46:36
试着检查一下:https://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python/
并将这些行添加到您的:~/.gdbinit中
python
import sys
sys.path.insert(0, '<Path to SVN Checkout Directory>')
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
end如果它不起作用,您可以从SVN中签出一个更接近您正在使用的GDB版本的旧版本。
注释:假设您的GDB启用了python后端。
更新:在使用Ubuntu的gdb包的情况下,您可以尝试安装以下软件包来添加对"STL漂亮打印“的支持:libstdc++6-4.8-dbg。
使用此更新,gdb将自动支持STL容器的漂亮打印。
发布于 2017-05-14 05:33:20
1)早期版本的gdb不需要Python来打印STL对象。与python有关的错误与您的倾诉有关。
gdbinit不是gdb配置。
2)有一种解决方案是可以工作的:卸载和重新安装旧的(在您的发行版上寻找漂亮的打印包) gdb包也会检查用户的.bashrc (您可能对gdb做了一些您不想做的事情),清除它,重新启动终端,它就能工作了。
注意,最近的gdb版本只需要特定版本的python,而且它们有相当多的bug,一些Linux发行版将它们作为默认版本,这是它们的问题,gdb不是一回事--它是一棵树。确保你得到了正确的答案,在我看来,这与python无关。
下面的链接描述了这个糟糕的想法是什么时候引入gdb的,以及为什么人们似乎喜欢它,https://bbs.archlinux.org/viewtopic.php?id=87299
https://stackoverflow.com/questions/43807907
复制相似问题