Re: [RFA] varobj: call CHECK_TYPEDEF

David Carlton
2003-06-11T23:51:12Z

On 11 Jun 2003 13:15:10 -0700, Keith Seitz <keiths@redhat.com> said:

> So where do we stand with this?

I've just gone and looked over the thread and at Keith's patch; I
think the idea is sound, but the implementation isn't. The comments
at the top of get_type say that it's supposed to skip past typedefs,
so calling CHECK_TYPEDEF certainly seems legitimate. But
CHECK_TYPEDEF calls check_typedef, which already goes through chains
of typedefs, so you can get rid of the loop in get_type. So I would
rewrite get_type as follows:

static struct type *
get_type (struct varobj *var)
{
struct type *type;
type = var->type;

if (type != NULL)
CHECK_TYPEDEF (type);

return type;
}

And I don't think you should change get_type_deref at all, but you
should change get_target_type as follows:

static struct type *
get_target_type (struct type *type)
{
if (type != NULL)
{
type = TYPE_TARGET_TYPE (type);

if (type != NULL)
CHECK_TYPEDEF (type);
}

return type;
}

(I do wonder a bit if all of those "type != NULL" checks are
necessary, but that's a separate question.)

I'm not qualified to approve these patches, but the idea seems obvious
to me.

David Carlton
carlton@math.stanford.edu