Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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