X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;ds=sidebyside;f=gdb%2Fada-lang.c;h=643cbec1e61110201f1d4046dc4438be312bd8e8;hb=44e36d8a7bda0394ebfe93378868c79b63c24aa3;hp=baeef0a923c1924ff1ca17d235611b6c86046dcd;hpb=21b556f400421068d5d1928b65750a909c2f716e;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index baeef0a923..643cbec1e6 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -115,13 +115,12 @@ static struct value *make_array_descriptor (struct type *, struct value *, static void ada_add_block_symbols (struct obstack *, struct block *, const char *, - domain_enum, struct objfile *, - struct symtab *, int); + domain_enum, struct objfile *, int); static int is_nonfunction (struct ada_symbol_info *, int); static void add_defn_to_vec (struct obstack *, struct symbol *, - struct block *, struct symtab *); + struct block *); static int num_defns_collected (struct obstack *); @@ -622,39 +621,40 @@ min_of_type (struct type *t) } /* The largest value in the domain of TYPE, a discrete type, as an integer. */ -static struct value * +static LONGEST discrete_type_high_bound (struct type *type) { switch (TYPE_CODE (type)) { case TYPE_CODE_RANGE: - return value_from_longest (TYPE_TARGET_TYPE (type), - TYPE_HIGH_BOUND (type)); + return TYPE_HIGH_BOUND (type); case TYPE_CODE_ENUM: - return - value_from_longest (type, - TYPE_FIELD_BITPOS (type, - TYPE_NFIELDS (type) - 1)); + return TYPE_FIELD_BITPOS (type, TYPE_NFIELDS (type) - 1); + case TYPE_CODE_BOOL: + return 1; + case TYPE_CODE_CHAR: case TYPE_CODE_INT: - return value_from_longest (type, max_of_type (type)); + return max_of_type (type); default: error (_("Unexpected type in discrete_type_high_bound.")); } } /* The largest value in the domain of TYPE, a discrete type, as an integer. */ -static struct value * +static LONGEST discrete_type_low_bound (struct type *type) { switch (TYPE_CODE (type)) { case TYPE_CODE_RANGE: - return value_from_longest (TYPE_TARGET_TYPE (type), - TYPE_LOW_BOUND (type)); + return TYPE_LOW_BOUND (type); case TYPE_CODE_ENUM: - return value_from_longest (type, TYPE_FIELD_BITPOS (type, 0)); + return TYPE_FIELD_BITPOS (type, 0); + case TYPE_CODE_BOOL: + return 0; + case TYPE_CODE_CHAR: case TYPE_CODE_INT: - return value_from_longest (type, min_of_type (type)); + return min_of_type (type); default: error (_("Unexpected type in discrete_type_low_bound.")); } @@ -1203,22 +1203,11 @@ ada_decode_symbol (const struct general_symbol_info *gsymbol) if (*resultp == NULL) { const char *decoded = ada_decode (gsymbol->name); - if (gsymbol->bfd_section != NULL) + if (gsymbol->obj_section != NULL) { - bfd *obfd = gsymbol->bfd_section->owner; - if (obfd != NULL) - { - struct objfile *objf; - ALL_OBJFILES (objf) - { - if (obfd == objf->obfd) - { - *resultp = obsavestring (decoded, strlen (decoded), - &objf->objfile_obstack); - break; - } - } - } + struct objfile *objf = gsymbol->obj_section->objfile; + *resultp = obsavestring (decoded, strlen (decoded), + &objf->objfile_obstack); } /* Sometimes, we can't find a corresponding objfile, in which case, we put the result on the heap. Since we only decode @@ -1829,7 +1818,7 @@ packed_array_type (struct type *type, long *elt_bits) (*elt_bits + HOST_CHAR_BIT - 1) / HOST_CHAR_BIT; } - TYPE_FLAGS (new_type) |= TYPE_FLAG_FIXED_INSTANCE; + TYPE_FIXED_INSTANCE (new_type) = 1; return new_type; } @@ -2253,6 +2242,7 @@ ada_value_assign (struct value *toval, struct value *fromval) { int len = (value_bitpos (toval) + bits + HOST_CHAR_BIT - 1) / HOST_CHAR_BIT; + int from_size; char *buffer = (char *) alloca (len); struct value *val; CORE_ADDR to_addr = VALUE_ADDRESS (toval) + value_offset (toval); @@ -2261,11 +2251,12 @@ ada_value_assign (struct value *toval, struct value *fromval) fromval = value_cast (type, fromval); read_memory (to_addr, buffer, len); + from_size = value_bitsize (fromval); + if (from_size == 0) + from_size = TYPE_LENGTH (value_type (fromval)) * TARGET_CHAR_BIT; if (gdbarch_bits_big_endian (current_gdbarch)) move_bits (buffer, value_bitpos (toval), - value_contents (fromval), - TYPE_LENGTH (value_type (fromval)) * TARGET_CHAR_BIT - - bits, bits); + value_contents (fromval), from_size - bits, bits); else move_bits (buffer, value_bitpos (toval), value_contents (fromval), 0, bits); @@ -2891,14 +2882,9 @@ resolve_subexp (struct expression **expp, int *pos, int deprocedure_p, case LOC_REGISTER: case LOC_ARG: case LOC_REF_ARG: - case LOC_REGPARM: case LOC_REGPARM_ADDR: case LOC_LOCAL: - case LOC_LOCAL_ARG: - case LOC_BASEREG: - case LOC_BASEREG_ARG: case LOC_COMPUTED: - case LOC_COMPUTED_ARG: goto FoundNonType; default: break; @@ -3976,15 +3962,14 @@ make_array_descriptor (struct type *type, struct value *arr, CORE_ADDR *sp) static int lookup_cached_symbol (const char *name, domain_enum namespace, - struct symbol **sym, struct block **block, - struct symtab **symtab) + struct symbol **sym, struct block **block) { return 0; } static void cache_symbol (const char *name, domain_enum namespace, struct symbol *sym, - struct block *block, struct symtab *symtab) + struct block *block) { } @@ -3998,13 +3983,11 @@ standard_lookup (const char *name, const struct block *block, domain_enum domain) { struct symbol *sym; - struct symtab *symtab; - if (lookup_cached_symbol (name, domain, &sym, NULL, NULL)) + if (lookup_cached_symbol (name, domain, &sym, NULL)) return sym; - sym = - lookup_symbol_in_language (name, block, domain, language_c, 0, &symtab); - cache_symbol (name, domain, sym, block_found, symtab); + sym = lookup_symbol_in_language (name, block, domain, language_c, 0); + cache_symbol (name, domain, sym, block_found); return sym; } @@ -4089,7 +4072,7 @@ lesseq_defined_than (struct symbol *sym0, struct symbol *sym1) static void add_defn_to_vec (struct obstack *obstackp, struct symbol *sym, - struct block *block, struct symtab *symtab) + struct block *block) { int i; size_t tmp; @@ -4112,7 +4095,6 @@ add_defn_to_vec (struct obstack *obstackp, { prevDefns[i].sym = sym; prevDefns[i].block = block; - prevDefns[i].symtab = symtab; return; } } @@ -4122,7 +4104,6 @@ add_defn_to_vec (struct obstack *obstackp, info.sym = sym; info.block = block; - info.symtab = symtab; obstack_grow (obstackp, &info, sizeof (struct ada_symbol_info)); } } @@ -4324,15 +4305,10 @@ symtab_for_sym (struct symbol *sym) case LOC_REGISTER: case LOC_ARG: case LOC_REF_ARG: - case LOC_REGPARM: case LOC_REGPARM_ADDR: case LOC_LOCAL: case LOC_TYPEDEF: - case LOC_LOCAL_ARG: - case LOC_BASEREG: - case LOC_BASEREG_ARG: case LOC_COMPUTED: - case LOC_COMPUTED_ARG: for (j = FIRST_LOCAL_BLOCK; j < BLOCKVECTOR_NBLOCKS (BLOCKVECTOR (s)); j += 1) { @@ -4639,7 +4615,7 @@ remove_irrelevant_renamings (struct ada_symbol_info *syms, if (current_block == NULL) return nsyms; - current_function = block_function (current_block); + current_function = block_linkage_function (current_block); if (current_function == NULL) return nsyms; @@ -4672,7 +4648,7 @@ remove_irrelevant_renamings (struct ada_symbol_info *syms, /* Find symbols in DOMAIN matching NAME0, in BLOCK0 and enclosing scope and in global scopes, returning the number of matches. Sets - *RESULTS to point to a vector of (SYM,BLOCK,SYMTAB) triples, + *RESULTS to point to a vector of (SYM,BLOCK) tuples, indicating the symbols found and the blocks and symbol tables (if any) in which they were found. This vector are transient---good only to the next call of ada_lookup_symbol_list. Any non-function/non-enumeral @@ -4726,7 +4702,7 @@ ada_lookup_symbol_list (const char *name0, const struct block *block0, { block_depth += 1; ada_add_block_symbols (&symbol_list_obstack, block, name, - namespace, NULL, NULL, wild_match); + namespace, NULL, wild_match); /* If we found a non-function match, assume that's the one. */ if (is_nonfunction (defns_collected (&symbol_list_obstack, 0), @@ -4748,10 +4724,10 @@ ada_lookup_symbol_list (const char *name0, const struct block *block0, goto done; cacheIfUnique = 1; - if (lookup_cached_symbol (name0, namespace, &sym, &block, &s)) + if (lookup_cached_symbol (name0, namespace, &sym, &block)) { if (sym != NULL) - add_defn_to_vec (&symbol_list_obstack, sym, block, s); + add_defn_to_vec (&symbol_list_obstack, sym, block); goto done; } @@ -4764,7 +4740,7 @@ ada_lookup_symbol_list (const char *name0, const struct block *block0, bv = BLOCKVECTOR (s); block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK); ada_add_block_symbols (&symbol_list_obstack, block, name, namespace, - objfile, s, wild_match); + objfile, wild_match); } if (namespace == VAR_DOMAIN) @@ -4787,14 +4763,14 @@ ada_lookup_symbol_list (const char *name0, const struct block *block0, block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK); ada_add_block_symbols (&symbol_list_obstack, block, SYMBOL_LINKAGE_NAME (msymbol), - namespace, objfile, s, wild_match); + namespace, objfile, wild_match); if (num_defns_collected (&symbol_list_obstack) == ndefns0) { block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK); ada_add_block_symbols (&symbol_list_obstack, block, SYMBOL_LINKAGE_NAME (msymbol), - namespace, objfile, s, + namespace, objfile, wild_match); } } @@ -4815,7 +4791,7 @@ ada_lookup_symbol_list (const char *name0, const struct block *block0, bv = BLOCKVECTOR (s); block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK); ada_add_block_symbols (&symbol_list_obstack, block, name, - namespace, objfile, s, wild_match); + namespace, objfile, wild_match); } } @@ -4832,7 +4808,7 @@ ada_lookup_symbol_list (const char *name0, const struct block *block0, bv = BLOCKVECTOR (s); block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK); ada_add_block_symbols (&symbol_list_obstack, block, name, namespace, - objfile, s, wild_match); + objfile, wild_match); } ALL_PSYMTABS (objfile, ps) @@ -4847,7 +4823,7 @@ ada_lookup_symbol_list (const char *name0, const struct block *block0, continue; block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK); ada_add_block_symbols (&symbol_list_obstack, block, name, - namespace, objfile, s, wild_match); + namespace, objfile, wild_match); } } } @@ -4859,11 +4835,10 @@ done: ndefns = remove_extra_symbols (*results, ndefns); if (ndefns == 0) - cache_symbol (name0, namespace, NULL, NULL, NULL); + cache_symbol (name0, namespace, NULL, NULL); if (ndefns == 1 && cacheIfUnique) - cache_symbol (name0, namespace, (*results)[0].sym, (*results)[0].block, - (*results)[0].symtab); + cache_symbol (name0, namespace, (*results)[0].sym, (*results)[0].block); ndefns = remove_irrelevant_renamings (*results, ndefns, block0); @@ -5205,7 +5180,7 @@ static void ada_add_block_symbols (struct obstack *obstackp, struct block *block, const char *name, domain_enum domain, struct objfile *objfile, - struct symtab *symtab, int wild) + int wild) { struct dict_iterator iter; int name_len = strlen (name); @@ -5226,25 +5201,16 @@ ada_add_block_symbols (struct obstack *obstackp, SYMBOL_DOMAIN (sym), domain) && wild_match (name, name_len, SYMBOL_LINKAGE_NAME (sym))) { - switch (SYMBOL_CLASS (sym)) - { - case LOC_ARG: - case LOC_LOCAL_ARG: - case LOC_REF_ARG: - case LOC_REGPARM: - case LOC_REGPARM_ADDR: - case LOC_BASEREG_ARG: - case LOC_COMPUTED_ARG: - arg_sym = sym; - break; - case LOC_UNRESOLVED: - continue; - default: + if (SYMBOL_CLASS (sym) == LOC_UNRESOLVED) + continue; + else if (SYMBOL_IS_ARGUMENT (sym)) + arg_sym = sym; + else + { found_sym = 1; add_defn_to_vec (obstackp, fixup_symbol_section (sym, objfile), - block, symtab); - break; + block); } } } @@ -5260,26 +5226,18 @@ ada_add_block_symbols (struct obstack *obstackp, if (cmp == 0 && is_name_suffix (SYMBOL_LINKAGE_NAME (sym) + name_len)) { - switch (SYMBOL_CLASS (sym)) - { - case LOC_ARG: - case LOC_LOCAL_ARG: - case LOC_REF_ARG: - case LOC_REGPARM: - case LOC_REGPARM_ADDR: - case LOC_BASEREG_ARG: - case LOC_COMPUTED_ARG: - arg_sym = sym; - break; - case LOC_UNRESOLVED: - break; - default: - found_sym = 1; - add_defn_to_vec (obstackp, - fixup_symbol_section (sym, objfile), - block, symtab); - break; - } + if (SYMBOL_CLASS (sym) != LOC_UNRESOLVED) + { + if (SYMBOL_IS_ARGUMENT (sym)) + arg_sym = sym; + else + { + found_sym = 1; + add_defn_to_vec (obstackp, + fixup_symbol_section (sym, objfile), + block); + } + } } } } @@ -5289,7 +5247,7 @@ ada_add_block_symbols (struct obstack *obstackp, { add_defn_to_vec (obstackp, fixup_symbol_section (arg_sym, objfile), - block, symtab); + block); } if (!wild) @@ -5316,26 +5274,18 @@ ada_add_block_symbols (struct obstack *obstackp, if (cmp == 0 && is_name_suffix (SYMBOL_LINKAGE_NAME (sym) + name_len + 5)) { - switch (SYMBOL_CLASS (sym)) - { - case LOC_ARG: - case LOC_LOCAL_ARG: - case LOC_REF_ARG: - case LOC_REGPARM: - case LOC_REGPARM_ADDR: - case LOC_BASEREG_ARG: - case LOC_COMPUTED_ARG: - arg_sym = sym; - break; - case LOC_UNRESOLVED: - break; - default: - found_sym = 1; - add_defn_to_vec (obstackp, - fixup_symbol_section (sym, objfile), - block, symtab); - break; - } + if (SYMBOL_CLASS (sym) != LOC_UNRESOLVED) + { + if (SYMBOL_IS_ARGUMENT (sym)) + arg_sym = sym; + else + { + found_sym = 1; + add_defn_to_vec (obstackp, + fixup_symbol_section (sym, objfile), + block); + } + } } } } @@ -5346,7 +5296,7 @@ ada_add_block_symbols (struct obstack *obstackp, { add_defn_to_vec (obstackp, fixup_symbol_section (arg_sym, objfile), - block, symtab); + block); } } } @@ -6761,7 +6711,7 @@ ada_find_renaming_symbol (const char *name, struct block *block) static struct symbol * find_old_style_renaming_symbol (const char *name, struct block *block) { - const struct symbol *function_sym = block_function (block); + const struct symbol *function_sym = block_linkage_function (block); char *rename; if (function_sym != NULL) @@ -6941,7 +6891,6 @@ empty_record (struct objfile *objfile) TYPE_FIELDS (type) = NULL; TYPE_NAME (type) = ""; TYPE_TAG_NAME (type) = NULL; - TYPE_FLAGS (type) = 0; TYPE_LENGTH (type) = 0; return type; } @@ -7001,7 +6950,7 @@ ada_template_to_fixed_record_type_1 (struct type *type, memset (TYPE_FIELDS (rtype), 0, sizeof (struct field) * nfields); TYPE_NAME (rtype) = ada_type_name (type); TYPE_TAG_NAME (rtype) = NULL; - TYPE_FLAGS (rtype) |= TYPE_FLAG_FIXED_INSTANCE; + TYPE_FIXED_INSTANCE (rtype) = 1; off = 0; bit_len = 0; @@ -7181,7 +7130,7 @@ template_to_static_fixed_type (struct type *type0) sizeof (struct field) * nfields); TYPE_NAME (type) = ada_type_name (type0); TYPE_TAG_NAME (type) = NULL; - TYPE_FLAGS (type) |= TYPE_FLAG_FIXED_INSTANCE; + TYPE_FIXED_INSTANCE (type) = 1; TYPE_LENGTH (type) = 0; } TYPE_FIELD_TYPE (type, f) = new_type; @@ -7226,7 +7175,7 @@ to_record_with_fixed_variant_part (struct type *type, const gdb_byte *valaddr, sizeof (struct field) * nfields); TYPE_NAME (rtype) = ada_type_name (type); TYPE_TAG_NAME (rtype) = NULL; - TYPE_FLAGS (rtype) |= TYPE_FLAG_FIXED_INSTANCE; + TYPE_FIXED_INSTANCE (rtype) = 1; TYPE_LENGTH (rtype) = TYPE_LENGTH (type); branch_type = to_fixed_variant_branch_type @@ -7281,7 +7230,7 @@ to_fixed_record_type (struct type *type0, const gdb_byte *valaddr, { struct type *templ_type; - if (TYPE_FLAGS (type0) & TYPE_FLAG_FIXED_INSTANCE) + if (TYPE_FIXED_INSTANCE (type0)) return type0; templ_type = dynamic_template_type (type0); @@ -7297,7 +7246,7 @@ to_fixed_record_type (struct type *type0, const gdb_byte *valaddr, } else { - TYPE_FLAGS (type0) |= TYPE_FLAG_FIXED_INSTANCE; + TYPE_FIXED_INSTANCE (type0) = 1; return type0; } @@ -7362,7 +7311,7 @@ to_fixed_array_type (struct type *type0, struct value *dval, struct type *result; if (ada_is_packed_array_type (type0) /* revisit? */ - || (TYPE_FLAGS (type0) & TYPE_FLAG_FIXED_INSTANCE)) + || TYPE_FIXED_INSTANCE (type0)) return type0; index_type_desc = ada_find_parallel_type (type0, "___XA"); @@ -7422,7 +7371,7 @@ to_fixed_array_type (struct type *type0, struct value *dval, error (_("array type with dynamic size is larger than varsize-limit")); } - TYPE_FLAGS (result) |= TYPE_FLAG_FIXED_INSTANCE; + TYPE_FIXED_INSTANCE (result) = 1; return result; } @@ -7512,7 +7461,7 @@ to_static_fixed_type (struct type *type0) if (type0 == NULL) return NULL; - if (TYPE_FLAGS (type0) & TYPE_FLAG_FIXED_INSTANCE) + if (TYPE_FIXED_INSTANCE (type0)) return type0; type0 = ada_check_typedef (type0); @@ -7674,7 +7623,8 @@ ada_attribute_name (enum exp_opcode n) static LONGEST pos_atr (struct value *arg) { - struct type *type = value_type (arg); + struct value *val = coerce_ref (arg); + struct type *type = value_type (val); if (!discrete_type_p (type)) error (_("'POS only defined on discrete types")); @@ -7682,7 +7632,7 @@ pos_atr (struct value *arg) if (TYPE_CODE (type) == TYPE_CODE_ENUM) { int i; - LONGEST v = value_as_long (arg); + LONGEST v = value_as_long (val); for (i = 0; i < TYPE_NFIELDS (type); i += 1) { @@ -7692,7 +7642,7 @@ pos_atr (struct value *arg) error (_("enumeration value is invalid: can't find 'POS")); } else - return value_as_long (arg); + return value_as_long (val); } static struct value * @@ -9016,9 +8966,11 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp, default: error (_("unexpected attribute encountered")); case OP_ATR_FIRST: - return discrete_type_low_bound (range_type); + return value_from_longest + (range_type, discrete_type_low_bound (range_type)); case OP_ATR_LAST: - return discrete_type_high_bound (range_type); + return value_from_longest + (range_type, discrete_type_high_bound (range_type)); case OP_ATR_LENGTH: error (_("the 'length attribute applies only to array types")); } @@ -9539,7 +9491,16 @@ to_fixed_range_type (char *name, struct value *dval, struct objfile *objfile) subtype_info = strstr (name, "___XD"); if (subtype_info == NULL) - return raw_type; + { + LONGEST L = discrete_type_low_bound (raw_type); + LONGEST U = discrete_type_high_bound (raw_type); + if (L < INT_MIN || U > INT_MAX) + return raw_type; + else + return create_range_type (alloc_type (objfile), raw_type, + discrete_type_low_bound (raw_type), + discrete_type_high_bound (raw_type)); + } else { static char *name_buf = NULL; @@ -9626,7 +9587,7 @@ ada_is_modular_type (struct type *type) struct type *subranged_type = base_type (type); return (subranged_type != NULL && TYPE_CODE (type) == TYPE_CODE_RANGE - && TYPE_CODE (subranged_type) != TYPE_CODE_ENUM + && TYPE_CODE (subranged_type) == TYPE_CODE_INT && TYPE_UNSIGNED (subranged_type)); } @@ -9809,7 +9770,7 @@ ada_exception_support_info_sniffer (void) each time a new executable is loaded by GDB. */ static void -ada_executable_changed_observer (void *unused) +ada_executable_changed_observer (void) { /* If the executable changed, then it is possible that the Ada runtime is different. So we need to invalidate the exception support info