From: Daniel Jacobowitz <drow@mvista.com>
To: gdb-patches@sources.redhat.com
Subject: [rfa] Fix crashes on complex types
Date: Sun, 17 Mar 2002 10:21:00 -0000 [thread overview]
Message-ID: <20020317132145.A5146@nevyn.them.org> (raw)
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.
OK to commit?
--
Daniel Jacobowitz Carnegie Mellon University
MontaVista Software Debian GNU/Linux Developer
2002-03-17 Daniel Jacobowitz <drow@mvista.com>
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);
}
next reply other threads:[~2002-03-17 18:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-03-17 10:21 Daniel Jacobowitz [this message]
2002-03-19 11:23 ` Elena Zannoni
2002-03-19 11:27 ` Daniel Jacobowitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20020317132145.A5146@nevyn.them.org \
--to=drow@mvista.com \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox