This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch+7.8] Fix 7.8 regression: resolve_dynamic_struct: Assertion `TYPE_NFIELDS (type) > 0' (PR 17642)
- From: Joel Brobecker <brobecker at adacore dot com>
- To: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Sat, 13 Dec 2014 09:23:51 -0500
- Subject: Re: [patch+7.8] Fix 7.8 regression: resolve_dynamic_struct: Assertion `TYPE_NFIELDS (type) > 0' (PR 17642)
- Authentication-results: sourceware.org; auth=none
- References: <20141125195444 dot GA3400 at host2 dot jankratochvil dot net>
> It is another missing check_typedef().
> gdb/
> 2014-11-25 Jan Kratochvil <jan.kratochvil@redhat.com>
>
> Fix internal error on stubs of dynamic types.
> * gdbtypes.c (resolve_dynamic_type_internal): Apply check_typedef to
> TYPE if not TYPE_CODE_TYPEDEF.
>
> gdb/testsuite/
> 2014-11-25 Jan Kratochvil <jan.kratochvil@redhat.com>
>
> Fix internal error on stubs of dynamic types.
> * gdb.base/vla-stub-define.c: New file.
> * gdb.base/vla-stub.c: New file.
> * gdb.base/vla-stub.exp: New file.
Pre-approved with the following comments. Ok for 7.8 as well, although
the chances of a 7.8.2 are getting slimmer, and you'll need also to
create a PR.
> diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
> index 61d259d..aa76604 100644
> --- a/gdb/gdbtypes.c
> +++ b/gdb/gdbtypes.c
> @@ -1875,41 +1875,48 @@ resolve_dynamic_type_internal (struct type *type, CORE_ADDR addr,
> if (!is_dynamic_type_internal (real_type, top_level))
> return type;
>
> - switch (TYPE_CODE (type))
> + if (TYPE_CODE (type) == TYPE_CODE_TYPEDEF)
> {
> - case TYPE_CODE_TYPEDEF:
> resolved_type = copy_type (type);
> TYPE_TARGET_TYPE (resolved_type)
> = resolve_dynamic_type_internal (TYPE_TARGET_TYPE (type), addr,
> top_level);
> - break;
> + }
> + else
Trailing space here...
> + {
> + /* Typedefs do not need to be preserved here but we need
> + to resolve any possible stub types. */
> + type = real_type;
It took me a moment, despite your added comment, to understand that
it was not so much about TYPE_CODE_TYPEDEF but about stubs! I keep
forgetting that check_typedef does more than unwrapping typedef
layers.
We know that type isn't a typedef here, so mentioning typedefs
is a bit confusing, IMO. How about we adjust the comment to say,
for instance:
/* Before trying to resolve TYPE, make sure it is not a stub. */
This is only a suggestion, and it's subjective, so feel free to ignore.
Thank you,
--
Joel