From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30314 invoked by alias); 3 Feb 2002 22:59:37 -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 30232 invoked from network); 3 Feb 2002 22:59:35 -0000 Received: from unknown (HELO nevyn.them.org) (128.2.145.6) by sources.redhat.com with SMTP; 3 Feb 2002 22:59:35 -0000 Received: from drow by nevyn.them.org with local (Exim 3.34 #1 (Debian)) id 16XVc0-0006ve-00 for ; Sun, 03 Feb 2002 17:59:52 -0500 Date: Sun, 03 Feb 2002 14:59:00 -0000 From: Daniel Jacobowitz To: gdb-patches@sources.redhat.com Subject: Re: [RFA/stabs] Fix gdb/280 infinite loop in userdef.exp Message-ID: <20020203175952.B26302@nevyn.them.org> Mail-Followup-To: gdb-patches@sources.redhat.com References: <20020201185437.A26371@nevyn.them.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.3.23i X-SW-Source: 2002-02/txt/msg00044.txt.bz2 Committed with comment. Sometime down the road I hope to try to clean that up - I'll have some other patches affecting stubbed types, which are related to this same hack. On Sun, Feb 03, 2002 at 05:25:30PM -0500, Jim Blandy wrote: > > Approved. Could you also put a comment in the stabs reader saying > that this isn't really a kosher way to construct types? > > Daniel Jacobowitz writes: > > > Another problem exposed by the way the stabs reader handles types. It does > > '*type = *xtype' at one point, which dies horribly for qualified types (and > > messes up pointer types, too...). I don't immediately see a way to get rid > > of that line, so I made an interface to do the copy correctly. > > > > For reference, that appears to be the only place in GDB this is actually > > done. Other readers must handle forward-referenced types somehow... > > > > Without this patch we enter an infinite loop because the cv-chain is > > corrupted. > > > > OK to commit? > > > > -- > > Daniel Jacobowitz Carnegie Mellon University > > MontaVista Software Debian GNU/Linux Developer > > > > 2002-02-01 Daniel Jacobowitz > > > > PR gdb/280 > > * gdbtypes.c (replace_type): New function. > > * gdbtypes.h (replace_type): Add prototype. > > * stabsread.c (read_type): Use replace_type. > > > > Index: gdbtypes.c > > =================================================================== > > RCS file: /cvs/src/src/gdb/gdbtypes.c,v > > retrieving revision 1.38 > > diff -u -p -r1.38 gdbtypes.c > > --- gdbtypes.c 2002/01/22 19:57:40 1.38 > > +++ gdbtypes.c 2002/02/01 23:48:45 > > @@ -519,6 +519,32 @@ finish_cv_type (struct type *type) > > } > > } > > > > +/* Replace the contents of ntype with the type *type. > > + > > + This function should not be necessary, but is due to quirks in the stabs > > + reader. This should go away. It does not handle the replacement type > > + being cv-qualified; it could be easily fixed to, but it should go away, > > + remember? */ > > +void > > +replace_type (struct type *ntype, struct type *type) > > +{ > > + struct type *cv_chain, *as_chain, *ptr, *ref; > > + > > + cv_chain = TYPE_CV_TYPE (ntype); > > + as_chain = TYPE_AS_TYPE (ntype); > > + ptr = TYPE_POINTER_TYPE (ntype); > > + ref = TYPE_REFERENCE_TYPE (ntype); > > + > > + *ntype = *type; > > + > > + TYPE_POINTER_TYPE (ntype) = ptr; > > + TYPE_REFERENCE_TYPE (ntype) = ref; > > + TYPE_CV_TYPE (ntype) = cv_chain; > > + TYPE_AS_TYPE (ntype) = as_chain; > > + > > + finish_cv_type (ntype); > > +} > > + > > /* Implement direct support for MEMBER_TYPE in GNU C++. > > May need to construct such a type if this is the first use. > > The TYPE is the type of the member. The DOMAIN is the type > > Index: gdbtypes.h > > =================================================================== > > RCS file: /cvs/src/src/gdb/gdbtypes.h,v > > retrieving revision 1.25 > > diff -u -p -r1.25 gdbtypes.h > > --- gdbtypes.h 2002/01/20 19:42:04 1.25 > > +++ gdbtypes.h 2002/02/01 23:48:45 > > @@ -1062,6 +1062,8 @@ extern struct type *make_cv_type (int, i > > > > extern void finish_cv_type (struct type *); > > > > +extern void replace_type (struct type *, struct type *); > > + > > extern int address_space_name_to_int (char *); > > > > extern char *address_space_int_to_name (int); > > Index: stabsread.c > > =================================================================== > > RCS file: /cvs/src/src/gdb/stabsread.c,v > > retrieving revision 1.23 > > diff -u -p -r1.23 stabsread.c > > --- stabsread.c 2002/01/20 19:12:23 1.23 > > +++ stabsread.c 2002/02/01 23:48:46 > > @@ -2531,7 +2531,7 @@ again: > > } > > else if (type_size >= 0 || is_string) > > { > > - *type = *xtype; > > + replace_type (type, xtype); > > TYPE_NAME (type) = NULL; > > TYPE_TAG_NAME (type) = NULL; > > } > -- Daniel Jacobowitz Carnegie Mellon University MontaVista Software Debian GNU/Linux Developer