[PATCH v2] Implement pahole-like 'ptype /o' option

John Baldwin jhb@FreeBSD.org
Tue Dec 12 15:50:00 GMT 2017


On 12/11/17 8:25 PM, Simon Marchi wrote:
> On 2017-12-11 19:51, Pedro Alves wrote:
>>>> So from that angle, I see value in not printing the offsets
>>>> of union members.
>>>
>>> Since it's still not clear whether the offsets should be printed or 
>>> not
>>> in this case, and I am not a global maintainer, I adjusted the code to
>>> print them and will post the patch as a reply to the v4 e-mail.  This
>>> way you can decide which version is best.
>>
>> Fun, just when I agreed with not printing the offsets... :-P  :-)
> 
> Damn, sorry for starting you guys on that track!  I just wanted to know 
> if it was intentional or not, I am fine with either.

The only reason I would find the offset usable is to know the offset of
a structure member inside of a union.  E.g.:

struct foo {
     int x;
     union {
         struct {
             int y;
             int z;
         };
         int a;
     };
};

I think it is useful to know the offset of 'foo.z' within the overall
structure.

-- 
John Baldwin



More information about the Gdb-patches mailing list