擅长:python、mysql、java
<p><strong>在我的系统中,<code>_Rep_type</code>不是<code>std::map</code></strong>的公共类型(它是私有的typedef),所以脚本试图找出<code><yourmap>._M_t</code>变量的类型,它的类型是<code>_Rep_type</code>。。。在</p>
<p>我试过了:</p>
<pre><code>typedef std::map<int,int> map_t;
map_t m;
m.insert(map_t::value_type(3,4));
</code></pre>
<p>然后在<code>gdb</code>中,我可以像这样打印键<code>3</code>(下面是我链接的脚本中的print函数):</p>
^{pr2}$
<p>其中,<code>std::map</code>中的<code>_M_t</code>是<code>_Rb_tree</code>类型,但在map中该类型不是公共的(您可以在<code>map</code>头文件中看到这一点,特别是<code><path/to/std-headers/dir/bits/stl_map.h</code>头文件。在</p>
<p><strong>不确定这是否有帮助,基本上您正在加载的pretty print python函数似乎有问题。</strong></p>
<p>我刚刚尝试从<a href="http://www.yolinux.com/TUTORIALS/GDB-Commands.html" rel="nofollow">GNU GDB Debugger Command Cheat Sheet from yolinux.com</a>添加<code>.gdbinit</code>的内容(我在google上搜索了<code>gdb pretty print</code>),然后我得到了合理的输出:</p>
<pre><code>(gdb) pmap m int int
elem[0].left: $3 = 3
elem[0].right: $4 = 4
</code></pre>