aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2read.c
diff options
context:
space:
mode:
authorUlrich Weigand <ulrich.weigand@de.ibm.com>2016-09-06 17:27:55 +0200
committerUlrich Weigand <ulrich.weigand@de.ibm.com>2016-09-06 17:27:55 +0200
commit19f392bc2a93d9e64d063b884cd6eca547c8dad0 (patch)
tree64968dc1b18a4cad8872489c2e9c39f5b5a7edcc /gdb/dwarf2read.c
parent88dfca6c43c11dea69db24cfb87e6821e63e29b2 (diff)
downloadgdb-19f392bc2a93d9e64d063b884cd6eca547c8dad0.zip
gdb-19f392bc2a93d9e64d063b884cd6eca547c8dad0.tar.gz
gdb-19f392bc2a93d9e64d063b884cd6eca547c8dad0.tar.bz2
Unify init_type and arch_type interface and helpers
This adds a number of helper routines for creating objfile-owned types; these correspond 1:1 to the already existing helper routines for creating gdbarch-owned types, and are intended to be used instead of init_type. A shared fragment of init_float_type and arch_float_type is extracted into a separate subroutine verify_subroutine. The commit also brings the interface of init_type in line with the one for arch_type. In particular, this means removing the FLAGS argument; callers now set the required flags directly. (Since most callers use the new helper routines, very few callers actually need to set any additional flags directly any more.) Note that this means all the TYPE_FLAGS_... defined are no longer needed anywhere; they will be removed by a follow-on commit. All users of init_type are changed to use on of the new helpers where possible. No functional change intended. gdb/ChangeLog: * gdbtypes.h (init_type): Remove FLAGS argument. Move OBJFILE argument to first position. (init_integer_type): New prototype. (init_character_type): Likewise. (init_boolean_type): Likewise. (init_float_type): Likewise. (init_decfloat_type): Likewise. (init_complex_type): Likewise. (init_pointer_type): Likewise. * gdbtypes.c (verify_floatflormat): New function. (init_type): Remove FLAGS argument and processing. Move OBJFILE argument to first position. (init_integer_type): New function. (init_character_type): Likewise. (init_boolean_type): Likewise. (init_float_type): Likewise. (init_decfloat_type): Likewise. (init_complex_type): Likewise. (init_pointer_type): Likewise. (arch_float_type): Use verify_floatflormat. (objfile_type): Use init_..._type helpers instead of calling init_type directly. * dwarf2read.c (fixup_go_packaging): Update to changed init_type prototype. (read_namespace_type): Likewise. (read_module_type): Likewise. (read_typedef): Likewise. (read_unspecified_type): Likewise. (build_error_marker_type): Likewise. (read_base_type): Use init_..._type helpers. * mdebugread.c (basic_type): Use init_..._type helpers. (parse_type): Update to changed init_type prototype. (cross_ref): Likewise. * stabsread.c (rs6000_builtin_type): Use init_..._type helpers. (read_sun_builtin_type): Likewise. (read_sun_floating_type): Likewise. (read_range_type): Likewise. Also update to changed init_type prototype. Signed-off-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
Diffstat (limited to 'gdb/dwarf2read.c')
-rw-r--r--gdb/dwarf2read.c64
1 files changed, 30 insertions, 34 deletions
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 9ad2caa..746290e 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -7865,8 +7865,8 @@ fixup_go_packaging (struct dwarf2_cu *cu)
= (const char *) obstack_copy0 (&objfile->per_bfd->storage_obstack,
package_name,
strlen (package_name));
- struct type *type = init_type (TYPE_CODE_MODULE, 0, 0,
- saved_package_name, objfile);
+ struct type *type = init_type (objfile, TYPE_CODE_MODULE, 0,
+ saved_package_name);
struct symbol *sym;
TYPE_TAG_NAME (type) = TYPE_NAME (type);
@@ -14136,9 +14136,7 @@ read_namespace_type (struct die_info *die, struct dwarf2_cu *cu)
previous_prefix, name, 0, cu);
/* Create the type. */
- type = init_type (TYPE_CODE_NAMESPACE, 0, 0, NULL,
- objfile);
- TYPE_NAME (type) = name;
+ type = init_type (objfile, TYPE_CODE_NAMESPACE, 0, name);
TYPE_TAG_NAME (type) = TYPE_NAME (type);
return set_die_type (die, type, cu);
@@ -14202,7 +14200,7 @@ read_module_type (struct die_info *die, struct dwarf2_cu *cu)
complaint (&symfile_complaints,
_("DW_TAG_module has no name, offset 0x%x"),
die->offset.sect_off);
- type = init_type (TYPE_CODE_MODULE, 0, 0, module_name, objfile);
+ type = init_type (objfile, TYPE_CODE_MODULE, 0, module_name);
/* determine_prefix uses TYPE_TAG_NAME. */
TYPE_TAG_NAME (type) = TYPE_NAME (type);
@@ -14740,9 +14738,8 @@ read_typedef (struct die_info *die, struct dwarf2_cu *cu)
struct type *this_type, *target_type;
name = dwarf2_full_name (NULL, die, cu);
- this_type = init_type (TYPE_CODE_TYPEDEF, 0,
- TYPE_FLAG_TARGET_STUB, NULL, objfile);
- TYPE_NAME (this_type) = name;
+ this_type = init_type (objfile, TYPE_CODE_TYPEDEF, 0, name);
+ TYPE_TARGET_STUB (this_type) = 1;
set_die_type (die, this_type, cu);
target_type = die_type (die, cu);
if (target_type != this_type)
@@ -14769,11 +14766,8 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
struct objfile *objfile = cu->objfile;
struct type *type;
struct attribute *attr;
- int encoding = 0, size = 0;
+ int encoding = 0, bits = 0;
const char *name;
- enum type_code code = TYPE_CODE_INT;
- int type_flags = 0;
- struct type *target_type = NULL;
attr = dwarf2_attr (die, DW_AT_encoding, cu);
if (attr)
@@ -14783,7 +14777,7 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
attr = dwarf2_attr (die, DW_AT_byte_size, cu);
if (attr)
{
- size = DW_UNSND (attr);
+ bits = DW_UNSND (attr) * TARGET_CHAR_BIT;
}
name = dwarf2_name (die, cu);
if (!name)
@@ -14796,62 +14790,64 @@ read_base_type (struct die_info *die, struct dwarf2_cu *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);
+ type = init_type (objfile, TYPE_CODE_VOID, 1, NULL);
+ type = init_pointer_type (objfile, bits, name, type);
break;
case DW_ATE_boolean:
- code = TYPE_CODE_BOOL;
- type_flags |= TYPE_FLAG_UNSIGNED;
+ type = init_boolean_type (objfile, bits, 1, name);
break;
case DW_ATE_complex_float:
- code = TYPE_CODE_COMPLEX;
- target_type = init_type (TYPE_CODE_FLT, size / 2, 0, NULL, objfile);
+ type = init_float_type (objfile, bits / 2, NULL, NULL);
+ type = init_complex_type (objfile, name, type);
break;
case DW_ATE_decimal_float:
- code = TYPE_CODE_DECFLOAT;
+ type = init_decfloat_type (objfile, bits, name);
break;
case DW_ATE_float:
- code = TYPE_CODE_FLT;
+ type = init_float_type (objfile, bits, name, NULL);
break;
case DW_ATE_signed:
+ type = init_integer_type (objfile, bits, 0, name);
break;
case DW_ATE_unsigned:
- type_flags |= TYPE_FLAG_UNSIGNED;
if (cu->language == language_fortran
&& name
&& startswith (name, "character("))
- code = TYPE_CODE_CHAR;
+ type = init_character_type (objfile, bits, 1, name);
+ else
+ type = init_integer_type (objfile, bits, 1, name);
break;
case DW_ATE_signed_char:
if (cu->language == language_ada || cu->language == language_m2
|| cu->language == language_pascal
|| cu->language == language_fortran)
- code = TYPE_CODE_CHAR;
+ type = init_character_type (objfile, bits, 0, name);
+ else
+ type = init_integer_type (objfile, bits, 0, name);
break;
case DW_ATE_unsigned_char:
if (cu->language == language_ada || cu->language == language_m2
|| cu->language == language_pascal
|| cu->language == language_fortran
|| cu->language == language_rust)
- code = TYPE_CODE_CHAR;
- type_flags |= TYPE_FLAG_UNSIGNED;
+ type = init_character_type (objfile, bits, 1, name);
+ else
+ type = init_integer_type (objfile, bits, 1, name);
break;
case DW_ATE_UTF:
/* We just treat this as an integer and then recognize the
type by name elsewhere. */
+ type = init_integer_type (objfile, bits, 0, name);
break;
default:
complaint (&symfile_complaints, _("unsupported DW_AT_encoding: '%s'"),
dwarf_type_encoding_name (encoding));
+ type = init_type (objfile, TYPE_CODE_ERROR,
+ bits / TARGET_CHAR_BIT, name);
break;
}
- type = init_type (code, size, type_flags, NULL, objfile);
- TYPE_NAME (type) = name;
- TYPE_TARGET_TYPE (type) = target_type;
-
if (name && strcmp (name, "char") == 0)
TYPE_NOSIGN (type) = 1;
@@ -15131,7 +15127,7 @@ read_unspecified_type (struct die_info *die, struct dwarf2_cu *cu)
/* For now, we only support the C meaning of an unspecified type: void. */
- type = init_type (TYPE_CODE_VOID, 0, 0, NULL, cu->objfile);
+ type = init_type (cu->objfile, TYPE_CODE_VOID, 0, NULL);
TYPE_NAME (type) = dwarf2_name (die, cu);
return set_die_type (die, type, cu);
@@ -19027,7 +19023,7 @@ build_error_marker_type (struct dwarf2_cu *cu, struct die_info *die)
message, strlen (message));
xfree (message);
- return init_type (TYPE_CODE_ERROR, 0, 0, saved, objfile);
+ return init_type (objfile, TYPE_CODE_ERROR, 0, saved);
}
/* Look up the type of DIE in CU using its type attribute ATTR.