This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Fix mi "-var-create" regression
- From: Sergio Durigan Junior <sergiodj at redhat dot com>
- To: "Gustavo\, Luis" <luis_gustavo at mentor dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Thu, 11 Oct 2012 18:53:37 -0300
- Subject: Re: [PATCH] Fix mi "-var-create" regression
- References: <5075D4FD.9050900@mentor.com>
On Wednesday, October 10 2012, Luis Gustavo wrote:
> Hi,
Hey Luis :-)
> 2012-10-10 Luis Machado <lgustavo@codesourcery.com>
>
> * value.c (value_actual_type): Check for TYPE_CODE_VOID
> target types.
>
> Index: gdb/gdb/value.c
> ===================================================================
> --- gdb.orig/gdb/value.c 2012-10-10 16:38:21.872234906 -0300
> +++ gdb/gdb/value.c 2012-10-10 16:42:49.560222099 -0300
> @@ -850,8 +850,13 @@ value_actual_type (struct value *value,
> result = value_type (value);
> if (opts.objectprint)
> {
> - if (TYPE_CODE (result) == TYPE_CODE_PTR
> + /* If result's target type is TYPE_CODE_VOID, do not try fetching its rtti
> + type. GDB will try to dereference the void pointer and will throw an
> + error when trying to do so. */
> + if ((TYPE_CODE (result) == TYPE_CODE_PTR
> || TYPE_CODE (result) == TYPE_CODE_REF)
> + && ((TYPE_TARGET_TYPE (result) != NULL)
> + && TYPE_CODE (TYPE_TARGET_TYPE (result)) != TYPE_CODE_VOID))
> {
> struct type *real_type;
>
As far as I remember this code (thanks for the explanation BTW), the
patch looks fine by me (not a maintainer). Just two things I noticed:
1) I believe you could remove some of the parentheses in the `if'
above. Something like:
if ((TYPE_CODE (result) == TYPE_CODE_PTR
|| TYPE_CODE (result) == TYPE_CODE_REF)
&& TYPE_TARGET_TYPE (result) != NULL
&& TYPE_CODE (TYPE_TARGET_TYPE (result)) != TYPE_CODE_VOID)
would have the same effect, right?
2) Would it be possible to provide a testcase for this issue? Not sure
if it's really needed, but I guess it won't hurt :-). Of course, if
some maintainer thinks it's useless, then please disconsider the idea
right away.
Thanks a lot,
--
Sergio