Skip to content

Cast intrusive_ptr's pointer to its dynamic_type before dereferencing#44

Open
pepsiman wants to merge 1 commit intoruediger:masterfrom
pepsiman:dynamic_type
Open

Cast intrusive_ptr's pointer to its dynamic_type before dereferencing#44
pepsiman wants to merge 1 commit intoruediger:masterfrom
pepsiman:dynamic_type

Conversation

@pepsiman
Copy link

I use boost::intrusive_ptr with the root of a class hierarchy.
It would be useful to see the members of derived types in gdb.

Before:

(gdb) p intrusive_derived
$1 = 0x555555ae2990 = {
  value = {
    <boost::sp_adl_block::intrusive_ref_counter<test_intrusive_ptr()::S, boost::sp_adl_block::thread_safe_counter>> = {
      m_ref_counter = {
        value_ = {
          <std::__atomic_base<int>> = {
            _M_i = 1
          }, <No data fields>}
      }
    }, 
    members of S: 
    _vptr.S = 0x5555557c12f0 <vtable for test_intrusive_ptr()::T+16>, 
    i = 6
  }
}

After:

(gdb) p intrusive_derived
$1 = 0x555555ae2990 = {
  value = {
    <S> = {
      <boost::sp_adl_block::intrusive_ref_counter<test_intrusive_ptr()::S, boost::sp_adl_block::thread_safe_counter>> = {
        m_ref_counter = {
          value_ = {
            <std::__atomic_base<int>> = {
              _M_i = 1
            }, <No data fields>}
        }
      }, 
      members of S: 
      _vptr.S = 0x5555557c12f0 <vtable for test_intrusive_ptr()::T+16>, 
      i = 6
    }, 
    members of T: 
    j = 9
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant