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]

Re: [python][patch] Pretty printers for anonymous types.


On Fri, Jan 16, 2009 at 4:49 PM, Tom Tromey <tromey@redhat.com> wrote:
>>>>>> "Paul" == Paul Pluzhnikov <ppluzhnikov@google.com> writes:
>
> Paul> AFAICT, currently there is no way to establish a pretty printer for
> Paul> 'Foo', because get_type() in python/python.c answers with
> Paul> "struct { ... }" for either 'f' or 'b'.
>
> This needs a patch to the documentation -- the search process is
> documented.  This is ok with that addition.

Ok...

> One issue I think you will hit is that gdb is fairly aggressive about
> calling check_typedef.  For instance, value_cast strips typedefs from
> the target type; so I suspect that "p (Foo *) x" will not do the right
> thing even with your patch.  This is just something we'll have to
> (eventually) fix.

You are correct:

(gdb) p *(Foo *)&f
$1 = {x = 0}         # "custom" pretty-printer did not kick in.

There is a further complication: when the same source is compiled
in C++ mode, then the 'TYPE_NAME (type) == NULL' condition is
always false -- the name is set to "<anonymous struct>" by GCC 4.3.1.

I think that's somewhat unfortunate :-(

Yikes!

gcc-4.0.3:  DW_AT_name        : Foo
gcc-4.1.1:  DW_AT_name        : ._0
gcc-4.2.2:  DW_AT_name        : ._0
gcc-4.3.1:  DW_AT_name        : (indirect string, offset: 0x121):
<anonymous struct>

And we aren't even looking at the typedef anymore:

#3  0x00000000004abfa9 in print_formatted (val=0x1209230, size=0,
options=0x7fffffffdd80, stream=0xcb7410) at ../../gdb/printcmd.c:305
305         value_print (val, stream, options);
(top) p val.type.main_type[0]
$15 = {code = TYPE_CODE_STRUCT, flag_unsigned = 0, flag_nosign = 0,
       flag_stub = 0, flag_target_stub = 0, flag_static = 0,
flag_prototyped = 0,
       flag_incomplete = 0, flag_varargs = 0, flag_vector = 0,
       flag_stub_supported = 1, flag_nottext = 0, flag_fixed_instance = 0,
       nfields = 1, vptr_fieldno = -1, name = 0xb70b79 "<anonymous struct>",
       tag_name = 0xb70b79 "<anonymous struct>", objfile = 0xbbab50,
       target_type = 0x0, fields = 0xb10b08, vptr_basetype = 0x0,
       type_specific = {cplus_stuff = 0xa10040, floatformat = 0xa10040,
       calling_convention = 10551360}}

Given that C/C++ consistency is desirable, but dealing with
anonymous C++ structs will clearly take a lot more work, should I
still commit this (with doc update), or file a gdb-archer PR in bugzilla?

Thanks,
-- 
Paul Pluzhnikov


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