[PATCH v2 06/11] Add a more general version of lookup_struct_elt_type.

Philipp Rudo prudo@linux.ibm.com
Mon Feb 11 10:27:00 GMT 2019


Hey Jon

On Fri, 8 Feb 2019 17:07:22 -0800
John Baldwin <jhb@FreeBSD.org> wrote:

> On 2/8/19 4:40 PM, John Baldwin wrote:
> > lookup_struct_elt is a new function which returns a tuple of
> > information about a component of a structure or union.  The returned
> > tuple contains a pointer to the struct field object for the component
> > as well as a bit offset of that field within the structure.  If the
> > field names a field in an anonymous substructure, the offset is the
> > "global" offset relative to the original structure type.  If noerr is
> > set, then the returned tuple will set the field pointer to NULL to
> > indicate a missing component rather than throwing an error.
> > 
> > lookup_struct_elt_type is now reimplemented in terms of this new
> > function.  It simply returns the type of the returned field.  
> 
> Hopefully this is close enough to lk_find_field that you can reuse it.
> One difference is that it defines its own dedicated type and the second is
> that it returns the raw bitpos so that it is hopefully easier to reuse in
> other places.  I think you can probably call it and just pass the members
> the returned structure (with an added divide for the offset to convert to
> bytes) to construct an lk_symbol.

sorry, I totally missed your v1.

The patch looks sane to me. It should be possible to use it in lk_find_field.
I'm not fully sure what the 'check on baseclasses' does for C structs, but I
guess it doesn't harm. Otherwise there would have already been an outcry :)

Thanks
Philipp



More information about the Gdb-patches mailing list