public inbox for archer@sourceware.org
 help / color / mirror / Atom feed
From: Roland McGrath <roland@redhat.com>
To: Project Archer <archer@sourceware.org>
Subject: $n for pretty-printed elements?
Date: Mon, 29 Jun 2009 00:07:00 -0000	[thread overview]
Message-ID: <20090629000709.45C9C420F6@magilla.sf.frob.com> (raw)

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

             reply	other threads:[~2009-06-29  0:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-29  0:07 Roland McGrath [this message]
2009-06-29  3:46 ` Paul Pluzhnikov
2009-07-17 22:05 ` Tom Tromey
2009-07-20  6:22   ` Roland McGrath

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090629000709.45C9C420F6@magilla.sf.frob.com \
    --to=roland@redhat.com \
    --cc=archer@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).