[PATCH 4/4] gdb: remove TYPE_DYN_PROP_LIST macro

Simon Marchi simark@simark.ca
Thu May 7 14:15:35 GMT 2020


On 2020-05-07 9:58 a.m., Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:
> 
> Simon> Remove this macro, which abstracts how to obtain the dyn_prop_list of a
> Simon> given type.  We could replace it with a method on `struct type`, but I
> Simon> don't think it's needed, as the only code that accesses the dynamic prop
> Simon> list directly is internal gdbtypes.c code (that can be seen as code
> Simon> internal to `struct type`).  So it can just refer to the field directly.
> 
> Eventually this member should probably be private.

Indeed, there are a few things to consider before:

- To make struct type non-POD, we need to re-evaluate how it's allocated/de-allocated
- Re-evaluate how the types are copied.  copy_type and copy_type_recursive are currently
  free functions.  So either they need to work only using the public API of struct type
  and struct main_type, they need to be made "friend" of these classes, or they need to
  be changed to be methods of these classes.

In the mean time, an approach I've taken with my not-submitted-yet patches is to still
rename the field to give it the `m_` prefix, even though it's not really private yet.
That still ensures that no other part of the code is unexpectedly accessing the field
directly.

Simon


More information about the Gdb-patches mailing list