public inbox for archer@sourceware.org
 help / color / mirror / Atom feed
* $n for pretty-printed elements?
@ 2009-06-29  0:07 Roland McGrath
  2009-06-29  3:46 ` Paul Pluzhnikov
  2009-07-17 22:05 ` Tom Tromey
  0 siblings, 2 replies; 4+ messages in thread
From: Roland McGrath @ 2009-06-29  0:07 UTC (permalink / raw)
  To: Project Archer

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-07-20  6:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-29  0:07 $n for pretty-printed elements? Roland McGrath
2009-06-29  3:46 ` Paul Pluzhnikov
2009-07-17 22:05 ` Tom Tromey
2009-07-20  6:22   ` Roland McGrath

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).