This is the mail archive of the archer@sourceware.org mailing list for the Archer project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

$n for pretty-printed elements?


Consider:

(gdb) p _m_path
$161 = std::list = {
  [0] = {
    <std::iterator<std::input_iterator_tag, elfutils::dwarf::debug_info_entry, long, elfutils::dwarf::debug_info_entry*, elfutils::dwarf::debug_info_entry&>> = {<No data fields>}, 
    members of elfutils::dwarf::debug_info_entry::children_type::const_iterator: 
    _m_stack = std::stack wrapping: std::deque with 1 elements = {
      {
        <std::iterator<std::input_iterator_tag, elfutils::dwarf::debug_info_entry, long, elfutils::dwarf::debug_info_entry*, elfutils::dwarf::debug_info_entry&>> = {<No data fields>}, 
        members of elfutils::dwarf::debug_info_entry::raw_children_type::const_iterator: 
        _m_die = {
          _m_die = {
            addr = 0x2aaab0005747, 
            cu = 0x66ada0, 
            abbrev = 0x674490, 
            padding__ = 0
          }
        }
      }
    }
  }
}

So that [0] = ... is real nice.  But now I want to refer to that datum.
For vanilla pretty-printing of plain types, I could use &_m_path[0] to
refer to that.  But std::list doesn't have operator[]--and even if it did,
I really didn't want to do an inferior call for this.

Inside there, that _m_stack = ... is real nice.  But now I want to refer to
that elfutils::dwarf::debug_info_entry::raw_children_type::const_iterator
object or its _m_die field.

What my gdb reflexes did was cast around for the handle on what I wanted.
I knew it wasn't really "p &(_m_path[0]._m_stack.top()._m_die)", because of
all the magic C++ inferior calls that implies (even if they could actually
be done, which they can't), though that's what my fingers wanted to try.
But my gdb hindbrain told me, "Fear the C++, find a $ you can trust."  
In my mind's eye it looked like:

(gdb) p _m_path
$161 = std::list = {
  [0] = $162 = {
    <std::iterator<std::input_iterator_tag, elfutils::dwarf::debug_info_entry, long, elfutils::dwarf::debug_info_entry*, elfutils::dwarf::debug_info_entry&>> = {<No data fields>}, 
    members of elfutils::dwarf::debug_info_entry::children_type::const_iterator: 
    _m_stack = std::stack wrapping: std::deque with 1 elements = {
      {
        $163 = <std::iterator<std::input_iterator_tag, elfutils::dwarf::debug_info_entry, long, elfutils::dwarf::debug_info_entry*, elfutils::dwarf::debug_info_entry&>> = {<No data fields>}, 
        members of elfutils::dwarf::debug_info_entry::raw_children_type::const_iterator: 
        _m_die = {
          _m_die = {
            addr = 0x2aaab0005747, 
            cu = 0x66ada0, 
            abbrev = 0x674490, 
            padding__ = 0
          }
        }
      }
    }
  }
}

and my fingers wanted to type "p &$163._m_die" but my eyeballs searching
for that $nnn to fill in couldn't see it anywhere on the screen!

Please help me, or my gdb hindbrain could shut down in horror and my
fingers might go feral.  

If you were to go all sophisticated and make that $161_0 instead of $162,
and $161_0_0 instead of $163, I would cope just fine.


Thanks,
Roland


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]