diff options
author | Michael Snyder <msnyder@vmware.com> | 2010-05-17 18:48:52 +0000 |
---|---|---|
committer | Michael Snyder <msnyder@vmware.com> | 2010-05-17 18:48:52 +0000 |
commit | a109c7c1042127edfe32cbc50f315c3dc40f8607 (patch) | |
tree | 0322616410678495af3fd4898e49a5b3116fda2c /gdb | |
parent | 0cce5bd9dd8b740485b4ce847a0bd09a23097076 (diff) | |
download | gdb-a109c7c1042127edfe32cbc50f315c3dc40f8607.zip gdb-a109c7c1042127edfe32cbc50f315c3dc40f8607.tar.gz gdb-a109c7c1042127edfe32cbc50f315c3dc40f8607.tar.bz2 |
2010-05-17 Michael Snyder <msnyder@vmware.com>
* valarith.c: White space.
* valops.c: White space.
* valprint.c: White space.
* value.c: White space.
* varobj.c: White space.
* xcoffread.c: White space.
* xml-support.c: White space.
* xml-tdesc.c: White space.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 11 | ||||
-rw-r--r-- | gdb/valarith.c | 18 | ||||
-rw-r--r-- | gdb/valops.c | 41 | ||||
-rw-r--r-- | gdb/valprint.c | 2 | ||||
-rw-r--r-- | gdb/value.c | 25 | ||||
-rw-r--r-- | gdb/varobj.c | 45 | ||||
-rw-r--r-- | gdb/xcoffread.c | 67 | ||||
-rw-r--r-- | gdb/xml-support.c | 3 | ||||
-rw-r--r-- | gdb/xml-tdesc.c | 1 |
9 files changed, 168 insertions, 45 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index de8f3bd..1c1cb81 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,14 @@ +2010-05-17 Michael Snyder <msnyder@vmware.com> + + * valarith.c: White space. + * valops.c: White space. + * valprint.c: White space. + * value.c: White space. + * varobj.c: White space. + * xcoffread.c: White space. + * xml-support.c: White space. + * xml-tdesc.c: White space. + 2010-05-17 Andreas Schwab <schwab@redhat.com> PR gdb/11092 diff --git a/gdb/valarith.c b/gdb/valarith.c index 4efe936..745d960 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -157,8 +157,8 @@ value_subscript (struct value *array, LONGEST index) { struct type *range_type = TYPE_INDEX_TYPE (tarray); LONGEST lowerbound, upperbound; - get_discrete_bounds (range_type, &lowerbound, &upperbound); + get_discrete_bounds (range_type, &lowerbound, &upperbound); if (VALUE_LVAL (array) != lval_memory) return value_subscripted_rvalue (array, index, lowerbound); @@ -304,6 +304,7 @@ int unop_user_defined_p (enum exp_opcode op, struct value *arg1) { struct type *type1; + if (op == UNOP_ADDR) return 0; type1 = check_typedef (value_type (arg1)); @@ -470,6 +471,7 @@ value_x_binop (struct value *arg1, struct value *arg2, enum exp_opcode op, if (noside == EVAL_AVOID_SIDE_EFFECTS) { struct type *return_type; + return_type = TYPE_TARGET_TYPE (check_typedef (value_type (argvec[0]))); return value_zero (return_type, VALUE_LVAL (arg1)); @@ -568,6 +570,7 @@ value_x_unop (struct value *arg1, enum exp_opcode op, enum noside noside) if (noside == EVAL_AVOID_SIDE_EFFECTS) { struct type *return_type; + return_type = TYPE_TARGET_TYPE (check_typedef (value_type (argvec[0]))); return value_zero (return_type, VALUE_LVAL (arg1)); @@ -623,6 +626,7 @@ value_concat (struct value *arg1, struct value *arg2) if (TYPE_CODE (type2) == TYPE_CODE_INT) { struct type *tmp = type1; + type1 = tmp; tmp = type2; inval1 = arg2; @@ -649,6 +653,7 @@ value_concat (struct value *arg1, struct value *arg2) if (TYPE_CODE (type2) == TYPE_CODE_CHAR) { char_type = type2; + inchar = (char) unpack_long (type2, value_contents (inval2)); for (idx = 0; idx < count; idx++) @@ -659,6 +664,7 @@ value_concat (struct value *arg1, struct value *arg2) else { char_type = TYPE_TARGET_TYPE (type2); + for (idx = 0; idx < count; idx++) { memcpy (ptr + (idx * inval2len), value_contents (inval2), @@ -692,11 +698,13 @@ value_concat (struct value *arg1, struct value *arg2) if (TYPE_CODE (type1) == TYPE_CODE_CHAR) { char_type = type1; + *ptr = (char) unpack_long (type1, value_contents (inval1)); } else { char_type = TYPE_TARGET_TYPE (type1); + memcpy (ptr, value_contents (inval1), inval1len); } if (TYPE_CODE (type2) == TYPE_CODE_CHAR) @@ -927,6 +935,7 @@ value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) in target format. real.c in GCC probably has the necessary code. */ DOUBLEST v1, v2, v = 0; + v1 = value_as_double (arg1); v2 = value_as_double (arg2); @@ -985,6 +994,7 @@ value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) || TYPE_CODE (type2) == TYPE_CODE_BOOL) { LONGEST v1, v2, v = 0; + v1 = value_as_long (arg1); v2 = value_as_long (arg2); @@ -1048,6 +1058,7 @@ value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) { LONGEST v2_signed = value_as_long (arg2); ULONGEST v1, v2, v = 0; + v1 = (ULONGEST) value_as_long (arg1); v2 = (ULONGEST) v2_signed; @@ -1173,6 +1184,7 @@ value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) else { LONGEST v1, v2, v = 0; + v1 = value_as_long (arg1); v2 = value_as_long (arg2); @@ -1397,6 +1409,7 @@ value_equal (struct value *arg1, struct value *arg2) /* NOTE: kettenis/20050816: Avoid compiler bug on systems where `long double' values are returned in static storage (m68k). */ DOUBLEST d = value_as_double (arg1); + return d == value_as_double (arg2); } else if ((code1 == TYPE_CODE_DECFLOAT || is_int1) @@ -1492,6 +1505,7 @@ value_less (struct value *arg1, struct value *arg2) /* NOTE: kettenis/20050816: Avoid compiler bug on systems where `long double' values are returned in static storage (m68k). */ DOUBLEST d = value_as_double (arg1); + return d < value_as_double (arg2); } else if ((code1 == TYPE_CODE_DECFLOAT || is_int1) @@ -1613,6 +1627,7 @@ value_bit_index (struct type *type, const gdb_byte *valaddr, int index) LONGEST word; unsigned rel_index; struct type *range = TYPE_INDEX_TYPE (type); + if (get_discrete_bounds (range, &low_bound, &high_bound) < 0) return -2; if (index < low_bound || index > high_bound) @@ -1632,6 +1647,7 @@ value_in (struct value *element, struct value *set) int member; struct type *settype = check_typedef (value_type (set)); struct type *eltype = check_typedef (value_type (element)); + if (TYPE_CODE (eltype) == TYPE_CODE_RANGE) eltype = TYPE_TARGET_TYPE (eltype); if (TYPE_CODE (settype) != TYPE_CODE_SET) diff --git a/gdb/valops.c b/gdb/valops.c index 6f5f684..6cd66dd 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -134,6 +134,7 @@ struct value * find_function_in_inferior (const char *name, struct objfile **objf_p) { struct symbol *sym; + sym = lookup_symbol (name, 0, VAR_DOMAIN, 0); if (sym != NULL) { @@ -152,6 +153,7 @@ find_function_in_inferior (const char *name, struct objfile **objf_p) { struct minimal_symbol *msymbol = lookup_minimal_symbol (name, NULL, NULL); + if (msymbol != NULL) { struct objfile *objfile = msymbol_objfile (msymbol); @@ -285,6 +287,7 @@ value_cast_structs (struct type *type, struct value *v2) { /* Downcasting is possible (t1 is superclass of v2). */ CORE_ADDR addr2 = value_address (v2); + addr2 -= value_address (v) + value_embedded_offset (v); return value_at (type, addr2); } @@ -322,6 +325,7 @@ value_cast_pointers (struct type *type, struct value *arg2) if (v2) { struct value *v = value_addr (v2); + deprecated_set_value_type (v, type); return v; } @@ -364,6 +368,7 @@ value_cast (struct type *type, struct value *arg2) struct type *t1 = check_typedef (type); struct type *dereftype = check_typedef (TYPE_TARGET_TYPE (t1)); struct value *val = value_cast (dereftype, arg2); + return value_ref (val); } @@ -389,11 +394,13 @@ value_cast (struct type *type, struct value *arg2) { struct type *element_type = TYPE_TARGET_TYPE (type); unsigned element_length = TYPE_LENGTH (check_typedef (element_type)); + if (element_length > 0 && TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type)) { struct type *range_type = TYPE_INDEX_TYPE (type); int val_length = TYPE_LENGTH (type2); LONGEST low_bound, high_bound, new_length; + if (get_discrete_bounds (range_type, &low_bound, &high_bound) < 0) low_bound = 0, high_bound = 0; new_length = val_length / element_length; @@ -444,6 +451,7 @@ value_cast (struct type *type, struct value *arg2) && TYPE_NAME (type) != 0) { struct value *v = value_cast_structs (type, arg2); + if (v) return v; } @@ -504,8 +512,8 @@ value_cast (struct type *type, struct value *arg2) pointers and four byte addresses. */ int addr_bit = gdbarch_addr_bit (get_type_arch (type2)); - LONGEST longest = value_as_long (arg2); + if (addr_bit < sizeof (LONGEST) * HOST_CHAR_BIT) { if (longest >= ((LONGEST) 1 << addr_bit) @@ -518,6 +526,7 @@ value_cast (struct type *type, struct value *arg2) && value_as_long (arg2) == 0) { struct value *result = allocate_value (type); + cplus_make_method_ptr (type, value_contents_writeable (result), 0, 0); return result; } @@ -625,6 +634,7 @@ dynamic_cast_check_1 (struct type *desired_type, for (i = 0; i < TYPE_N_BASECLASSES (search_type) && result_count < 2; ++i) { int offset = baseclass_offset (search_type, i, contents, address); + if (offset == -1) error (_("virtual baseclass botch")); if (class_types_same_p (desired_type, TYPE_BASECLASS (search_type, i))) @@ -810,8 +820,8 @@ struct value * value_zero (struct type *type, enum lval_type lv) { struct value *val = allocate_value (type); - VALUE_LVAL (val) = lv; + VALUE_LVAL (val) = lv; return val; } @@ -827,6 +837,7 @@ value_one (struct type *type, enum lval_type lv) { enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type)); gdb_byte v[16]; + decimal_from_string (v, TYPE_LENGTH (type), byte_order, "1"); val = value_from_decfloat (type, v); } @@ -934,6 +945,7 @@ value_fetch_lazy (struct value *val) value_bitpos (val), value_bitsize (val)); int length = TYPE_LENGTH (type); + store_signed_integer (value_contents_raw (val), length, byte_order, num); } else if (VALUE_LVAL (val) == lval_memory) @@ -1110,8 +1122,8 @@ value_assign (struct value *toval, struct value *fromval) if (value_bitsize (toval)) { struct value *parent = value_parent (toval); - changed_addr = value_address (parent) + value_offset (toval); + changed_addr = value_address (parent) + value_offset (toval); changed_len = (value_bitpos (toval) + value_bitsize (toval) + HOST_CHAR_BIT - 1) @@ -1248,6 +1260,7 @@ value_assign (struct value *toval, struct value *fromval) { struct frame_info *fi = frame_find_by_id (old_frame); + if (fi != NULL) select_frame (fi); } @@ -1355,6 +1368,7 @@ address_of_variable (struct symbol *var, struct block *b) || TYPE_CODE (type) == TYPE_CODE_FUNC) { CORE_ADDR addr = value_address (val); + return value_from_pointer (lookup_pointer_type (type), addr); } @@ -1496,8 +1510,8 @@ struct value * value_addr (struct value *arg1) { struct value *arg2; - struct type *type = check_typedef (value_type (arg1)); + if (TYPE_CODE (type) == TYPE_CODE_REF) { /* Copy the value, but change the type from (T&) to (T*). We @@ -1539,8 +1553,8 @@ struct value * value_ref (struct value *arg1) { struct value *arg2; - struct type *type = check_typedef (value_type (arg1)); + if (TYPE_CODE (type) == TYPE_CODE_REF) return arg1; @@ -1565,6 +1579,7 @@ value_ind (struct value *arg1) if (TYPE_CODE (base_type) == TYPE_CODE_PTR) { struct type *enc_type; + /* We may be pointing to something embedded in a larger object. Get the real type of the enclosing object. */ enc_type = check_typedef (value_enclosing_type (arg1)); @@ -1704,6 +1719,7 @@ value_bitstring (char *ptr, int len, struct type *index_type) struct type *domain_type = create_range_type (NULL, index_type, 0, len - 1); struct type *type = create_set_type (NULL, domain_type); + TYPE_CODE (type) = TYPE_CODE_BITSTRING; val = allocate_value (type); memcpy (value_contents_raw (val), ptr, TYPE_LENGTH (type)); @@ -1824,6 +1840,7 @@ search_struct_field (const char *name, struct value *arg1, int offset, if (t_field_name && (strcmp_iw (t_field_name, name) == 0)) { struct value *v; + if (field_is_static (&TYPE_FIELD (type, i))) { v = value_static_field (type, i); @@ -1846,6 +1863,7 @@ search_struct_field (const char *name, struct value *arg1, int offset, && (strcmp_iw (t_field_name, "else") == 0)))) { struct type *field_type = TYPE_FIELD_TYPE (type, i); + if (TYPE_CODE (field_type) == TYPE_CODE_UNION || TYPE_CODE (field_type) == TYPE_CODE_STRUCT) { @@ -1977,6 +1995,7 @@ search_struct_method (const char *name, struct value **arg1p, for (i = TYPE_NFN_FIELDS (type) - 1; i >= 0; i--) { char *t_field_name = TYPE_FN_FIELDLIST_NAME (type, i); + /* FIXME! May need to check for ARM demangling here */ if (strncmp (t_field_name, "__", 2) == 0 || strncmp (t_field_name, "op", 2) == 0 || @@ -1991,8 +2010,8 @@ search_struct_method (const char *name, struct value **arg1p, { int j = TYPE_FN_FIELDLIST_LENGTH (type, i) - 1; struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i); - name_matched = 1; + name_matched = 1; check_stub_method_group (type, i); if (j > 0 && args == 0) error (_("cannot resolve overloaded method `%s': no arguments supplied"), name); @@ -2041,6 +2060,7 @@ search_struct_method (const char *name, struct value **arg1p, if (offset < 0 || offset >= TYPE_LENGTH (type)) { gdb_byte *tmp = alloca (TYPE_LENGTH (baseclass)); + if (target_read_memory (value_address (*arg1p) + offset, tmp, TYPE_LENGTH (baseclass)) != 0) error (_("virtual baseclass botch")); @@ -2204,6 +2224,7 @@ find_method_list (struct value **argp, const char *method, { /* pai: FIXME What about operators and type conversions? */ char *fn_field_name = TYPE_FN_FIELDLIST_NAME (type, i); + if (fn_field_name && (strcmp_iw (fn_field_name, method) == 0)) { int len = TYPE_FN_FIELDLIST_LENGTH (type, i); @@ -2224,6 +2245,7 @@ find_method_list (struct value **argp, const char *method, for (i = TYPE_N_BASECLASSES (type) - 1; i >= 0; i--) { int base_offset; + if (BASETYPE_VIA_VIRTUAL (type, i)) { base_offset = value_offset (*argp) + offset; @@ -2496,6 +2518,7 @@ find_overload_match (struct type **arg_types, int nargs, { struct type *temp_type = check_typedef (value_type (temp)); struct type *obj_type = check_typedef (value_type (*objp)); + if (TYPE_CODE (temp_type) != TYPE_CODE_PTR && (TYPE_CODE (obj_type) == TYPE_CODE_PTR || TYPE_CODE (obj_type) == TYPE_CODE_REF)) @@ -2845,6 +2868,7 @@ check_field (struct type *type, const char *name) for (i = TYPE_NFIELDS (type) - 1; i >= TYPE_N_BASECLASSES (type); i--) { char *t_field_name = TYPE_FIELD_NAME (type, i); + if (t_field_name && (strcmp_iw (t_field_name, name) == 0)) return 1; } @@ -2929,6 +2953,7 @@ compare_parameters (struct type *t1, struct type *t2, int skip_artificial) if ((TYPE_NFIELDS (t1) - start) == TYPE_NFIELDS (t2)) { int i; + for (i = 0; i < TYPE_NFIELDS (t2); ++i) { if (rank_one_type (TYPE_FIELD_TYPE (t1, start + i), @@ -3068,6 +3093,7 @@ value_struct_elt_for_reference (struct type *domain, int offset, struct symbol *s = lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, j), 0, VAR_DOMAIN, 0); + if (s == NULL) return NULL; @@ -3098,6 +3124,7 @@ value_struct_elt_for_reference (struct type *domain, int offset, struct symbol *s = lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, j), 0, VAR_DOMAIN, 0); + if (s == NULL) return NULL; @@ -3393,11 +3420,13 @@ value_slice (struct value *array, int lowbound, int length) int element = value_bit_index (array_type, value_contents (array), lowbound + i); + if (element < 0) error (_("internal error accessing bitstring")); else if (element > 0) { int j = i % TARGET_CHAR_BIT; + if (gdbarch_bits_big_endian (get_type_arch (array_type))) j = TARGET_CHAR_BIT - 1 - j; value_contents_raw (slice)[i / TARGET_CHAR_BIT] |= (1 << j); diff --git a/gdb/valprint.c b/gdb/valprint.c index de1161d..517e607 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -395,6 +395,7 @@ value_print (struct value *val, struct ui_file *stream, value_address (val), stream, 0, options, current_language); + if (r) return r; } @@ -1141,6 +1142,7 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr, else { long low, hi; + if (get_array_bounds (type, &low, &hi)) len = hi - low + 1; else diff --git a/gdb/value.c b/gdb/value.c index 2f1ae7a..ec33403 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -304,6 +304,7 @@ struct value * allocate_value (struct type *type) { struct value *val = allocate_value_lazy (type); + allocate_value_contents (val); val->lazy = 0; return val; @@ -320,6 +321,7 @@ allocate_repeat_value (struct type *type, int count) done with it. */ struct type *array_type = lookup_array_range_type (type, low_bound, count + low_bound - 1); + return allocate_value (array_type); } @@ -329,6 +331,7 @@ allocate_computed_value (struct type *type, void *closure) { struct value *v = allocate_value (type); + VALUE_LVAL (v) = lval_computed; v->location.computed.funcs = funcs; v->location.computed.closure = closure; @@ -817,7 +820,8 @@ record_latest_value (struct value *val) if (i == 0) { struct value_history_chunk *new - = (struct value_history_chunk *) + = (struct value_history_chunk *) + xmalloc (sizeof (struct value_history_chunk)); memset (new->values, 0, sizeof new->values); new->next = value_history_chain; @@ -894,6 +898,7 @@ show_values (char *num_exp, int from_tty) for (i = num; i < num + 10 && i <= value_history_count; i++) { struct value_print_options opts; + val = access_value_history (i); printf_filtered (("$%d = "), i); get_user_print_options (&opts); @@ -1054,6 +1059,7 @@ struct internalvar * create_internalvar (const char *name) { struct internalvar *var; + var = (struct internalvar *) xmalloc (sizeof (struct internalvar)); var->name = concat (name, (char *)NULL); var->kind = INTERNALVAR_VOID; @@ -1071,6 +1077,7 @@ struct internalvar * create_internalvar_type_lazy (char *name, internalvar_make_value fun) { struct internalvar *var = create_internalvar (name); + var->kind = INTERNALVAR_MAKE_VALUE; var->u.make_value = fun; return var; @@ -1354,6 +1361,7 @@ create_internal_function (const char *name, internal_function_fn handler, void *cookie) { struct internal_function *ifn = XNEW (struct internal_function); + ifn->name = xstrdup (name); ifn->handler = handler; ifn->cookie = cookie; @@ -1818,14 +1826,16 @@ value_static_field (struct type *type, int fieldno) else { char *phys_name = TYPE_FIELD_STATIC_PHYSNAME (type, fieldno); - /*TYPE_FIELD_NAME (type, fieldno);*/ + /*TYPE_FIELD_NAME (type, fieldno);*/ struct symbol *sym = lookup_symbol (phys_name, 0, VAR_DOMAIN, 0); if (sym == NULL) { - /* With some compilers, e.g. HP aCC, static data members are reported - as non-debuggable symbols */ - struct minimal_symbol *msym = lookup_minimal_symbol (phys_name, NULL, NULL); + /* With some compilers, e.g. HP aCC, static data members are + reported as non-debuggable symbols */ + struct minimal_symbol *msym = lookup_minimal_symbol (phys_name, + NULL, NULL); + if (!msym) return NULL; else @@ -2201,7 +2211,6 @@ value_from_longest (struct type *type, LONGEST num) struct value *val = allocate_value (type); pack_long (value_contents_raw (val), type, num); - return val; } @@ -2212,6 +2221,7 @@ struct value * value_from_pointer (struct type *type, CORE_ADDR addr) { struct value *val = allocate_value (type); + store_typed_address (value_contents_raw (val), check_typedef (type), addr); return val; } @@ -2227,6 +2237,7 @@ value_from_contents_and_address (struct type *type, CORE_ADDR address) { struct value *v = allocate_value (type); + if (valaddr == NULL) set_value_lazy (v, 1); else @@ -2259,7 +2270,6 @@ value_from_decfloat (struct type *type, const gdb_byte *dec) struct value *val = allocate_value (type); memcpy (value_contents_raw (val), dec, TYPE_LENGTH (type)); - return val; } @@ -2267,6 +2277,7 @@ struct value * coerce_ref (struct value *arg) { struct type *value_type_arg_tmp = check_typedef (value_type (arg)); + if (TYPE_CODE (value_type_arg_tmp) == TYPE_CODE_REF) arg = value_at_lazy (TYPE_TARGET_TYPE (value_type_arg_tmp), unpack_pointer (value_type (arg), diff --git a/gdb/varobj.c b/gdb/varobj.c index a6e9df3..b9b8e91b 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -512,6 +512,7 @@ find_frame_addr_in_frame_chain (CORE_ADDR frame_addr) comparing it against our argument. */ CORE_ADDR frame_base = get_frame_base_address (frame); int addr_bit = gdbarch_addr_bit (get_frame_arch (frame)); + if (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT)) frame_base &= ((CORE_ADDR) 1 << addr_bit) - 1; @@ -622,6 +623,7 @@ varobj_create (char *objname, /* Error getting the value. Try to at least get the right type. */ struct value *type_only_value = evaluate_type (var->root->exp); + var->type = value_type (type_only_value); } else @@ -924,6 +926,7 @@ install_dynamic_child (struct varobj *var, { /* There's no child yet. */ struct varobj *child = varobj_add_child (var, name, value); + if (new) { VEC_safe_push (varobj_p, *new, child); @@ -933,6 +936,7 @@ install_dynamic_child (struct varobj *var, else { varobj_p existing = VEC_index (varobj_p, var->children, index); + if (install_new_value (existing, value, 0)) { if (changed) @@ -1068,6 +1072,7 @@ update_dynamic_varobj_children (struct varobj *var, if (i < VEC_length (varobj_p, var->children)) { int j; + *cchanged = 1; for (j = i; j < VEC_length (varobj_p, var->children); ++j) varobj_delete (VEC_index (varobj_p, var->children, j), NULL, 0); @@ -1171,6 +1176,7 @@ varobj_add_child (struct varobj *var, const char *name, struct value *value) varobj_p v = create_child_with_value (var, VEC_length (varobj_p, var->children), name, value); + VEC_safe_push (varobj_p, var->children, v); return v; } @@ -1486,6 +1492,7 @@ install_new_value (struct varobj *var, struct value *value, int initial) { struct varobj *parent = var->parent; int frozen = var->frozen; + for (; !frozen && parent; parent = parent->parent) frozen |= parent->frozen; @@ -1694,6 +1701,7 @@ VEC(varobj_update_result) *varobj_update (struct varobj **varp, int explicit) if (!(*varp)->root->is_valid) { varobj_update_result r = {0}; + r.varobj = *varp; r.status = VAROBJ_INVALID; VEC_safe_push (varobj_update_result, result, &r); @@ -1703,6 +1711,7 @@ VEC(varobj_update_result) *varobj_update (struct varobj **varp, int explicit) if ((*varp)->root->rootvar == *varp) { varobj_update_result r = {0}; + r.varobj = *varp; r.status = VAROBJ_IN_SCOPE; @@ -1734,6 +1743,7 @@ VEC(varobj_update_result) *varobj_update (struct varobj **varp, int explicit) else { varobj_update_result r = {0}; + r.varobj = *varp; VEC_safe_push (varobj_update_result, stack, &r); } @@ -1812,6 +1822,7 @@ VEC(varobj_update_result) *varobj_update (struct varobj **varp, int explicit) { varobj_p tmp = VEC_index (varobj_p, changed, i); varobj_update_result r = {0}; + r.varobj = tmp; r.changed = 1; r.value_installed = 1; @@ -1820,9 +1831,11 @@ VEC(varobj_update_result) *varobj_update (struct varobj **varp, int explicit) for (i = VEC_length (varobj_p, unchanged) - 1; i >= 0; --i) { varobj_p tmp = VEC_index (varobj_p, unchanged, i); + if (!tmp->frozen) { varobj_update_result r = {0}; + r.varobj = tmp; r.value_installed = 1; VEC_safe_push (varobj_update_result, stack, &r); @@ -1847,10 +1860,12 @@ VEC(varobj_update_result) *varobj_update (struct varobj **varp, int explicit) for (i = VEC_length (varobj_p, v->children)-1; i >= 0; --i) { varobj_p c = VEC_index (varobj_p, v->children, i); + /* Child may be NULL if explicitly deleted by -var-delete. */ if (c != NULL && !c->frozen) { varobj_update_result r = {0}; + r.varobj = c; VEC_safe_push (varobj_update_result, stack, &r); } @@ -1899,6 +1914,7 @@ delete_variable_1 (struct cpstack **resultp, int *delcountp, for (i = 0; i < VEC_length (varobj_p, var->children); ++i) { varobj_p child = VEC_index (varobj_p, var->children, i); + if (!child) continue; if (!remove_from_parent_p) @@ -2139,6 +2155,7 @@ static struct varobj * new_root_variable (void) { struct varobj *var = new_variable (); + var->root = (struct varobj_root *) xmalloc (sizeof (struct varobj_root));; var->root->lang = NULL; var->root->exp = NULL; @@ -2204,8 +2221,8 @@ static struct type * get_type (struct varobj *var) { struct type *type; - type = var->type; + type = var->type; if (type != NULL) type = check_typedef (type); @@ -2400,6 +2417,7 @@ value_of_root (struct varobj **var_handle, int *type_changed) correct in other frames, so update the expression. */ struct expression *tmp_exp = var->root->exp; + var->root->exp = tmp_var->root->exp; tmp_var->root->exp = tmp_exp; @@ -2512,9 +2530,11 @@ value_get_print_value (struct value *value, enum varobj_display_formats format, { PyObject *py_str = python_string_to_target_python_string (output); + if (py_str) { char *s = PyString_AsString (py_str); + len = PyString_Size (py_str); thevalue = xmemdup (s, len + 1, len + 1); type = builtin_type (gdbarch)->builtin_char; @@ -2671,7 +2691,8 @@ adjust_value_for_child_access (struct value **value, { if (value && *value) { - int success = gdb_value_ind (*value, value); + int success = gdb_value_ind (*value, value); + if (!success) *value = NULL; } @@ -2754,8 +2775,8 @@ value_struct_element_index (struct value *value, int type_index) { struct value *result = NULL; volatile struct gdb_exception e; - struct type *type = value_type (value); + type = check_typedef (type); gdb_assert (TYPE_CODE (type) == TYPE_CODE_STRUCT @@ -2822,6 +2843,7 @@ c_describe_child (struct varobj *parent, int index, if (cvalue && value) { int real_index = index + TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type)); + gdb_value_subscript (value, real_index, cvalue); } @@ -2855,6 +2877,7 @@ c_describe_child (struct varobj *parent, int index, if (cfull_expression) { char *join = was_ptr ? "->" : "."; + *cfull_expression = xstrprintf ("(%s)%s%s", parent_expression, join, TYPE_FIELD_NAME (type, index)); } @@ -2868,6 +2891,7 @@ c_describe_child (struct varobj *parent, int index, if (cvalue && value) { int success = gdb_value_ind (value, cvalue); + if (!success) *cvalue = NULL; } @@ -2897,6 +2921,7 @@ static char * c_name_of_child (struct varobj *parent, int index) { char *name; + c_describe_child (parent, index, &name, NULL, NULL, NULL); return name; } @@ -2923,6 +2948,7 @@ check_scope (struct varobj *var) if (fi) { CORE_ADDR pc = get_frame_pc (fi); + if (pc < BLOCK_START (var->root->valid_block) || pc >= BLOCK_END (var->root->valid_block)) scope = 0; @@ -2985,8 +3011,8 @@ static struct value * c_value_of_child (struct varobj *parent, int index) { struct value *value = NULL; - c_describe_child (parent, index, NULL, &value, NULL, NULL); + c_describe_child (parent, index, NULL, &value, NULL, NULL); return value; } @@ -2994,6 +3020,7 @@ static struct type * c_type_of_child (struct varobj *parent, int index) { struct type *type = NULL; + c_describe_child (parent, index, NULL, NULL, &type, NULL); return type; } @@ -3025,6 +3052,7 @@ c_value_of_variable (struct varobj *var, enum varobj_display_formats format) case TYPE_CODE_ARRAY: { char *number; + number = xstrprintf ("[%d]", var->num_children); return (number); } @@ -3217,6 +3245,7 @@ cplus_describe_child (struct varobj *parent, int index, || TYPE_CODE (type) == TYPE_CODE_UNION) { char *join = was_ptr ? "->" : "."; + if (CPLUS_FAKE_CHILD (parent)) { /* The fields of the class type are ordered as they @@ -3278,6 +3307,7 @@ cplus_describe_child (struct varobj *parent, int index, if (cfull_expression) { char *ptr = was_ptr ? "*" : ""; + /* Cast the parent to the base' type. Note that in gdb, expression like (Base1)d @@ -3296,6 +3326,7 @@ cplus_describe_child (struct varobj *parent, int index, { char *access = NULL; int children[3]; + cplus_class_num_children (type, children); /* Everything beyond the baseclasses can @@ -3351,6 +3382,7 @@ static char * cplus_name_of_child (struct varobj *parent, int index) { char *name = NULL; + cplus_describe_child (parent, index, &name, NULL, NULL, NULL); return name; } @@ -3373,6 +3405,7 @@ static struct value * cplus_value_of_child (struct varobj *parent, int index) { struct value *value = NULL; + cplus_describe_child (parent, index, NULL, &value, NULL, NULL); return value; } @@ -3381,12 +3414,14 @@ static struct type * cplus_type_of_child (struct varobj *parent, int index) { struct type *type = NULL; + cplus_describe_child (parent, index, NULL, NULL, &type, NULL); return type; } static char * -cplus_value_of_variable (struct varobj *var, enum varobj_display_formats format) +cplus_value_of_variable (struct varobj *var, + enum varobj_display_formats format) { /* If we have one of our special types, don't print out diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c index 2720f6d..aa6d27e 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -240,6 +240,7 @@ find_targ_sec (bfd *abfd, asection *sect, void *obj) { struct find_targ_sec_arg *args = (struct find_targ_sec_arg *) obj; struct objfile *objfile = args->objfile; + if (sect->target_index == args->targ_index) { /* This is the section. Figure out what SECT_OFF_* code it is. */ @@ -258,6 +259,7 @@ static int secnum_to_section (int secnum, struct objfile *objfile) { int off = SECT_OFF_TEXT (objfile); + asection *sect = NULL; struct find_targ_sec_arg args; args.targ_index = secnum; @@ -273,6 +275,7 @@ static asection * secnum_to_bfd_section (int secnum, struct objfile *objfile) { int off = SECT_OFF_TEXT (objfile); + asection *sect = NULL; struct find_targ_sec_arg args; args.targ_index = secnum; @@ -372,6 +375,7 @@ compare_lte (const void *lte1p, const void *lte2p) { struct linetable_entry *lte1 = (struct linetable_entry *) lte1p; struct linetable_entry *lte2 = (struct linetable_entry *) lte2p; + return lte1->pc - lte2->pc; } @@ -399,10 +403,8 @@ arrange_linetable (struct linetable *oldLineTb) for (function_count = 0, ii = 0; ii < oldLineTb->nitems; ++ii) { - if (oldLineTb->item[ii].line == 0) { /* function entry found. */ - if (function_count >= fentry_size) { /* make sure you have room. */ fentry_size *= 2; @@ -553,8 +555,8 @@ process_linenos (CORE_ADDR start, CORE_ADDR end) { int offset, ii; file_ptr max_offset = - ((struct coff_symfile_info *) this_symtab_psymtab->objfile->deprecated_sym_private) - ->max_lineno_offset; + ((struct coff_symfile_info *) this_symtab_psymtab->objfile + ->deprecated_sym_private)->max_lineno_offset; /* subfile structure for the main compilation unit. */ struct subfile main_subfile; @@ -614,7 +616,6 @@ process_linenos (CORE_ADDR start, CORE_ADDR end) } else { - /* Have a new subfile for the include file. */ tmpSubfile = inclTable[ii].subfile = @@ -708,6 +709,7 @@ process_linenos (CORE_ADDR start, CORE_ADDR end) one when passed to deduce_language_from_filename. Kludge on top of kludge. */ char *fakename = strrchr (inclTable[ii].name, '.'); + if (fakename == NULL) fakename = " ?"; start_subfile (fakename, (char *) 0); @@ -851,11 +853,13 @@ enter_line_range (struct subfile *subfile, unsigned beginoffset, unsigned endoff #define RECORD_MINIMAL_SYMBOL(NAME, ADDR, TYPE, SECTION, OBJFILE) \ { \ char *namestr; \ - namestr = (NAME); \ - if (namestr[0] == '.') ++namestr; \ - prim_record_minimal_symbol_and_info (namestr, (ADDR), (TYPE), \ - (SECTION), (asection *)NULL, (OBJFILE)); \ - misc_func_recorded = 1; \ + \ + namestr = (NAME); \ + if (namestr[0] == '.') ++namestr; \ + prim_record_minimal_symbol_and_info (namestr, (ADDR), (TYPE), \ + (SECTION), (asection *)NULL, \ + (OBJFILE)); \ + misc_func_recorded = 1; \ } @@ -885,6 +889,7 @@ xcoff_next_symbol_text (struct objfile *objfile) { struct internal_syment symbol; char *retval; + /* FIXME: is this the same as the passed arg? */ if (this_symtab_psymtab) objfile = this_symtab_psymtab->objfile; @@ -926,9 +931,10 @@ read_xcoff_symtab (struct partial_symtab *pst) struct objfile *objfile = pst->objfile; bfd *abfd = objfile->obfd; char *raw_auxptr; /* Pointer to first raw aux entry for sym */ - char *strtbl = ((struct coff_symfile_info *) objfile->deprecated_sym_private)->strtbl; + char *strtbl = + ((struct coff_symfile_info *) objfile->deprecated_sym_private)->strtbl; char *debugsec = - ((struct coff_symfile_info *) objfile->deprecated_sym_private)->debugsec; + ((struct coff_symfile_info *) objfile->deprecated_sym_private)->debugsec; char *debugfmt = bfd_xcoff_is_xcoff64 (abfd) ? "XCOFF64" : "XCOFF"; struct internal_syment symbol[1]; @@ -979,7 +985,6 @@ read_xcoff_symtab (struct partial_symtab *pst) while (symnum < max_symnum) { - QUIT; /* make this command interruptable. */ /* READ_ONE_SYMBOL (symbol, cs, symname_alloced); */ @@ -1008,6 +1013,7 @@ read_xcoff_symtab (struct partial_symtab *pst) if (cs->c_name[E_SYMNMLEN - 1] != '\0') { char *p; + p = obstack_alloc (&objfile->objfile_obstack, E_SYMNMLEN + 1); strncpy (p, cs->c_name, E_SYMNMLEN); p[E_SYMNMLEN] = '\0'; @@ -1222,7 +1228,6 @@ read_xcoff_symtab (struct partial_symtab *pst) switch (cs->c_sclass) { - case C_FILE: /* c_value field contains symnum of next .file entry in table @@ -1275,6 +1280,7 @@ read_xcoff_symtab (struct partial_symtab *pst) { CORE_ADDR off = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); + bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type, cs->c_sclass, 0, cs->c_naux, &main_aux); @@ -1290,7 +1296,6 @@ read_xcoff_symtab (struct partial_symtab *pst) } else if (strcmp (cs->c_name, ".ef") == 0) { - bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type, cs->c_sclass, 0, cs->c_naux, &main_aux); @@ -1300,7 +1305,7 @@ read_xcoff_symtab (struct partial_symtab *pst) contains number of lines to '}' */ if (context_stack_depth <= 0) - { /* We attempted to pop an empty context stack */ + { /* We attempted to pop an empty context stack */ ef_complaint (cs->c_symnum); within_function = 0; break; @@ -1612,9 +1617,10 @@ static void read_symbol (struct internal_syment *symbol, int symno) { int nsyms = - ((struct coff_symfile_info *) this_symtab_psymtab->objfile->deprecated_sym_private)->symtbl_num_syms; + ((struct coff_symfile_info *) this_symtab_psymtab->objfile->deprecated_sym_private)->symtbl_num_syms; char *stbl = - ((struct coff_symfile_info *) this_symtab_psymtab->objfile->deprecated_sym_private)->symtbl; + ((struct coff_symfile_info *) this_symtab_psymtab->objfile->deprecated_sym_private)->symtbl; + if (symno < 0 || symno >= nsyms) { complaint (&symfile_complaints, _("Invalid symbol offset")); @@ -1686,6 +1692,7 @@ read_symbol_lineno (int symno) if (symbol->n_sclass == C_FCN) { char *name = xcoff64 ? strtbl + symbol->n_offset : symbol->n_name; + if (strcmp (name, ".bf") == 0) goto gotit; } @@ -1953,11 +1960,11 @@ xcoff_start_psymtab (struct objfile *objfile, char *filename, int first_symnum, struct partial_symbol **static_syms) { struct partial_symtab *result = - start_psymtab_common (objfile, objfile->section_offsets, - filename, - /* We fill in textlow later. */ - 0, - global_syms, static_syms); + start_psymtab_common (objfile, objfile->section_offsets, + filename, + /* We fill in textlow later. */ + 0, + global_syms, static_syms); result->read_symtab_private = obstack_alloc (&objfile->objfile_obstack, sizeof (struct symloc)); @@ -2018,7 +2025,7 @@ xcoff_end_psymtab (struct partial_symtab *pst, char **include_list, for (i = 0; i < num_includes; i++) { struct partial_symtab *subpst = - allocate_psymtab (include_list[i], objfile); + allocate_psymtab (include_list[i], objfile); subpst->section_offsets = pst->section_offsets; subpst->read_symtab_private = obstack_alloc (&objfile->objfile_obstack, @@ -2089,6 +2096,7 @@ swap_sym (struct internal_syment *symbol, union internal_auxent *aux, /* FIXME: wastes memory for symbols which we don't end up putting into the minimal symbols. */ char *p; + p = obstack_alloc (&objfile->objfile_obstack, E_SYMNMLEN + 1); strncpy (p, symbol->n_name, E_SYMNMLEN); p[E_SYMNMLEN] = '\0'; @@ -2281,7 +2289,8 @@ scan_xcoff_symtab (struct objfile *objfile) if (pst != NULL) { CORE_ADDR highval = - symbol.n_value + csect_aux.x_csect.x_scnlen.l; + symbol.n_value + csect_aux.x_csect.x_scnlen.l; + if (highval > pst->texthigh) pst->texthigh = highval; if (pst->textlow == 0 || symbol.n_value < pst->textlow) @@ -2413,7 +2422,6 @@ scan_xcoff_symtab (struct objfile *objfile) if (last_csect_name && !misc_func_recorded) { - /* If no misc. function recorded in the last seen csect, enter it as a function. This will take care of functions like strcmp() compiled by xlc. */ @@ -2507,6 +2515,7 @@ scan_xcoff_symtab (struct objfile *objfile) /* We probably could save a few instructions by assuming that C_LSYM, C_PSYM, etc., never have auxents. */ int naux1 = symbol.n_numaux + 1; + ssymnum += naux1; sraw_symbol += bfd_coff_symesz (abfd) * naux1; } @@ -2516,6 +2525,7 @@ scan_xcoff_symtab (struct objfile *objfile) { /* Mark down an include file in the current psymtab */ enum language tmp_language; + swap_sym (&symbol, &main_aux[0], &namestring, &sraw_symbol, &ssymnum, objfile); @@ -2542,8 +2552,10 @@ scan_xcoff_symtab (struct objfile *objfile) in a binary tree, if profiling shows this is a major hog). */ if (pst && strcmp (namestring, pst->filename) == 0) continue; + { int i; + for (i = 0; i < includes_used; i++) if (strcmp (namestring, psymtab_include_list[i]) == 0) { @@ -2578,6 +2590,7 @@ scan_xcoff_symtab (struct objfile *objfile) case C_STSYM: { char *p; + swap_sym (&symbol, &main_aux[0], &namestring, &sraw_symbol, &ssymnum, objfile); @@ -2742,6 +2755,7 @@ scan_xcoff_symtab (struct objfile *objfile) { int name_len = p - namestring; char *name = xmalloc (name_len + 1); + memcpy (name, namestring, name_len); name[name_len] = '\0'; function_outside_compilation_unit_complaint (name); @@ -2763,6 +2777,7 @@ scan_xcoff_symtab (struct objfile *objfile) { int name_len = p - namestring; char *name = xmalloc (name_len + 1); + memcpy (name, namestring, name_len); name[name_len] = '\0'; function_outside_compilation_unit_complaint (name); diff --git a/gdb/xml-support.c b/gdb/xml-support.c index a8dbc51..b5e8b50 100644 --- a/gdb/xml-support.c +++ b/gdb/xml-support.c @@ -560,6 +560,7 @@ gdb_xml_parse (struct gdb_xml_parser *parser, const char *buffer) else if (status == XML_STATUS_ERROR) { enum XML_Error err = XML_GetErrorCode (parser->expat_parser); + error_string = XML_ErrorString (err); } else @@ -1016,6 +1017,7 @@ obstack_xml_printf (struct obstack *obstack, const char *format, ...) { char *p; char *a = va_arg (ap, char *); + obstack_grow (obstack, prev, f - prev - 1); p = xml_escape_text (a); obstack_grow_str (obstack, p); @@ -1046,6 +1048,7 @@ xml_fetch_content_from_file (const char *filename, void *baton) if (dirname && *dirname) { char *fullname = concat (dirname, "/", filename, (char *) NULL); + if (fullname == NULL) nomem (0); file = fopen (fullname, FOPEN_RT); diff --git a/gdb/xml-tdesc.c b/gdb/xml-tdesc.c index ca60ffb..bccef11 100644 --- a/gdb/xml-tdesc.c +++ b/gdb/xml-tdesc.c @@ -261,6 +261,7 @@ tdesc_start_struct (struct gdb_xml_parser *parser, { int size = (int) * (ULONGEST *) VEC_index (gdb_xml_value_s, attributes, 1)->value; + tdesc_set_struct_size (type, size); data->current_type_size = size; } |