From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22074 invoked by alias); 24 Sep 2002 18:39:58 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 22067 invoked from network); 24 Sep 2002 18:39:56 -0000 Received: from unknown (HELO touchme.toronto.redhat.com) (216.138.202.10) by sources.redhat.com with SMTP; 24 Sep 2002 18:39:56 -0000 Received: from redhat.com (tooth.toronto.redhat.com [172.16.14.29]) by touchme.toronto.redhat.com (Postfix) with ESMTP id E2401800384; Tue, 24 Sep 2002 14:39:55 -0400 (EDT) Message-ID: <3D90B123.90200@redhat.com> Date: Tue, 24 Sep 2002 11:39:00 -0000 From: Fernando Nasser Organization: Red Hat Canada User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020607 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Keith Seitz Cc: gdb-patches@sources.redhat.com Subject: Re: [RFA] (varobj) Fix gdb/701 References: Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2002-09/txt/msg00586.txt.bz2 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 > > * 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