This is the mail archive of the gdb@sourceware.org mailing list for the GDB 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]

Re: Pretty-printers for members can't be influenced by pretty-printers for their containing structure


>>>>> "Jim" == Jim Blandy <jimb@red-bean.com> writes:

Jim> Mozilla's JavaScript engine uses a number of struct types that contain
Jim> unions. I'd like to define a pretty-printer such that the dead union
Jim> branches simply don't show up. Here's an example, from our string
Jim> representation.

Jim> Certainly, I can write a pretty-printer that just generates a
Jim> string like this:

Jim>    { lengthAndFlags = blah, u1 = { left = blah }, s = { right = blah } ... }

Jim> Unfortunately, I can't do that. The pretty-printer for JSString::Data
Jim> can report 'u1' as one of its children, but then when I'm asked to
Jim> create a pretty-printer for that 'u1' value, I have no way of finding
Jim> the JSString::Data instance from which it was extracted. I've lost the
Jim> context I need to make a pretty-printer that lists only 'left' (say)
Jim> as a child, omitting 'chars'.

Couldn't you have 'children' return a list like

  [ ('lengthAndFlags', ...), ('u1.chars', ...), ... ]

Jim> One possible fix would be to allow the second element of the 2-tuple
Jim> items produced by the iterator returned by the pretty-printer's
Jim> 'children' method to be a new pretty-printer. The set of Python values
Jim> that GDB will convert to gdb.Values doesn't include any object types,
Jim> so this is unambiguous.

Jim> How does this sound? Am I looking for a solution in the wrong place?
Jim> Is there a better way to get what I want?

I think your proposed solution is fine.  It's been requested a few
times, and is http://sourceware.org/bugzilla/show_bug.cgi?id=12806

Tom


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