forked from Imagelibrary/binutils-gdb
* coffread.c (decode_type): Use builtin_type_int32 instead
of FT_INTEGER fundamental type for array range index type. (decode_base_type): Use builtin types of current_gdbarch instead of fundamental types. * dwarf2read.c (struct dwarf2_cu): Remove ftypes member. (read_file_scope): Do not initialize ftypes member. (dwarf_base_type, dwarf2_fundamental_types): Remove functions. (read_array_type): Use builtin_type_int32 instead of FT_INTEGER fundamental type for array range index type. (read_tag_string_type): Likewise for string range index type. Also, do not overwrite FT_CHAR type with new string type. (read_base_type): If DW_AT_name is missing, create unnamed type with given properties instead of looking for a fundamental type. Create new types as TYPE_TARGET_TYPE for DW_ATE_address and DW_ATE_complex_float types. (read_subrange_type): Create new type to represent missing DW_AT_type instead of looking for a fundamental type. (die_type): Use builtin type to represent "void" instead of looking for a fundamental type. * stabsread.c (define_symbol): Use builtin types to represent 'r' and 'i' floating-point and integer constants. * gdbtypes.c (lookup_fundamental_type): Remove. * gdbtypes.h (lookup_fundamental_type): Remove prototype. (FT_VOID, FT_BOOLEAN, FT_CHAR, FT_SIGNED_CHAR, FT_UNSIGNED_CHAR, FT_SHORT, FT_SIGNED_SHORT, FT_UNSIGNED_SHORT, FT_INTEGER, FT_SIGNED_INTEGER, FT_UNSIGNED_INTEGER, FT_LONG, FT_SIGNED_LONG, FT_UNSIGNED_LONG, FT_LONG_LONG, FT_SIGNED_LONG_LONG, FT_UNSIGNED_LONG_LONG, FT_FLOAT, FT_DBL_PREC_FLOAT, FT_EXT_PREC_FLOAT, FT_COMPLEX, FT_DBL_PREC_COMPLEX, FT_EXT_PREC_COMPLEX, FT_STRING, FT_FIXED_DECIMAL, FT_FLOAT_DECIMAL, FT_BYTE, FT_UNSIGNED_BYTE, FT_TEMPLATE_ARG, FT_DECFLOAT, FT_DBL_PREC_DECFLOAT, FT_EXT_PREC_DECFLOAT, FT_NUM_MEMBERS): Remove macros. * objfiles.c (struct objfile): Remove fundamental_types member. * symfile.c (reread_symbols): Do not clear fundamental_types. * language.h (struct language_defn): Remove la_fund_type member. (create_fundamental_type): Remove. * language.c (unk_lang_create_fundamental_type): Remove. (unknown_language_defn, auto_language_defn, local_language_defn): Adapt initializer. * ada-lang.c (ada_create_fundamental_type): Remove. (ada_language_defn): Adapt initializer. * c-lang.h (c_create_fundamental_type): Remove prototype. * c-lang.c (c_create_fundamental_type): Remove. (c_language_defn, cplus_language_defn, asm_language_defn, minimal_language_defn): Adapt initializer. * f-lang.c (f_create_fundamental_type): Remove. (f_language_defn): Adapt initializer. * jv-lang.c (java_create_fundamental_type): Remove. (java_language_defn): Adapt initializer. * m2-lang.c (m2_create_fundamental_type): Remove. (m2_language_defn): Adapt initializer. * objc-lang.c (objc_create_fundamental_type): Remove. (objc_language_defn): Adapt initializer. * p-lang.h (pascal_create_fundamental_type): Remove prototype. * p-lang.c (pascal_create_fundamental_type): Remove. (pascal_language_defn): Adapt initializer. * scm-lang.c (scm_language_defn): Adapt initializer.
This commit is contained in:
263
gdb/dwarf2read.c
263
gdb/dwarf2read.c
@@ -288,17 +288,6 @@ struct dwarf2_cu
|
||||
distinguish these in buildsym.c. */
|
||||
struct pending **list_in_scope;
|
||||
|
||||
/* Maintain an array of referenced fundamental types for the current
|
||||
compilation unit being read. For DWARF version 1, we have to construct
|
||||
the fundamental types on the fly, since no information about the
|
||||
fundamental types is supplied. Each such fundamental type is created by
|
||||
calling a language dependent routine to create the type, and then a
|
||||
pointer to that type is then placed in the array at the index specified
|
||||
by it's FT_<TYPENAME> value. The array has a fixed size set by the
|
||||
FT_NUM_MEMBERS compile time constant, which is the number of predefined
|
||||
fundamental types gdb knows how to construct. */
|
||||
struct type *ftypes[FT_NUM_MEMBERS]; /* Fundamental types */
|
||||
|
||||
/* DWARF abbreviation table associated with this compilation unit. */
|
||||
struct abbrev_info **dwarf2_abbrevs;
|
||||
|
||||
@@ -936,8 +925,6 @@ static void read_enumeration_type (struct die_info *, struct dwarf2_cu *);
|
||||
|
||||
static void process_enumeration_scope (struct die_info *, struct dwarf2_cu *);
|
||||
|
||||
static struct type *dwarf_base_type (int, int, struct dwarf2_cu *);
|
||||
|
||||
static CORE_ADDR decode_locdesc (struct dwarf_block *, struct dwarf2_cu *);
|
||||
|
||||
static void read_array_type (struct die_info *, struct dwarf2_cu *);
|
||||
@@ -1019,9 +1006,6 @@ static struct die_info *follow_die_ref (struct die_info *,
|
||||
struct attribute *,
|
||||
struct dwarf2_cu *);
|
||||
|
||||
static struct type *dwarf2_fundamental_type (struct objfile *, int,
|
||||
struct dwarf2_cu *);
|
||||
|
||||
/* memory allocation interface */
|
||||
|
||||
static struct dwarf_block *dwarf_alloc_block (struct dwarf2_cu *);
|
||||
@@ -2844,10 +2828,6 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu)
|
||||
/* We assume that we're processing GCC output. */
|
||||
processing_gcc_compilation = 2;
|
||||
|
||||
/* The compilation unit may be in a different language or objfile,
|
||||
zero out all remembered fundamental types. */
|
||||
memset (cu->ftypes, 0, FT_NUM_MEMBERS * sizeof (struct type *));
|
||||
|
||||
start_symtab (name, comp_dir, lowpc);
|
||||
record_debugformat ("DWARF 2");
|
||||
record_producer (cu->producer);
|
||||
@@ -4284,7 +4264,7 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu)
|
||||
arrays with unspecified length. */
|
||||
if (die->child == NULL)
|
||||
{
|
||||
index_type = dwarf2_fundamental_type (objfile, FT_INTEGER, cu);
|
||||
index_type = builtin_type_int32;
|
||||
range_type = create_range_type (NULL, index_type, 0, -1);
|
||||
set_die_type (die, create_array_type (NULL, element_type, range_type),
|
||||
cu);
|
||||
@@ -4719,19 +4699,11 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu)
|
||||
length = 1;
|
||||
}
|
||||
}
|
||||
index_type = dwarf2_fundamental_type (objfile, FT_INTEGER, cu);
|
||||
|
||||
index_type = builtin_type_int32;
|
||||
range_type = create_range_type (NULL, index_type, 1, length);
|
||||
if (cu->language == language_fortran)
|
||||
{
|
||||
/* Need to create a unique string type for bounds
|
||||
information */
|
||||
type = create_string_type (0, range_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
char_type = dwarf2_fundamental_type (objfile, FT_CHAR, cu);
|
||||
type = create_string_type (char_type, range_type);
|
||||
}
|
||||
type = create_string_type (NULL, range_type);
|
||||
|
||||
set_die_type (die, type, cu);
|
||||
}
|
||||
|
||||
@@ -4846,6 +4818,9 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
|
||||
struct attribute *attr;
|
||||
int encoding = 0, size = 0;
|
||||
char *name;
|
||||
enum type_code code = TYPE_CODE_INT;
|
||||
int type_flags = 0;
|
||||
struct type *target_type = NULL;
|
||||
|
||||
/* If we've already decoded this die, this is a no-op. */
|
||||
if (die->type)
|
||||
@@ -4864,71 +4839,57 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
|
||||
size = DW_UNSND (attr);
|
||||
}
|
||||
name = dwarf2_name (die, cu);
|
||||
if (name)
|
||||
if (!name)
|
||||
{
|
||||
enum type_code code = TYPE_CODE_INT;
|
||||
int type_flags = 0;
|
||||
complaint (&symfile_complaints,
|
||||
_("DW_AT_name missing from DW_TAG_base_type"));
|
||||
}
|
||||
|
||||
switch (encoding)
|
||||
{
|
||||
case DW_ATE_address:
|
||||
/* Turn DW_ATE_address into a void * pointer. */
|
||||
code = TYPE_CODE_PTR;
|
||||
type_flags |= TYPE_FLAG_UNSIGNED;
|
||||
break;
|
||||
case DW_ATE_boolean:
|
||||
code = TYPE_CODE_BOOL;
|
||||
type_flags |= TYPE_FLAG_UNSIGNED;
|
||||
break;
|
||||
case DW_ATE_complex_float:
|
||||
code = TYPE_CODE_COMPLEX;
|
||||
break;
|
||||
case DW_ATE_decimal_float:
|
||||
code = TYPE_CODE_DECFLOAT;
|
||||
break;
|
||||
case DW_ATE_float:
|
||||
code = TYPE_CODE_FLT;
|
||||
break;
|
||||
case DW_ATE_signed:
|
||||
break;
|
||||
case DW_ATE_unsigned:
|
||||
type_flags |= TYPE_FLAG_UNSIGNED;
|
||||
break;
|
||||
case DW_ATE_signed_char:
|
||||
if (cu->language == language_m2)
|
||||
code = TYPE_CODE_CHAR;
|
||||
break;
|
||||
case DW_ATE_unsigned_char:
|
||||
if (cu->language == language_m2)
|
||||
code = TYPE_CODE_CHAR;
|
||||
type_flags |= TYPE_FLAG_UNSIGNED;
|
||||
break;
|
||||
default:
|
||||
complaint (&symfile_complaints, _("unsupported DW_AT_encoding: '%s'"),
|
||||
dwarf_type_encoding_name (encoding));
|
||||
break;
|
||||
}
|
||||
type = init_type (code, size, type_flags, name, objfile);
|
||||
if (encoding == DW_ATE_address)
|
||||
TYPE_TARGET_TYPE (type) = dwarf2_fundamental_type (objfile, FT_VOID,
|
||||
cu);
|
||||
else if (encoding == DW_ATE_complex_float)
|
||||
{
|
||||
if (size == 32)
|
||||
TYPE_TARGET_TYPE (type)
|
||||
= dwarf2_fundamental_type (objfile, FT_EXT_PREC_FLOAT, cu);
|
||||
else if (size == 16)
|
||||
TYPE_TARGET_TYPE (type)
|
||||
= dwarf2_fundamental_type (objfile, FT_DBL_PREC_FLOAT, cu);
|
||||
else if (size == 8)
|
||||
TYPE_TARGET_TYPE (type)
|
||||
= dwarf2_fundamental_type (objfile, FT_FLOAT, cu);
|
||||
}
|
||||
}
|
||||
else
|
||||
switch (encoding)
|
||||
{
|
||||
type = dwarf_base_type (encoding, size, cu);
|
||||
case DW_ATE_address:
|
||||
/* Turn DW_ATE_address into a void * pointer. */
|
||||
code = TYPE_CODE_PTR;
|
||||
type_flags |= TYPE_FLAG_UNSIGNED;
|
||||
target_type = init_type (TYPE_CODE_VOID, 1, 0, NULL, objfile);
|
||||
break;
|
||||
case DW_ATE_boolean:
|
||||
code = TYPE_CODE_BOOL;
|
||||
type_flags |= TYPE_FLAG_UNSIGNED;
|
||||
break;
|
||||
case DW_ATE_complex_float:
|
||||
code = TYPE_CODE_COMPLEX;
|
||||
target_type = init_type (TYPE_CODE_FLT, size / 2, 0, NULL, objfile);
|
||||
break;
|
||||
case DW_ATE_decimal_float:
|
||||
code = TYPE_CODE_DECFLOAT;
|
||||
break;
|
||||
case DW_ATE_float:
|
||||
code = TYPE_CODE_FLT;
|
||||
break;
|
||||
case DW_ATE_signed:
|
||||
break;
|
||||
case DW_ATE_unsigned:
|
||||
type_flags |= TYPE_FLAG_UNSIGNED;
|
||||
break;
|
||||
case DW_ATE_signed_char:
|
||||
if (cu->language == language_m2)
|
||||
code = TYPE_CODE_CHAR;
|
||||
break;
|
||||
case DW_ATE_unsigned_char:
|
||||
if (cu->language == language_m2)
|
||||
code = TYPE_CODE_CHAR;
|
||||
type_flags |= TYPE_FLAG_UNSIGNED;
|
||||
break;
|
||||
default:
|
||||
complaint (&symfile_complaints, _("unsupported DW_AT_encoding: '%s'"),
|
||||
dwarf_type_encoding_name (encoding));
|
||||
break;
|
||||
}
|
||||
|
||||
type = init_type (code, size, type_flags, name, objfile);
|
||||
TYPE_TARGET_TYPE (type) = target_type;
|
||||
|
||||
set_die_type (die, type, cu);
|
||||
}
|
||||
|
||||
@@ -4954,8 +4915,8 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
|
||||
complaint (&symfile_complaints,
|
||||
_("DW_AT_type missing from DW_TAG_subrange_type"));
|
||||
base_type
|
||||
= dwarf_base_type (DW_ATE_signed,
|
||||
gdbarch_addr_bit (current_gdbarch) / 8, cu);
|
||||
= init_type (TYPE_CODE_INT, gdbarch_addr_bit (current_gdbarch) / 8,
|
||||
0, NULL, cu->objfile);
|
||||
}
|
||||
|
||||
if (cu->language == language_fortran)
|
||||
@@ -7515,7 +7476,7 @@ die_type (struct die_info *die, struct dwarf2_cu *cu)
|
||||
if (!type_attr)
|
||||
{
|
||||
/* A missing DW_AT_type represents a void type. */
|
||||
return dwarf2_fundamental_type (cu->objfile, FT_VOID, cu);
|
||||
return builtin_type (current_gdbarch)->builtin_void;
|
||||
}
|
||||
else
|
||||
type_die = follow_die_ref (die, type_attr, cu);
|
||||
@@ -7760,92 +7721,6 @@ typename_concat (struct obstack *obs, const char *prefix, const char *suffix,
|
||||
}
|
||||
}
|
||||
|
||||
static struct type *
|
||||
dwarf_base_type (int encoding, int size, struct dwarf2_cu *cu)
|
||||
{
|
||||
struct objfile *objfile = cu->objfile;
|
||||
|
||||
/* FIXME - this should not produce a new (struct type *)
|
||||
every time. It should cache base types. */
|
||||
struct type *type;
|
||||
switch (encoding)
|
||||
{
|
||||
case DW_ATE_address:
|
||||
type = dwarf2_fundamental_type (objfile, FT_VOID, cu);
|
||||
return type;
|
||||
case DW_ATE_boolean:
|
||||
type = dwarf2_fundamental_type (objfile, FT_BOOLEAN, cu);
|
||||
return type;
|
||||
case DW_ATE_complex_float:
|
||||
if (size == 16)
|
||||
{
|
||||
type = dwarf2_fundamental_type (objfile, FT_DBL_PREC_COMPLEX, cu);
|
||||
}
|
||||
else
|
||||
{
|
||||
type = dwarf2_fundamental_type (objfile, FT_COMPLEX, cu);
|
||||
}
|
||||
return type;
|
||||
case DW_ATE_float:
|
||||
if (size == 8)
|
||||
{
|
||||
type = dwarf2_fundamental_type (objfile, FT_DBL_PREC_FLOAT, cu);
|
||||
}
|
||||
else
|
||||
{
|
||||
type = dwarf2_fundamental_type (objfile, FT_FLOAT, cu);
|
||||
}
|
||||
return type;
|
||||
case DW_ATE_decimal_float:
|
||||
if (size == 16)
|
||||
type = dwarf2_fundamental_type (objfile, FT_DBL_PREC_DECFLOAT, cu);
|
||||
else if (size == 8)
|
||||
type = dwarf2_fundamental_type (objfile, FT_EXT_PREC_DECFLOAT, cu);
|
||||
else
|
||||
type = dwarf2_fundamental_type (objfile, FT_DECFLOAT, cu);
|
||||
return type;
|
||||
case DW_ATE_signed:
|
||||
switch (size)
|
||||
{
|
||||
case 1:
|
||||
type = dwarf2_fundamental_type (objfile, FT_SIGNED_CHAR, cu);
|
||||
break;
|
||||
case 2:
|
||||
type = dwarf2_fundamental_type (objfile, FT_SIGNED_SHORT, cu);
|
||||
break;
|
||||
default:
|
||||
case 4:
|
||||
type = dwarf2_fundamental_type (objfile, FT_SIGNED_INTEGER, cu);
|
||||
break;
|
||||
}
|
||||
return type;
|
||||
case DW_ATE_signed_char:
|
||||
type = dwarf2_fundamental_type (objfile, FT_SIGNED_CHAR, cu);
|
||||
return type;
|
||||
case DW_ATE_unsigned:
|
||||
switch (size)
|
||||
{
|
||||
case 1:
|
||||
type = dwarf2_fundamental_type (objfile, FT_UNSIGNED_CHAR, cu);
|
||||
break;
|
||||
case 2:
|
||||
type = dwarf2_fundamental_type (objfile, FT_UNSIGNED_SHORT, cu);
|
||||
break;
|
||||
default:
|
||||
case 4:
|
||||
type = dwarf2_fundamental_type (objfile, FT_UNSIGNED_INTEGER, cu);
|
||||
break;
|
||||
}
|
||||
return type;
|
||||
case DW_ATE_unsigned_char:
|
||||
type = dwarf2_fundamental_type (objfile, FT_UNSIGNED_CHAR, cu);
|
||||
return type;
|
||||
default:
|
||||
type = dwarf2_fundamental_type (objfile, FT_SIGNED_INTEGER, cu);
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
struct die_info *
|
||||
copy_die (struct die_info *old_die)
|
||||
@@ -9069,28 +8944,6 @@ follow_die_ref (struct die_info *src_die, struct attribute *attr,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct type *
|
||||
dwarf2_fundamental_type (struct objfile *objfile, int typeid,
|
||||
struct dwarf2_cu *cu)
|
||||
{
|
||||
if (typeid < 0 || typeid >= FT_NUM_MEMBERS)
|
||||
{
|
||||
error (_("Dwarf Error: internal error - invalid fundamental type id %d [in module %s]"),
|
||||
typeid, objfile->name);
|
||||
}
|
||||
|
||||
/* Look for this particular type in the fundamental type vector. If
|
||||
one is not found, create and install one appropriate for the
|
||||
current language and the current target machine. */
|
||||
|
||||
if (cu->ftypes[typeid] == NULL)
|
||||
{
|
||||
cu->ftypes[typeid] = cu->language_defn->la_fund_type (objfile, typeid);
|
||||
}
|
||||
|
||||
return (cu->ftypes[typeid]);
|
||||
}
|
||||
|
||||
/* Decode simple location descriptions.
|
||||
Given a pointer to a dwarf block that defines a location, compute
|
||||
the location and return the value.
|
||||
|
||||
Reference in New Issue
Block a user