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

* Re: $n for pretty-printed elements?
  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
  1 sibling, 0 replies; 4+ messages in thread
From: Paul Pluzhnikov @ 2009-06-29  3:46 UTC (permalink / raw)
  To: Roland McGrath; +Cc: Project Archer

On Sun, Jun 28, 2009 at 5:07 PM, Roland McGrath<roland@redhat.com> wrote:

> So that [0] = ... is real nice.  But now I want to refer to that datum.

Here is earlier thread on this subject:
http://sourceware.org/ml/archer/2008-q4/msg00483.html

-- 
Paul Pluzhnikov

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

* Re: $n for pretty-printed elements?
  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
  1 sibling, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2009-07-17 22:05 UTC (permalink / raw)
  To: Roland McGrath; +Cc: Project Archer

Sorry for the delay in replying to this.
I'm very behind :(

Roland> Consider:
Roland> (gdb) p _m_path
Roland> $161 = std::list = {
Roland>   [0] = {

[...]

Roland> (gdb) p _m_path
Roland> $161 = std::list = {
Roland>   [0] = $162 = {

This seems like a good idea to me.

There are some subtleties.  We may be seeing the result of several
printers there.  E.g., consider a std::list<std::string>.  I think for
that we'd see:

$61 = std::list = {
  [0] = $162 = "hi bob";
};

... where I suppose $162 would refer to the char* underneath it all.
I suppose my point is that there are some operations, like assignments,
which wouldn't always make sense.

I'll put this on my list.

Tom

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

* Re: $n for pretty-printed elements?
  2009-07-17 22:05 ` Tom Tromey
@ 2009-07-20  6:22   ` Roland McGrath
  0 siblings, 0 replies; 4+ messages in thread
From: Roland McGrath @ 2009-07-20  6:22 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Project Archer

> Sorry for the delay in replying to this.
> I'm very behind :(

No problem.

> Roland> (gdb) p _m_path
> Roland> $161 = std::list = {
> Roland>   [0] = $162 = {
> 
> This seems like a good idea to me.
> 
> There are some subtleties.  [...]

Sure.  I didn't try to think through the whole general case of this feature.

> I suppose my point is that there are some operations, like assignments,
> which wouldn't always make sense.

Sure.  I really just had in mind the basics of "I want &(that one there) to
use in another expression".  It only has to make sense when it makes
sense. :-)

The point of frustration comes when the (ordinarily quite nice) pretty
printers are hiding what the (otherwise painful to read through) generic
old style of printing internal member details make fairly easy to express.

> I'll put this on my list.

Great!


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).