diff options
author | David Taylor <dtaylor@emc.com> | 2016-04-12 15:02:57 -0400 |
---|---|---|
committer | David Taylor <david.taylor@emc.com> | 2016-06-24 21:02:36 -0400 |
commit | 6b8505468e64c2be8d0eea1f2b8db86fa3897600 (patch) | |
tree | 81de3154cfc05d9811239c11ef05cbb3a6fec06d /gdb/valops.c | |
parent | e0204c4d4ceb9be0b0ccf8f92ab683aab54f67cd (diff) | |
download | gdb-6b8505468e64c2be8d0eea1f2b8db86fa3897600.zip gdb-6b8505468e64c2be8d0eea1f2b8db86fa3897600.tar.gz gdb-6b8505468e64c2be8d0eea1f2b8db86fa3897600.tar.bz2 |
Support structure offsets that are 512K or larger.
GDB computes structure byte offsets using a 32 bit integer. And,
first it computes the offset in bits and then converts to bytes. The
result is that any offset that if 512K bytes or larger overflows.
This patch changes GDB to use LONGEST for such calculations.
PR gdb/17520 Structure offset wrong when 1/4 GB or greater.
* c-lang.h: Change all parameters, variables, and struct or union
members used as struct or union fie3ld offsets from int to
LONGEST.
* c-valprint.c: Likewise.
* cp-abi.c: Likewise.
* cp-abi.h: Likewise.
* cp-valprint.c: Likewise.
* d-valprint.c: Likewise.
* dwarf2loc.c: Likewise.
* eval.c: Likewise.
* extension-priv.h: Likewise.
* extension.c: Likewise.
* extension.h: Likewise.
* findvar.c: Likewise.
* gdbtypes.h: Likewise.
* gnu-v2-abi.c: Likewise.
* gnu-v3-abi.c: Likewise.
* go-valprint.c: Likewise.
* guile/guile-internal.h: Likewise.
* guile/scm-pretty-print.c: Likewise.
* jv-valprint.c Likewise.
* opencl-lang.c: Likewise.
* p-lang.h: Likewise.
* python/py-prettyprint.c: Likewise.
* python/python-internal.h: Likewise.
* spu-tdep.c: Likewise.
* typeprint.c: Likewise.
* valarith.c: Likewise.
* valops.c: Likewise.
* valprint.c: Likewise.
* valprint.h: Likewise.
* value.c: Likewise.
* value.h: Likewise.
* p-valprint.c: Likewise.
* c-typeprint.c (c_type_print_base): When printing offset, use
plongest, not %d.
* gdbtypes.c (recursive_dump_type): Ditto.
Diffstat (limited to 'gdb/valops.c')
-rw-r--r-- | gdb/valops.c | 65 |
1 files changed, 34 insertions, 31 deletions
diff --git a/gdb/valops.c b/gdb/valops.c index 7f9cb93..40392e8 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -51,7 +51,7 @@ static struct value *search_struct_field (const char *, struct value *, static struct value *search_struct_method (const char *, struct value **, struct value **, - int, int *, struct type *); + LONGEST, int *, struct type *); static int find_oload_champ_namespace (struct value **, int, const char *, const char *, @@ -96,9 +96,9 @@ static CORE_ADDR allocate_space_in_inferior (int); static struct value *cast_into_complex (struct type *, struct value *); static void find_method_list (struct value **, const char *, - int, struct type *, struct fn_field **, int *, + LONGEST, struct type *, struct fn_field **, int *, VEC (xmethod_worker_ptr) **, - struct type **, int *); + struct type **, LONGEST *); void _initialize_valops (void); @@ -256,7 +256,8 @@ value_cast_structs (struct type *type, struct value *v2) if (TYPE_NAME (t2) != NULL) { /* Try downcasting using the run-time type of the value. */ - int full, top, using_enc; + int full, using_enc; + LONGEST top; struct type *real_type; real_type = value_rtti_type (v2, &full, &top, &using_enc); @@ -635,7 +636,7 @@ value_reinterpret_cast (struct type *type, struct value *arg) static int dynamic_cast_check_1 (struct type *desired_type, const gdb_byte *valaddr, - int embedded_offset, + LONGEST embedded_offset, CORE_ADDR address, struct value *val, struct type *search_type, @@ -647,8 +648,9 @@ 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, valaddr, embedded_offset, - address, val); + LONGEST offset = baseclass_offset (search_type, i, valaddr, + embedded_offset, + address, val); if (class_types_same_p (desired_type, TYPE_BASECLASS (search_type, i))) { @@ -682,7 +684,7 @@ dynamic_cast_check_1 (struct type *desired_type, static int dynamic_cast_check_2 (struct type *desired_type, const gdb_byte *valaddr, - int embedded_offset, + LONGEST embedded_offset, CORE_ADDR address, struct value *val, struct type *search_type, @@ -692,7 +694,7 @@ dynamic_cast_check_2 (struct type *desired_type, for (i = 0; i < TYPE_N_BASECLASSES (search_type) && result_count < 2; ++i) { - int offset; + LONGEST offset; if (! BASETYPE_VIA_PUBLIC (search_type, i)) continue; @@ -723,7 +725,8 @@ dynamic_cast_check_2 (struct type *desired_type, struct value * value_dynamic_cast (struct type *type, struct value *arg) { - int full, top, using_enc; + int full, using_enc; + LONGEST top; struct type *resolved_type = check_typedef (type); struct type *arg_type = check_typedef (value_type (arg)); struct type *class_type, *rtti_type; @@ -954,7 +957,7 @@ value_at_lazy (struct type *type, CORE_ADDR addr) } void -read_value_memory (struct value *val, int embedded_offset, +read_value_memory (struct value *val, LONGEST embedded_offset, int stack, CORE_ADDR memaddr, gdb_byte *buffer, size_t length) { @@ -1034,7 +1037,7 @@ value_assign (struct value *toval, struct value *fromval) case lval_internalvar_component: { - int offset = value_offset (toval); + LONGEST offset = value_offset (toval); /* Are we dealing with a bitfield? @@ -1121,7 +1124,7 @@ value_assign (struct value *toval, struct value *fromval) if (value_bitsize (toval)) { struct value *parent = value_parent (toval); - int offset = value_offset (parent) + value_offset (toval); + LONGEST offset = value_offset (parent) + value_offset (toval); int changed_len; gdb_byte buffer[sizeof (LONGEST)]; int optim, unavail; @@ -1600,7 +1603,7 @@ value_array (int lowbound, int highbound, struct value **elemvec) { int nelem; int idx; - unsigned int typelength; + ULONGEST typelength; struct value *val; struct type *arraytype; @@ -1776,7 +1779,7 @@ typecmp (int staticp, int varargs, int nargs, static void update_search_result (struct value **result_ptr, struct value *v, - int *last_boffset, int boffset, + LONGEST *last_boffset, LONGEST boffset, const char *name, struct type *type) { if (v != NULL) @@ -1800,10 +1803,10 @@ update_search_result (struct value **result_ptr, struct value *v, lookup is ambiguous. */ static void -do_search_struct_field (const char *name, struct value *arg1, int offset, +do_search_struct_field (const char *name, struct value *arg1, LONGEST offset, struct type *type, int looking_for_baseclass, struct value **result_ptr, - int *last_boffset, + LONGEST *last_boffset, struct type *outermost_type) { int i; @@ -1850,7 +1853,7 @@ do_search_struct_field (const char *name, struct value *arg1, int offset, <variant field>. */ struct value *v = NULL; - int new_offset = offset; + LONGEST new_offset = offset; /* This is pretty gross. In G++, the offset in an anonymous union is relative to the beginning of the @@ -1889,7 +1892,7 @@ do_search_struct_field (const char *name, struct value *arg1, int offset, && (strcmp_iw (name, TYPE_BASECLASS_NAME (type, i)) == 0)); - int boffset = value_embedded_offset (arg1) + offset; + LONGEST boffset = value_embedded_offset (arg1) + offset; if (BASETYPE_VIA_VIRTUAL (type, i)) { @@ -1965,7 +1968,7 @@ search_struct_field (const char *name, struct value *arg1, struct type *type, int looking_for_baseclass) { struct value *result = NULL; - int boffset = 0; + LONGEST boffset = 0; do_search_struct_field (name, arg1, 0, type, looking_for_baseclass, &result, &boffset, type); @@ -1982,7 +1985,7 @@ search_struct_field (const char *name, struct value *arg1, static struct value * search_struct_method (const char *name, struct value **arg1p, - struct value **args, int offset, + struct value **args, LONGEST offset, int *static_memfuncp, struct type *type) { int i; @@ -2046,8 +2049,8 @@ search_struct_method (const char *name, struct value **arg1p, for (i = TYPE_N_BASECLASSES (type) - 1; i >= 0; i--) { - int base_offset; - int this_offset; + LONGEST base_offset; + LONGEST this_offset; if (BASETYPE_VIA_VIRTUAL (type, i)) { @@ -2280,10 +2283,10 @@ value_struct_elt_bitpos (struct value **argp, int bitpos, struct type *ftype, static void find_method_list (struct value **argp, const char *method, - int offset, struct type *type, + LONGEST offset, struct type *type, struct fn_field **fn_list, int *num_fns, VEC (xmethod_worker_ptr) **xm_worker_vec, - struct type **basetype, int *boffset) + struct type **basetype, LONGEST *boffset) { int i; struct fn_field *f = NULL; @@ -2340,7 +2343,7 @@ find_method_list (struct value **argp, const char *method, extension methods. */ for (i = TYPE_N_BASECLASSES (type) - 1; i >= 0; i--) { - int base_offset; + LONGEST base_offset; if (BASETYPE_VIA_VIRTUAL (type, i)) { @@ -2380,10 +2383,10 @@ find_method_list (struct value **argp, const char *method, static void value_find_oload_method_list (struct value **argp, const char *method, - int offset, struct fn_field **fn_list, + LONGEST offset, struct fn_field **fn_list, int *num_fns, VEC (xmethod_worker_ptr) **xm_worker_vec, - struct type **basetype, int *boffset) + struct type **basetype, LONGEST *boffset) { struct type *t; @@ -2493,7 +2496,7 @@ find_overload_match (struct value **args, int nargs, /* Number of overloaded instances being considered. */ int num_fns = 0; struct type *basetype = NULL; - int boffset; + LONGEST boffset; struct cleanup *all_cleanups = make_cleanup (null_cleanup, NULL); @@ -3588,7 +3591,7 @@ value_maybe_namespace_elt (const struct type *curtype, struct type * value_rtti_indirect_type (struct value *v, int *full, - int *top, int *using_enc) + LONGEST *top, int *using_enc) { struct value *target = NULL; struct type *type, *real_type, *target_type; @@ -3661,7 +3664,7 @@ value_full_object (struct value *argp, { struct type *real_type; int full = 0; - int top = -1; + LONGEST top = -1; int using_enc = 0; struct value *new_val; |