From: Ulrich Weigand Date: Thu, 2 Jul 2009 12:18:46 +0000 (+0000) Subject: * gdbtypes.c (lookup_array_range_type): Add prototype. X-Git-Tag: msnyder-checkpoint-072509-branchpoint~245 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e3506a9f27bb02c48fad7978a446777b047efe51;p=external%2Fbinutils.git * gdbtypes.c (lookup_array_range_type): Add prototype. (lookup_string_range_type): Likewise. * gdbtypes.c (lookup_array_range_type): New function. (lookup_string_range_type): Likewise. * ax-gdb.c (gen_repeat): Use lookup_array_range_type. * parse.c (follow_types): Likewise. * jv-lang.c (java_array_type): Likewise. * gnu-v3-abi.c (build_gdb_vtable_type): Likewise. * mt-tdep.c (mt_register_type): Likewise. * sh-tdep.c (sh_sh4_build_float_register_type): Likewise. * sh64-tdep.c (sh64_build_float_register_type): Likewise. * value.c (allocate_repeat_value): Likewise. * valops.c (value_array, value_cstring): Likewise. * valops.c (value_string): Use lookup_string_range_type. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 935a29f..bd617d5 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,23 @@ 2009-07-02 Ulrich Weigand + * gdbtypes.c (lookup_array_range_type): Add prototype. + (lookup_string_range_type): Likewise. + * gdbtypes.c (lookup_array_range_type): New function. + (lookup_string_range_type): Likewise. + + * ax-gdb.c (gen_repeat): Use lookup_array_range_type. + * parse.c (follow_types): Likewise. + * jv-lang.c (java_array_type): Likewise. + * gnu-v3-abi.c (build_gdb_vtable_type): Likewise. + * mt-tdep.c (mt_register_type): Likewise. + * sh-tdep.c (sh_sh4_build_float_register_type): Likewise. + * sh64-tdep.c (sh64_build_float_register_type): Likewise. + * value.c (allocate_repeat_value): Likewise. + * valops.c (value_array, value_cstring): Likewise. + * valops.c (value_string): Use lookup_string_range_type. + +2009-07-02 Ulrich Weigand + * m2-typeprint.c (m2_print_bounds, m2_is_long_set_of_type): Remove redundant check for NULL TYPE_TARGET_TYPE. * m2-valprint.c (m2_print_long_set): Likewise. diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c index 5e04b07..80f6cbf 100644 --- a/gdb/ax-gdb.c +++ b/gdb/ax-gdb.c @@ -1394,9 +1394,8 @@ gen_repeat (struct expression *exp, union exp_element **pc, { /* FIXME-type-allocation: need a way to free this type when we are done with it. */ - struct type *range - = create_range_type (0, builtin_type_int32, 0, length - 1); - struct type *array = create_array_type (0, value1.type, range); + struct type *array + = lookup_array_range_type (value1.type, 0, length - 1); value->kind = axs_lvalue_memory; value->type = array; diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index cd26db8..f9c04f1 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -833,6 +833,17 @@ create_array_type (struct type *result_type, return result_type; } +struct type * +lookup_array_range_type (struct type *element_type, + int low_bound, int high_bound) +{ + struct gdbarch *gdbarch = current_gdbarch; + struct type *index_type = builtin_type (gdbarch)->builtin_int; + struct type *range_type + = create_range_type (NULL, index_type, low_bound, high_bound); + return create_array_type (NULL, element_type, range_type); +} + /* Create a string type using either a blank type supplied in RESULT_TYPE, or creating a new type. String types are similar enough to array of char types that we can use create_array_type to @@ -858,6 +869,17 @@ create_string_type (struct type *result_type, } struct type * +lookup_string_range_type (struct type *string_char_type, + int low_bound, int high_bound) +{ + struct type *result_type; + result_type = lookup_array_range_type (string_char_type, + low_bound, high_bound); + TYPE_CODE (result_type) = TYPE_CODE_STRING; + return result_type; +} + +struct type * create_set_type (struct type *result_type, struct type *domain_type) { if (result_type == NULL) @@ -947,11 +969,7 @@ struct type * init_vector_type (struct type *elt_type, int n) { struct type *array_type; - - array_type = create_array_type (0, elt_type, - create_range_type (0, - builtin_type_int32, - 0, n-1)); + array_type = lookup_array_range_type (elt_type, 0, n - 1); make_vector_type (array_type); return array_type; } diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 152443e..78a1229 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -1201,9 +1201,11 @@ extern struct type *create_range_type (struct type *, struct type *, int, extern struct type *create_array_type (struct type *, struct type *, struct type *); +extern struct type *lookup_array_range_type (struct type *, int, int); extern struct type *create_string_type (struct type *, struct type *, struct type *); +extern struct type *lookup_string_range_type (struct type *, int, int); extern struct type *create_set_type (struct type *, struct type *); diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index 6613e75..cc90c01 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -145,9 +145,7 @@ build_gdb_vtable_type (struct gdbarch *arch) /* ptrdiff_t vcall_and_vbase_offsets[0]; */ FIELD_NAME (*field) = "vcall_and_vbase_offsets"; - FIELD_TYPE (*field) - = create_array_type (0, ptrdiff_type, - create_range_type (0, builtin_type_int32, 0, -1)); + FIELD_TYPE (*field) = lookup_array_range_type (ptrdiff_type, 0, -1); FIELD_BITPOS (*field) = offset * TARGET_CHAR_BIT; offset += TYPE_LENGTH (FIELD_TYPE (*field)); field++; @@ -168,9 +166,7 @@ build_gdb_vtable_type (struct gdbarch *arch) /* void (*virtual_functions[0]) (); */ FIELD_NAME (*field) = "virtual_functions"; - FIELD_TYPE (*field) - = create_array_type (0, ptr_to_void_fn_type, - create_range_type (0, builtin_type_int32, 0, -1)); + FIELD_TYPE (*field) = lookup_array_range_type (ptr_to_void_fn_type, 0, -1); FIELD_BITPOS (*field) = offset * TARGET_CHAR_BIT; offset += TYPE_LENGTH (FIELD_TYPE (*field)); field++; diff --git a/gdb/jv-lang.c b/gdb/jv-lang.c index 8a83416..e522a46 100644 --- a/gdb/jv-lang.c +++ b/gdb/jv-lang.c @@ -803,13 +803,10 @@ java_demangle_type_signature (char *signature) struct type * java_array_type (struct type *type, int dims) { - struct type *range_type; - while (dims-- > 0) { - range_type = create_range_type (NULL, builtin_type_int32, 0, 0); /* FIXME This is bogus! Java arrays are not gdb arrays! */ - type = create_array_type (NULL, type, range_type); + type = lookup_array_range_type (type, 0, 0); } return type; diff --git a/gdb/mt-tdep.c b/gdb/mt-tdep.c index 04029a4..ec52d5b 100644 --- a/gdb/mt-tdep.c +++ b/gdb/mt-tdep.c @@ -257,11 +257,7 @@ mt_register_type (struct gdbarch *arch, int regnum) if (regnum >= 0 && regnum < MT_NUM_REGS + MT_NUM_PSEUDO_REGS) { if (copro_type == NULL) - { - struct type *temp; - temp = create_range_type (NULL, builtin_type_int32, 0, 1); - copro_type = create_array_type (NULL, builtin_type_int16, temp); - } + copro_type = lookup_array_range_type (builtin_type_int16, 0, 1); switch (regnum) { case MT_PC_REGNUM: diff --git a/gdb/parse.c b/gdb/parse.c index de4cd6c..d071a2e 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -1257,7 +1257,6 @@ follow_types (struct type *follow_type) int make_volatile = 0; int make_addr_space = 0; int array_size; - struct type *range_type; while (!done) switch (pop_type ()) @@ -1323,13 +1322,9 @@ follow_types (struct type *follow_type) array_size = pop_type_int (); /* FIXME-type-allocation: need a way to free this type when we are done with it. */ - range_type = - create_range_type ((struct type *) NULL, - builtin_type_int32, 0, - array_size >= 0 ? array_size - 1 : 0); follow_type = - create_array_type ((struct type *) NULL, - follow_type, range_type); + lookup_array_range_type (follow_type, + 0, array_size >= 0 ? array_size - 1 : 0); if (array_size < 0) TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (follow_type) = 1; break; diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c index b86be74..47e0bec 100644 --- a/gdb/sh-tdep.c +++ b/gdb/sh-tdep.c @@ -2146,10 +2146,8 @@ sh_sh3e_register_type (struct gdbarch *gdbarch, int reg_nr) static struct type * sh_sh4_build_float_register_type (struct gdbarch *gdbarch, int high) { - struct type *temp; - - temp = create_range_type (NULL, builtin_type_int32, 0, high); - return create_array_type (NULL, builtin_type (gdbarch)->builtin_float, temp); + return lookup_array_range_type (builtin_type (gdbarch)->builtin_float, + 0, high); } static struct type * diff --git a/gdb/sh64-tdep.c b/gdb/sh64-tdep.c index ab976e2..0214007 100644 --- a/gdb/sh64-tdep.c +++ b/gdb/sh64-tdep.c @@ -1498,10 +1498,8 @@ REGISTER_BYTE returns the register byte for the base register. static struct type * sh64_build_float_register_type (struct gdbarch *gdbarch, int high) { - struct type *temp; - - temp = create_range_type (NULL, builtin_type_int32, 0, high); - return create_array_type (NULL, builtin_type (gdbarch)->builtin_float, temp); + return lookup_array_range_type (builtin_type (gdbarch)->builtin_float, + 0, high); } /* Return the GDB type object for the "standard" data type diff --git a/gdb/valops.c b/gdb/valops.c index c0bc2a5..52debbe 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -1294,7 +1294,6 @@ value_array (int lowbound, int highbound, struct value **elemvec) int idx; unsigned int typelength; struct value *val; - struct type *rangetype; struct type *arraytype; CORE_ADDR addr; @@ -1315,12 +1314,8 @@ value_array (int lowbound, int highbound, struct value **elemvec) } } - rangetype = create_range_type ((struct type *) NULL, - builtin_type_int32, - lowbound, highbound); - arraytype = create_array_type ((struct type *) NULL, - value_enclosing_type (elemvec[0]), - rangetype); + arraytype = lookup_array_range_type (value_enclosing_type (elemvec[0]), + lowbound, highbound); if (!current_language->c_style_arrays) { @@ -1351,12 +1346,8 @@ value_cstring (char *ptr, int len, struct type *char_type) struct value *val; int lowbound = current_language->string_lower_bound; int highbound = len / TYPE_LENGTH (char_type); - struct type *rangetype = create_range_type ((struct type *) NULL, - builtin_type_int32, - lowbound, - highbound + lowbound - 1); struct type *stringtype - = create_array_type ((struct type *) NULL, char_type, rangetype); + = lookup_array_range_type (char_type, lowbound, highbound + lowbound - 1); val = allocate_value (stringtype); memcpy (value_contents_raw (val), ptr, len); @@ -1378,12 +1369,8 @@ value_string (char *ptr, int len, struct type *char_type) struct value *val; int lowbound = current_language->string_lower_bound; int highbound = len / TYPE_LENGTH (char_type); - struct type *rangetype = create_range_type ((struct type *) NULL, - builtin_type_int32, - lowbound, - highbound + lowbound - 1); struct type *stringtype - = create_string_type ((struct type *) NULL, char_type, rangetype); + = lookup_string_range_type (char_type, lowbound, highbound + lowbound - 1); val = allocate_value (stringtype); memcpy (value_contents_raw (val), ptr, len); diff --git a/gdb/value.c b/gdb/value.c index 01066e9..7b95c42 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -290,13 +290,9 @@ allocate_repeat_value (struct type *type, int count) int low_bound = current_language->string_lower_bound; /* ??? */ /* FIXME-type-allocation: need a way to free this type when we are done with it. */ - struct type *range_type - = create_range_type ((struct type *) NULL, builtin_type_int32, - low_bound, count + low_bound - 1); - /* FIXME-type-allocation: need a way to free this type when we are - done with it. */ - return allocate_value (create_array_type ((struct type *) NULL, - type, range_type)); + struct type *array_type + = lookup_array_range_type (type, low_bound, count + low_bound - 1); + return allocate_value (array_type); } /* Needed if another module needs to maintain its on list of values. */