From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21637 invoked by alias); 19 Mar 2002 19:23:05 -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 21563 invoked from network); 19 Mar 2002 19:22:52 -0000 Received: from unknown (HELO cygnus.com) (205.180.230.5) by sources.redhat.com with SMTP; 19 Mar 2002 19:22:52 -0000 Received: from localhost.redhat.com (cse.cygnus.com [205.180.230.236]) by runyon.cygnus.com (8.8.7-cygnus/8.8.7) with ESMTP id LAA10928 for ; Tue, 19 Mar 2002 11:22:50 -0800 (PST) Received: by localhost.redhat.com (Postfix, from userid 469) id 249FD112E4; Tue, 19 Mar 2002 14:22:13 -0500 (EST) From: Elena Zannoni MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15511.36836.986235.25971@localhost.redhat.com> Date: Tue, 19 Mar 2002 11:23:00 -0000 To: Daniel Jacobowitz Cc: gdb-patches@sources.redhat.com Subject: Re: [rfa] Fix crashes on complex types In-Reply-To: <20020317132145.A5146@nevyn.them.org> References: <20020317132145.A5146@nevyn.them.org> X-Mailer: VM 7.00 under Emacs 20.7.1 X-SW-Source: 2002-03/txt/msg00359.txt.bz2 Daniel Jacobowitz writes: > The complex type support has bitrotten a bit. We used to set > TYPE_TARGET_TYPE properly in all the places we would create such types, > but a few more have crept in during the intervening years. This patch > just makes sure that field is valid, so that we can use it to print > later. This fixes PR gdb/422. Looks good. > > OK to commit? > Any chance you can sneak in a testcase? Steal the gcc one? Elena > -- > Daniel Jacobowitz Carnegie Mellon University > MontaVista Software Debian GNU/Linux Developer > > 2002-03-17 Daniel Jacobowitz > > Fix PR gdb/422. > * c-lang.c (c_create_fundamental_type): Handle FT_COMPLEX, > FT_DBL_PREC_COMPLEX, and FT_EXT_PREC_COMPLEX. > * dwarf2read.c (read_base_type): Set TYPE_TARGET_TYPE for > complex types. > * stabsread.c (rs6000_builtin_type): Likewise. > (read_sun_floating_type): Likewise. > > Index: c-lang.c > =================================================================== > RCS file: /cvs/src/src/gdb/c-lang.c,v > retrieving revision 1.10 > diff -u -p -r1.10 c-lang.c > --- c-lang.c 2002/02/13 18:49:29 1.10 > +++ c-lang.c 2002/03/17 18:17:24 > @@ -338,6 +338,30 @@ c_create_fundamental_type (struct objfil > TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT, > 0, "long double", objfile); > break; > + case FT_COMPLEX: > + type = init_type (TYPE_CODE_FLT, > + 2 * TARGET_FLOAT_BIT / TARGET_CHAR_BIT, > + 0, "complex float", objfile); > + TYPE_TARGET_TYPE (type) > + = init_type (TYPE_CODE_FLT, TARGET_FLOAT_BIT / TARGET_CHAR_BIT, > + 0, "float", objfile); > + break; > + case FT_DBL_PREC_COMPLEX: > + type = init_type (TYPE_CODE_FLT, > + 2 * TARGET_DOUBLE_BIT / TARGET_CHAR_BIT, > + 0, "complex double", objfile); > + TYPE_TARGET_TYPE (type) > + = init_type (TYPE_CODE_FLT, TARGET_DOUBLE_BIT / TARGET_CHAR_BIT, > + 0, "double", objfile); > + break; > + case FT_EXT_PREC_COMPLEX: > + type = init_type (TYPE_CODE_FLT, > + 2 * TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT, > + 0, "complex long double", objfile); > + TYPE_TARGET_TYPE (type) > + = init_type (TYPE_CODE_FLT, TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT, > + 0, "long double", objfile); > + break; > case FT_TEMPLATE_ARG: > type = init_type (TYPE_CODE_TEMPLATE_ARG, > 0, > Index: dwarf2read.c > =================================================================== > RCS file: /cvs/src/src/gdb/dwarf2read.c,v > retrieving revision 1.50 > diff -u -p -r1.50 dwarf2read.c > --- dwarf2read.c 2002/03/14 22:53:35 1.50 > +++ dwarf2read.c 2002/03/17 18:17:25 > @@ -2979,6 +2979,18 @@ read_base_type (struct die_info *die, st > type = init_type (code, size, type_flags, DW_STRING (attr), objfile); > if (encoding == DW_ATE_address) > TYPE_TARGET_TYPE (type) = dwarf2_fundamental_type (objfile, FT_VOID); > + else if (encoding == DW_ATE_complex_float) > + { > + if (size == 32) > + TYPE_TARGET_TYPE (type) > + = dwarf2_fundamental_type (objfile, FT_EXT_PREC_FLOAT); > + else if (size == 16) > + TYPE_TARGET_TYPE (type) > + = dwarf2_fundamental_type (objfile, FT_DBL_PREC_FLOAT); > + else if (size == 8) > + TYPE_TARGET_TYPE (type) > + = dwarf2_fundamental_type (objfile, FT_FLOAT); > + } > } > else > { > Index: stabsread.c > =================================================================== > RCS file: /cvs/src/src/gdb/stabsread.c,v > retrieving revision 1.28 > diff -u -p -r1.28 stabsread.c > --- stabsread.c 2002/03/08 17:19:39 1.28 > +++ stabsread.c 2002/03/17 18:17:25 > @@ -2978,10 +2978,14 @@ rs6000_builtin_type (int typenum) > case 25: > /* Complex type consisting of two IEEE single precision values. */ > rettype = init_type (TYPE_CODE_COMPLEX, 8, 0, "complex", NULL); > + TYPE_TARGET_TYPE (rettype) = init_type (TYPE_CODE_FLT, 4, 0, "float", > + NULL); > break; > case 26: > /* Complex type consisting of two IEEE double precision values. */ > rettype = init_type (TYPE_CODE_COMPLEX, 16, 0, "double complex", NULL); > + TYPE_TARGET_TYPE (rettype) = init_type (TYPE_CODE_FLT, 8, 0, "double", > + NULL); > break; > case 27: > rettype = init_type (TYPE_CODE_INT, 1, 0, "integer*1", NULL); > @@ -4511,6 +4515,7 @@ read_sun_floating_type (char **pp, int t > int nbits; > int details; > int nbytes; > + struct type *rettype; > > /* The first number has more details about the type, for example > FN_COMPLEX. */ > @@ -4525,9 +4530,12 @@ read_sun_floating_type (char **pp, int t > > if (details == NF_COMPLEX || details == NF_COMPLEX16 > || details == NF_COMPLEX32) > - /* This is a type we can't handle, but we do know the size. > - We also will be able to give it a name. */ > - return init_type (TYPE_CODE_COMPLEX, nbytes, 0, NULL, objfile); > + { > + rettype = init_type (TYPE_CODE_COMPLEX, nbytes, 0, NULL, objfile); > + TYPE_TARGET_TYPE (rettype) > + = init_type (TYPE_CODE_FLT, nbytes / 2, 0, NULL, objfile); > + return rettype; > + } > > return init_type (TYPE_CODE_FLT, nbytes, 0, NULL, objfile); > }