From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28309 invoked by alias); 9 Dec 2001 19:06:47 -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 28222 invoked from network); 9 Dec 2001 19:06:44 -0000 Received: from unknown (HELO cygnus.com) (205.180.230.5) by sources.redhat.com with SMTP; 9 Dec 2001 19:06:44 -0000 Received: from rtl.cygnus.com (cse.cygnus.com [205.180.230.236]) by runyon.cygnus.com (8.8.7-cygnus/8.8.7) with ESMTP id LAA00680; Sun, 9 Dec 2001 11:06:41 -0800 (PST) Received: (from ezannoni@localhost) by rtl.cygnus.com (8.11.2/8.11.0) id fB9JCj601250; Sun, 9 Dec 2001 14:12:45 -0500 X-Authentication-Warning: krustylu.cygnus.com: ezannoni set sender to ezannoni@cygnus.com using -f From: Elena Zannoni MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15379.47021.244273.208836@krustylu.cygnus.com> Date: Sun, 09 Dec 2001 11:06:00 -0000 To: fnf@redhat.com Cc: gdb-patches@sources.redhat.com Subject: Re: RFA: use init_type() in dwarf2read.c In-Reply-To: <200112090641.fB96fCx13479@fishpond.ninemoons.com> References: <200112090641.fB96fCx13479@fishpond.ninemoons.com> X-Mailer: VM 6.97 under Emacs 20.7.1 X-SW-Source: 2001-12/txt/msg00253.txt.bz2 Fred Fish writes: > The dwarf2read.c file sometimes handcrafts new types and sometimes > calls init_type(). This patch eliminates one of the unnecessary > handcraftings. > > -Fred > Fred, this is OK, but could you please not use the conditional expression? You can initialize name to NULL at the top, and then just use an 'if(attr && DW_STRING (attr))'. Thanks Elena > > 2001-12-08 Fred Fish > > * dwarf2read.c (read_typedef): Replace hand crafted type > initialization with a call to the init_type() function, which > is how the rest of gdb creates types. > > Index: dwarf2read.c > =================================================================== > RCS file: /cvs/src/src/gdb/dwarf2read.c,v > retrieving revision 1.38 > diff -u -p -r1.38 dwarf2read.c > --- dwarf2read.c 2001/12/07 22:11:51 1.38 > +++ dwarf2read.c 2001/12/09 01:28:00 > @@ -2886,26 +2882,15 @@ static void > read_typedef (struct die_info *die, struct objfile *objfile, > const struct comp_unit_head *cu_header) > { > - struct type *type; > + struct attribute *attr; > + char *name; > > if (!die->type) > { > - struct attribute *attr; > - struct type *xtype; > - > - xtype = die_type (die, objfile, cu_header); > - > - type = alloc_type (objfile); > - TYPE_CODE (type) = TYPE_CODE_TYPEDEF; > - TYPE_FLAGS (type) |= TYPE_FLAG_TARGET_STUB; > - TYPE_TARGET_TYPE (type) = xtype; > attr = dwarf_attr (die, DW_AT_name); > - if (attr && DW_STRING (attr)) > - TYPE_NAME (type) = obsavestring (DW_STRING (attr), > - strlen (DW_STRING (attr)), > - &objfile->type_obstack); > - > - die->type = type; > + name = (attr && DW_STRING (attr)) ? DW_STRING (attr) : NULL; > + die->type = init_type (TYPE_CODE_TYPEDEF, 0, TYPE_FLAG_TARGET_STUB, name, objfile); > + TYPE_TARGET_TYPE (die->type) = die_type (die, objfile, cu_header); > } > } >