This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PING 2][PATCH v3] Fix gdb crash when trying to print the address of a synthetic C++ reference
- From: Pedro Alves <palves at redhat dot com>
- To: Martin Galvan <martin dot galvan at tallertechnologies dot com>, gdb-patches at sourceware dot org, jan dot kratochvil at redhat dot com, lgustavo at codesourcery dot com, daniel dot gutson at tallertechnologies dot com
- Date: Fri, 15 Apr 2016 23:32:44 +0100
- Subject: Re: [PING 2][PATCH v3] Fix gdb crash when trying to print the address of a synthetic C++ reference
- Authentication-results: sourceware.org; auth=none
- References: <1460751838-20954-1-git-send-email-martin dot galvan at tallertechnologies dot com>
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