This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: Simpify varobj children handling for C++
- From: Daniel Jacobowitz <drow at false dot org>
- To: Vladimir Prus <ghost at cs dot msu dot su>
- Cc: gdb-patches at sources dot redhat dot com
- Date: Sat, 20 Jan 2007 14:41:53 -0500
- Subject: Re: Simpify varobj children handling for C++
- References: <200612240050.30172.ghost@cs.msu.su> <emo1cf$b0v$1@sea.gmane.org> <20070103223207.GM17935@nevyn.them.org> <E1H7FxM-00089U-NX@zigzag.lvk.cs.msu.su>
On Wed, Jan 17, 2007 at 09:55:53PM +0300, Vladimir Prus wrote:
> >> @@ -950,7 +950,8 @@ value_ind (struct value *arg1)
> >> if (TYPE_CODE (base_type) == TYPE_CODE_INT)
> >> return value_at_lazy (builtin_type_int,
> >> (CORE_ADDR) value_as_long (arg1));
> >> - else if (TYPE_CODE (base_type) == TYPE_CODE_PTR)
> >> + else if (TYPE_CODE (base_type) == TYPE_CODE_PTR
> >> + || TYPE_CODE (base_type) == TYPE_CODE_PTR)
> >> {
> >> struct type *enc_type;
> >> /* We may be pointing to something embedded in a larger object */
> >
> > Something tells me you didn't actually need value_ind to handle
> > references... :-)
>
> Why? Because that's a bad idea or because varobj code does not
> need to dereference rereferences? The latter is true,
> attached version of the patch builds on the
> "fix 'editable' attribute for references" patch I've posted earlier
> and now 'adjust_value_for_child_access' asserts that the type
> is not reference.
All I meant was that you added "is TYPE_CODE_PTR or is TYPE_CODE_PTR".
I guess you meant to check TYPE_CODE_REF, but you must not have needed
it if you didn't notice the typo.
> +get_value_type (struct varobj *var)
> {
> struct type *type;
>
> - type = get_type (var);
> + if (var->value)
> + type = value_type (var->value);
> + else
> + type = var->type;
>
> - if (type)
> - {
> - if (TYPE_CODE (type) == TYPE_CODE_REF)
> - type = get_target_type (type);
> - if (TYPE_CODE (type) == TYPE_CODE_PTR)
> - type = get_target_type (type);
> - }
> + if (TYPE_CODE (type) == TYPE_CODE_REF)
> + type = get_target_type (type);
> +
> + type = check_typedef (type);
>
> return type;
> }
I think that if you want to check for references, you need to call
check_typedef first (I just checked that g++ does allow typedefs
to reference types). Otherwise this looks OK to commit.
It would be nice to have some tests for not stripping typedefs,
if that's practical, but it's not really important.
--
Daniel Jacobowitz
CodeSourcery