Re: [RFA] varobj: call CHECK_TYPEDEF

Daniel Jacobowitz
2003-04-24T20:47:55Z

On Thu, Apr 24, 2003 at 01:46:55PM -0700, Keith Seitz wrote:
> On Thu, 2003-04-24 at 13:18, Daniel Jacobowitz wrote:
> > CHECK_TYPEDEF does just about what the name suggests - it replaces a
> > TYPE_CODE_TYPEDEF type with the type (TYPE_CODE_STRUCT in this case)
> > that it points to. Feel free to add a comment to that effect.
>
> Ah! Duh! :-)
>
> > The question is whether the caller of get_type ever wants the typedef;
> > depending on how it's used these calls may belong in particular
> > callers, not in get_type.
>
> Hmm. Ok, well I would think that varobj would not want the typedef. For
> example, if we have, "typedef struct foo Bar" and I declare a variable
> of type Bar, varobj should report the number of children as the number
> of children of the struct itself, not the typedef. get_type and
> get_target_type already explicitly bypass TYPE_CODE_TYPEDEF.
>
> Now the real ambiguity is: where to put this in varobj's case? Since
> get_type (and consequently get_target_type and get_type_deref) are used
> all over the place, so we would want to use CHECK_TYPEDEF there. But how
> to not call it when not necessary? In the case I'm currently working on,
> the TYPE_CODE (type) is TYPE_CODE_PTR and TYPE_CODE (TYPE_TARGET_TYPE
> (type)) is TYPE_CODE_STRUCT. Perhaps there is something else I'm
> missing? (Of course, this is still how whatis_command does it...)

The important question is whether get_type is ever used to display the
object's type; in which case we should say Bar, not "struct foo".

I haven't looked at where it's used, so I don't know.

--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer