* [RFA] (varobj) Fix gdb/701
@ 2002-09-16 12:10 Keith Seitz
2002-09-24 11:39 ` Fernando Nasser
0 siblings, 1 reply; 3+ messages in thread
From: Keith Seitz @ 2002-09-16 12:10 UTC (permalink / raw)
To: gdb-patches
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;
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [RFA] (varobj) Fix gdb/701
2002-09-16 12:10 [RFA] (varobj) Fix gdb/701 Keith Seitz
@ 2002-09-24 11:39 ` Fernando Nasser
2002-09-24 11:50 ` Keith Seitz
0 siblings, 1 reply; 3+ messages in thread
From: Fernando Nasser @ 2002-09-24 11:39 UTC (permalink / raw)
To: Keith Seitz; +Cc: gdb-patches
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-09-24 18:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-16 12:10 [RFA] (varobj) Fix gdb/701 Keith Seitz
2002-09-24 11:39 ` Fernando Nasser
2002-09-24 11:50 ` Keith Seitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox