[PATCH 1/3] gdb: add owner-related methods to struct type

Tom Tromey tom@tromey.com
Fri Jan 22 15:31:37 GMT 2021


>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:

Simon> From: Simon Marchi <simon.marchi@efficios.com>
Simon> Add the following methods to struct type:

Simon>  * is_objfile_owned
Simon>  * set_owner (objfile and gdbarch overloads)
Simon>  * objfile and arch getters

Simon> Rename the fields in main_type to ensure no other code accesses them
Simon> directly.  As usual, we can't make them actually private, but giving
Simon> them the `m_` prefix will help making sure they are not accessed when
Simon> not supposed to, by convention.

Simon> Remove the TYPE_OWNER macro to ensure no code uses the type_owner struct
Simon> directly.

Looks good, with one small nit.

Simon> +  gdbarch *arch () const
Simon> +  {
Simon> +    if (this->is_objfile_owned ())
Simon> +      return nullptr;
Simon> +
Simon> +  /* Return the gdbarch owner of this type.
Simon> +
Simon> +     Return nullptr if this type is not gdbarch-owned.  */
Simon> +    return this->main_type->m_owner.gdbarch;
Simon> +  }

This comment got misplaced into the middle of the method.

Tom


More information about the Gdb-patches mailing list