首页 > core文件中的几个字段含义

core文件中的几个字段含义

class Dialog{

      typedef std::map<int, SharedPtr<SipMessage> > RequestMap;
      RequestMap mRequests;
}

在GDB中找出来mRequests是这样的:

(gdb) p this
$22 = (resip::Dialog * const) 0x2aaab0784a80
(gdb) p this->mRequests
$23 = {_M_t = {
    _M_impl = {<std::allocator<std::_Rb_tree_node<std::pair<int const, resip::SharedPtr<resip::SipMessage> > > >> = {<__gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<int const, resip::SharedPtr<resip::SipMessage> > > >> = {<No data fields>}, <No data fields>}, _M_key_compare = {<std::binary_function<int, int, bool>> = {<No data fields>}, <No data fields>}, _M_header = {_M_color = _S_red, 
        _M_parent = 0x0, _M_left = 0x2aaab0785a20, _M_right = 0x2aaab0785a20}, _M_node_count = 0}}}

我想问的是
_M_left = 0x2aaab0785a20, _M_right = 0x2aaab0785a20
*_M_left*的内容代表什么,有没有办法查看mRequest的内容?


由于 map 实际上是一个 tree,特别是 operator [] 这种便利的重载在 core dump 中不可用,所以你要想看 map 里面的内容,就需要顺着 tree 一个个的节点去找,略蛋疼。

你可以参考 gcc 的标准库实现来了解各个字段的含义,比如:

另外,网上有人推荐使用一个 gdb 脚本来解决这个蛋疼的事情,不过我没有用过,你可以尝试一下,或许会很有帮助。

【热门文章】
【热门文章】