This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA] (varobj) Fix gdb/701


This is an obvious fix. The whole point in having get_type and get_target_type was to prevent things like this to happen.

Thanks for spotting and fixing it Keith.

Fernando

Keith Seitz wrote:
Hi,

This patch fixes the failure highlighted in gdb/701 (or gdb701.exp, just committed).

This happens because varobj had some last uses of TYPE_TARGET_TYPE, which is a big no-no.

This patch fixes this and adds comments about why using TYPE_TARGET_TYPE is not kosher.

Keith

ChangeLog
2002-09-16 Keith Seitz <keiths@redhat.com>

* varobj.c (c_type_of_child): Use get_target_type instead
of TYPE_TARGET_TYPE.

Patch
Index: varobj.c
===================================================================
RCS file: /cvs/src/src/gdb/varobj.c,v
retrieving revision 1.31
diff -p -r1.31 varobj.c
*** varobj.c 2 Aug 2002 20:51:21 -0000 1.31
--- varobj.c 13 Sep 2002 23:51:00 -0000
*************** make_cleanup_free_variable (struct varob
*** 1345,1351 ****
/* This returns the type of the variable. This skips past typedefs
and returns the real type of the variable. It also dereferences
! pointers and references. */
static struct type *
get_type (struct varobj *var)
{
--- 1345,1354 ----
/* This returns the type of the variable. This skips past typedefs
and returns the real type of the variable. It also dereferences
! pointers and references.
! ! NOTE: TYPE_TARGET_TYPE should NOT be used anywhere in this file
! except within get_target_type and get_type. */
static struct type *
get_type (struct varobj *var)
{
*************** get_type_deref (struct varobj *var)
*** 1374,1380 ****
}
/* This returns the target type (or NULL) of TYPE, also skipping
! past typedefs, just like get_type (). */
static struct type *
get_target_type (struct type *type)
{
--- 1377,1386 ----
}
/* This returns the target type (or NULL) of TYPE, also skipping
! past typedefs, just like get_type ().
! ! NOTE: TYPE_TARGET_TYPE should NOT be used anywhere in this file
! except within get_target_type and get_type. */
static struct type *
get_target_type (struct type *type)
{
*************** c_type_of_child (struct varobj *parent, *** 1959,1965 ****
switch (TYPE_CODE (parent->type))
{
case TYPE_CODE_ARRAY:
! type = TYPE_TARGET_TYPE (parent->type);
break;
case TYPE_CODE_STRUCT:
--- 1965,1971 ----
switch (TYPE_CODE (parent->type))
{
case TYPE_CODE_ARRAY:
! type = get_target_type (parent->type);
break;
case TYPE_CODE_STRUCT:
*************** c_type_of_child (struct varobj *parent, *** 1968,1974 ****
break;
case TYPE_CODE_PTR:
! switch (TYPE_CODE (TYPE_TARGET_TYPE (parent->type)))
{
case TYPE_CODE_STRUCT:
case TYPE_CODE_UNION:
--- 1974,1980 ----
break;
case TYPE_CODE_PTR:
! switch (TYPE_CODE (get_target_type (parent->type)))
{
case TYPE_CODE_STRUCT:
case TYPE_CODE_UNION:
*************** c_type_of_child (struct varobj *parent, *** 1976,1982 ****
break;
default:
! type = TYPE_TARGET_TYPE (parent->type);
break;
}
break;
--- 1982,1988 ----
break;
default:
! type = get_target_type (parent->type);
break;
}
break;


--
Fernando Nasser
Red Hat Canada Ltd.                     E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]