This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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: [PING 2][PATCH v3] Fix gdb crash when trying to print the address of a synthetic C++ reference


On 04/15/2016 09:23 PM, Martin Galvan wrote:

> diff --git a/gdb/valops.c b/gdb/valops.c
> index 5a244a9..40559c2 100644
> --- a/gdb/valops.c
> +++ b/gdb/valops.c
> @@ -1463,11 +1463,19 @@ value_addr (struct value *arg1)
>    if (TYPE_CODE (type) == TYPE_CODE_REF)
>      {
>        /* Copy the value, but change the type from (T&) to (T*).  We
> -         keep the same location information, which is efficient, and
> -         allows &(&X) to get the location containing the reference.  */
> +	 keep the same location information, which is efficient, and
> +	 allows &(&X) to get the location containing the reference.
> +	 Do the same to its enclosing type for consistency.  */
> +      struct type *type_ptr = lookup_pointer_type (TYPE_TARGET_TYPE (type));
> +

Spurious empty line.

> +      struct type *enclosing_type = check_typedef (value_enclosing_type (arg1));
> +      struct type *enclosing_type_ptr =
> +	lookup_pointer_type (TYPE_TARGET_TYPE (enclosing_type));

= goes on the next line.

OK with those fixed.

I'd write it like this, with the variables reordered to align the
lookup_pointer_type calls:

      struct type *enclosing_type
	= check_typedef (value_enclosing_type (arg1));
      struct type *type_ptr
	= lookup_pointer_type (TYPE_TARGET_TYPE (type));
      struct type *enclosing_type_ptr
	= lookup_pointer_type (TYPE_TARGET_TYPE (enclosing_type));

Thanks for fixing this, and also for writing a test with the DWARF assembler.

Thanks,
Pedro Alves


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