From 6b8505468e64c2be8d0eea1f2b8db86fa3897600 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Tue, 12 Apr 2016 15:02:57 -0400 Subject: 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. --- gdb/ChangeLog | 41 +++++++++++++ gdb/c-lang.h | 4 +- gdb/c-typeprint.c | 11 ++-- gdb/c-valprint.c | 3 +- gdb/cp-abi.c | 4 +- gdb/cp-abi.h | 8 +-- gdb/cp-valprint.c | 15 ++--- gdb/d-valprint.c | 2 +- gdb/dwarf2loc.c | 7 ++- gdb/eval.c | 3 +- gdb/extension-priv.h | 2 +- gdb/extension.c | 2 +- gdb/extension.h | 2 +- gdb/findvar.c | 4 +- gdb/gdbtypes.c | 4 +- gdb/gdbtypes.h | 2 +- gdb/gnu-v2-abi.c | 6 +- gdb/gnu-v3-abi.c | 4 +- gdb/go-valprint.c | 2 +- gdb/guile/guile-internal.h | 2 +- gdb/guile/scm-pretty-print.c | 2 +- gdb/jv-valprint.c | 2 +- gdb/opencl-lang.c | 10 +-- gdb/p-lang.h | 2 +- gdb/p-valprint.c | 10 +-- gdb/python/py-prettyprint.c | 2 +- gdb/python/python-internal.h | 2 +- gdb/spu-tdep.c | 2 +- gdb/testsuite/ChangeLog | 5 ++ gdb/testsuite/gdb.base/offsets.c | 28 +++++++++ gdb/testsuite/gdb.base/offsets.exp | 45 ++++++++++++++ gdb/typeprint.c | 2 +- gdb/valarith.c | 4 +- gdb/valops.c | 65 ++++++++++---------- gdb/valprint.c | 8 +-- gdb/valprint.h | 4 +- gdb/value.c | 122 +++++++++++++++++++------------------ gdb/value.h | 79 ++++++++++++------------ 38 files changed, 328 insertions(+), 194 deletions(-) create mode 100644 gdb/testsuite/gdb.base/offsets.c create mode 100644 gdb/testsuite/gdb.base/offsets.exp diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 1ad9aa5..3e6a2cc 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,44 @@ +2016-06-24 David Taylor + + 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. + 2016-06-24 David Taylor * MAINTAINERS (Write After Approval): Add David Taylor. diff --git a/gdb/c-lang.h b/gdb/c-lang.h index bf50afc..12be8bf 100644 --- a/gdb/c-lang.h +++ b/gdb/c-lang.h @@ -123,14 +123,14 @@ extern void cp_print_class_member (const gdb_byte *, struct type *, struct ui_file *, char *); extern void cp_print_value_fields (struct type *, struct type *, - const gdb_byte *, int, CORE_ADDR, + const gdb_byte *, LONGEST, CORE_ADDR, struct ui_file *, int, const struct value *, const struct value_print_options *, struct type **, int); extern void cp_print_value_fields_rtti (struct type *, - const gdb_byte *, int, CORE_ADDR, + const gdb_byte *, LONGEST, CORE_ADDR, struct ui_file *, int, const struct value *, const struct value_print_options *, diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c index ed16fc3..2564ebc 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c @@ -1437,13 +1437,14 @@ c_type_print_base (struct type *type, struct ui_file *stream, TYPE_FIELD_NAME (type, i), stream, show, level + 4, &local_flags); - fprintf_filtered (stream, " @%d", - TYPE_FIELD_BITPOS (type, i)); + fprintf_filtered (stream, " @%s", + plongest (TYPE_FIELD_BITPOS (type, i))); if (TYPE_FIELD_BITSIZE (type, i) > 1) { - fprintf_filtered (stream, "-%d", - TYPE_FIELD_BITPOS (type, i) - + TYPE_FIELD_BITSIZE (type, i) - 1); + fprintf_filtered (stream, "-%s", + plongest (TYPE_FIELD_BITPOS (type, i) + + TYPE_FIELD_BITSIZE (type, i) + - 1)); } fprintf_filtered (stream, ";\n"); } diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c index 61302a3..2cb418d 100644 --- a/gdb/c-valprint.c +++ b/gdb/c-valprint.c @@ -567,7 +567,8 @@ c_value_print (struct value *val, struct ui_file *stream, const struct value_print_options *options) { struct type *type, *real_type, *val_type; - int full, top, using_enc; + int full, using_enc; + LONGEST top; struct value_print_options opts = *options; opts.deref_ref = 1; diff --git a/gdb/cp-abi.c b/gdb/cp-abi.c index 96533b1..afc4d4a 100644 --- a/gdb/cp-abi.c +++ b/gdb/cp-abi.c @@ -66,7 +66,7 @@ is_operator_name (const char *name) int baseclass_offset (struct type *type, int index, const gdb_byte *valaddr, - int embedded_offset, CORE_ADDR address, + LONGEST embedded_offset, CORE_ADDR address, const struct value *val) { int res = 0; @@ -106,7 +106,7 @@ value_virtual_fn_field (struct value **arg1p, struct type * value_rtti_type (struct value *v, int *full, - int *top, int *using_enc) + LONGEST *top, int *using_enc) { struct type *ret = NULL; diff --git a/gdb/cp-abi.h b/gdb/cp-abi.h index 6d038f3..4349a4a 100644 --- a/gdb/cp-abi.h +++ b/gdb/cp-abi.h @@ -135,7 +135,7 @@ extern struct value *value_virtual_fn_field (struct value **valuep, FULL, TOP, and USING_ENC can each be zero, in which case we don't provide the corresponding piece of information. */ extern struct type *value_rtti_type (struct value *value, - int *full, int *top, + int *full, LONGEST *top, int *using_enc); /* Compute the offset of the baseclass which is the INDEXth baseclass @@ -146,7 +146,7 @@ extern struct type *value_rtti_type (struct value *value, extern int baseclass_offset (struct type *type, int index, const gdb_byte *valaddr, - int embedded_offset, + LONGEST embedded_offset, CORE_ADDR address, const struct value *val); @@ -229,9 +229,9 @@ struct cp_abi_ops int j, struct type * type, int offset); struct type *(*rtti_type) (struct value *v, int *full, - int *top, int *using_enc); + LONGEST *top, int *using_enc); int (*baseclass_offset) (struct type *type, int index, - const bfd_byte *valaddr, int embedded_offset, + const bfd_byte *valaddr, LONGEST embedded_offset, CORE_ADDR address, const struct value *val); void (*print_method_ptr) (const gdb_byte *contents, struct type *type, diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index effce30..7b0c19a 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -80,7 +80,7 @@ static void cp_print_static_field (struct type *, struct value *, const struct value_print_options *); static void cp_print_value (struct type *, struct type *, - const gdb_byte *, int, + const gdb_byte *, LONGEST, CORE_ADDR, struct ui_file *, int, const struct value *, const struct value_print_options *, @@ -154,7 +154,7 @@ cp_is_vtbl_member (struct type *type) void cp_print_value_fields (struct type *type, struct type *real_type, - const gdb_byte *valaddr, int offset, + const gdb_byte *valaddr, LONGEST offset, CORE_ADDR address, struct ui_file *stream, int recurse, const struct value *val, const struct value_print_options *options, @@ -417,7 +417,7 @@ cp_print_value_fields (struct type *type, struct type *real_type, void cp_print_value_fields_rtti (struct type *type, - const gdb_byte *valaddr, int offset, + const gdb_byte *valaddr, LONGEST offset, CORE_ADDR address, struct ui_file *stream, int recurse, const struct value *val, @@ -434,7 +434,8 @@ cp_print_value_fields_rtti (struct type *type, TARGET_CHAR_BIT * TYPE_LENGTH (type))) { struct value *value; - int full, top, using_enc; + int full, using_enc; + LONGEST top; /* Ugh, we have to convert back to a value here. */ value = value_from_contents_and_address (type, valaddr + offset, @@ -459,7 +460,7 @@ cp_print_value_fields_rtti (struct type *type, static void cp_print_value (struct type *type, struct type *real_type, - const gdb_byte *valaddr, int offset, + const gdb_byte *valaddr, LONGEST offset, CORE_ADDR address, struct ui_file *stream, int recurse, const struct value *val, const struct value_print_options *options, @@ -469,7 +470,7 @@ cp_print_value (struct type *type, struct type *real_type, = (struct type **) obstack_next_free (&dont_print_vb_obstack); struct obstack tmp_obstack = dont_print_vb_obstack; int i, n_baseclasses = TYPE_N_BASECLASSES (type); - int thisoffset; + LONGEST thisoffset; struct type *thistype; if (dont_print_vb == 0) @@ -483,7 +484,7 @@ cp_print_value (struct type *type, struct type *real_type, for (i = 0; i < n_baseclasses; i++) { - int boffset = 0; + LONGEST boffset = 0; int skip = 0; struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i)); const char *basename = TYPE_NAME (baseclass); diff --git a/gdb/d-valprint.c b/gdb/d-valprint.c index 8527424..620688b 100644 --- a/gdb/d-valprint.c +++ b/gdb/d-valprint.c @@ -29,7 +29,7 @@ static int dynamic_array_type (struct type *type, const gdb_byte *valaddr, - int embedded_offset, CORE_ADDR address, + LONGEST embedded_offset, CORE_ADDR address, struct ui_file *stream, int recurse, const struct value *val, const struct value_print_options *options) diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c index adb0ac2..548e468 100644 --- a/gdb/dwarf2loc.c +++ b/gdb/dwarf2loc.c @@ -1765,7 +1765,7 @@ read_pieced_value (struct value *v) struct gdbarch *arch = get_frame_arch (frame); int gdb_regnum = dwarf_reg_to_regnum_or_error (arch, p->v.regno); int optim, unavail; - int reg_offset = source_offset; + LONGEST reg_offset = source_offset; if (gdbarch_byte_order (arch) == BFD_ENDIAN_BIG && this_size < register_size (arch, gdb_regnum)) @@ -2016,7 +2016,7 @@ write_pieced_value (struct value *to, struct value *from) a synthetic pointer. */ static int -check_pieced_synthetic_pointer (const struct value *value, int bit_offset, +check_pieced_synthetic_pointer (const struct value *value, LONGEST bit_offset, int bit_length) { struct piece_closure *c @@ -2132,7 +2132,8 @@ indirect_pieced_value (struct value *value) struct type *type; struct frame_info *frame; struct dwarf2_locexpr_baton baton; - int i, bit_offset, bit_length; + int i, bit_length; + LONGEST bit_offset; struct dwarf_expr_piece *piece = NULL; LONGEST byte_offset; enum bfd_endian byte_order; diff --git a/gdb/eval.c b/gdb/eval.c index de1c663..00a107c 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -1900,7 +1900,8 @@ evaluate_subexp_standard (struct type *expect_type, { struct type *type = value_type (arg1); struct type *real_type; - int full, top, using_enc; + int full, using_enc; + LONGEST top; struct value_print_options opts; get_user_print_options (&opts); diff --git a/gdb/extension-priv.h b/gdb/extension-priv.h index d7bc572..26bd21f 100644 --- a/gdb/extension-priv.h +++ b/gdb/extension-priv.h @@ -181,7 +181,7 @@ struct extension_language_ops enum ext_lang_rc (*apply_val_pretty_printer) (const struct extension_language_defn *, struct type *type, const gdb_byte *valaddr, - int embedded_offset, CORE_ADDR address, + LONGEST embedded_offset, CORE_ADDR address, struct ui_file *stream, int recurse, const struct value *val, const struct value_print_options *options, const struct language_defn *language); diff --git a/gdb/extension.c b/gdb/extension.c index ae24518..c9f5664 100644 --- a/gdb/extension.c +++ b/gdb/extension.c @@ -497,7 +497,7 @@ free_ext_lang_type_printers (struct ext_lang_type_printers *printers) int apply_ext_lang_val_pretty_printer (struct type *type, const gdb_byte *valaddr, - int embedded_offset, CORE_ADDR address, + LONGEST embedded_offset, CORE_ADDR address, struct ui_file *stream, int recurse, const struct value *val, const struct value_print_options *options, diff --git a/gdb/extension.h b/gdb/extension.h index e9980a7..fa11f25 100644 --- a/gdb/extension.h +++ b/gdb/extension.h @@ -226,7 +226,7 @@ extern void free_ext_lang_type_printers (struct ext_lang_type_printers *); extern int apply_ext_lang_val_pretty_printer (struct type *type, const gdb_byte *valaddr, - int embedded_offset, CORE_ADDR address, + LONGEST embedded_offset, CORE_ADDR address, struct ui_file *stream, int recurse, const struct value *val, const struct value_print_options *options, const struct language_defn *language); diff --git a/gdb/findvar.c b/gdb/findvar.c index cfb3e38..c64ec06 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -835,8 +835,8 @@ void read_frame_register_value (struct value *value, struct frame_info *frame) { struct gdbarch *gdbarch = get_frame_arch (frame); - int offset = 0; - int reg_offset = value_offset (value); + LONGEST offset = 0; + LONGEST reg_offset = value_offset (value); int regnum = VALUE_REGNUM (value); int len = type_length_units (check_typedef (value_type (value))); diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 0421cc5..ec5c17a 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -4297,8 +4297,8 @@ recursive_dump_type (struct type *type, int spaces) idx, plongest (TYPE_FIELD_ENUMVAL (type, idx))); else printfi_filtered (spaces + 2, - "[%d] bitpos %d bitsize %d type ", - idx, TYPE_FIELD_BITPOS (type, idx), + "[%d] bitpos %s bitsize %d type ", + idx, plongest (TYPE_FIELD_BITPOS (type, idx)), TYPE_FIELD_BITSIZE (type, idx)); gdb_print_host_address (TYPE_FIELD_TYPE (type, idx), gdb_stdout); printf_filtered (" name '%s' (", diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 91e3eb9..2dda074 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -511,7 +511,7 @@ union field_location gdbarch_bits_big_endian=0 targets, it is the bit offset to the LSB. */ - int bitpos; + LONGEST bitpos; /* * Enum value. */ LONGEST enumval; diff --git a/gdb/gnu-v2-abi.c b/gdb/gnu-v2-abi.c index 7618d48..d2a0e35 100644 --- a/gdb/gnu-v2-abi.c +++ b/gdb/gnu-v2-abi.c @@ -183,7 +183,7 @@ gnuv2_virtual_fn_field (struct value **arg1p, struct fn_field * f, int j, static struct type * -gnuv2_value_rtti_type (struct value *v, int *full, int *top, int *using_enc) +gnuv2_value_rtti_type (struct value *v, int *full, LONGEST *top, int *using_enc) { struct type *known_type; struct type *rtti_type; @@ -340,7 +340,7 @@ vb_match (struct type *type, int index, struct type *basetype) static int gnuv2_baseclass_offset (struct type *type, int index, - const bfd_byte *valaddr, int embedded_offset, + const bfd_byte *valaddr, LONGEST embedded_offset, CORE_ADDR address, const struct value *val) { struct type *basetype = TYPE_BASECLASS (type, index); @@ -358,7 +358,7 @@ gnuv2_baseclass_offset (struct type *type, int index, if (vb_match (type, i, basetype)) { struct type *field_type; - int field_offset; + LONGEST field_offset; int field_length; CORE_ADDR addr; diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index ae84b36..5bf36a2 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -286,7 +286,7 @@ gnuv3_get_vtable (struct gdbarch *gdbarch, static struct type * gnuv3_rtti_type (struct value *value, - int *full_p, int *top_p, int *using_enc_p) + int *full_p, LONGEST *top_p, int *using_enc_p) { struct gdbarch *gdbarch; struct type *values_type = check_typedef (value_type (value)); @@ -443,7 +443,7 @@ gnuv3_virtual_fn_field (struct value **value_p, static int gnuv3_baseclass_offset (struct type *type, int index, - const bfd_byte *valaddr, int embedded_offset, + const bfd_byte *valaddr, LONGEST embedded_offset, CORE_ADDR address, const struct value *val) { struct gdbarch *gdbarch; diff --git a/gdb/go-valprint.c b/gdb/go-valprint.c index 7bb7b55..34ed8e0 100644 --- a/gdb/go-valprint.c +++ b/gdb/go-valprint.c @@ -37,7 +37,7 @@ static void print_go_string (struct type *type, const gdb_byte *valaddr, - int embedded_offset, CORE_ADDR address, + LONGEST embedded_offset, CORE_ADDR address, struct ui_file *stream, int recurse, const struct value *val, const struct value_print_options *options) diff --git a/gdb/guile/guile-internal.h b/gdb/guile/guile-internal.h index b7f104d..0aa4a0a 100644 --- a/gdb/guile/guile-internal.h +++ b/gdb/guile/guile-internal.h @@ -606,7 +606,7 @@ extern void gdbscm_preserve_values extern enum ext_lang_rc gdbscm_apply_val_pretty_printer (const struct extension_language_defn *, struct type *type, const gdb_byte *valaddr, - int embedded_offset, CORE_ADDR address, + LONGEST embedded_offset, CORE_ADDR address, struct ui_file *stream, int recurse, const struct value *val, const struct value_print_options *options, diff --git a/gdb/guile/scm-pretty-print.c b/gdb/guile/scm-pretty-print.c index b1cbbdd..afdd0c7 100644 --- a/gdb/guile/scm-pretty-print.c +++ b/gdb/guile/scm-pretty-print.c @@ -958,7 +958,7 @@ ppscm_print_children (SCM printer, enum display_hint hint, enum ext_lang_rc gdbscm_apply_val_pretty_printer (const struct extension_language_defn *extlang, struct type *type, const gdb_byte *valaddr, - int embedded_offset, CORE_ADDR address, + LONGEST embedded_offset, CORE_ADDR address, struct ui_file *stream, int recurse, const struct value *val, const struct value_print_options *options, diff --git a/gdb/jv-valprint.c b/gdb/jv-valprint.c index 6f7ef4b..2988737 100644 --- a/gdb/jv-valprint.c +++ b/gdb/jv-valprint.c @@ -266,7 +266,7 @@ java_value_print (struct value *val, struct ui_file *stream, static void java_print_value_fields (struct type *type, const gdb_byte *valaddr, - int offset, + LONGEST offset, CORE_ADDR address, struct ui_file *stream, int recurse, const struct value *val, diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index 2a46d86..6fb8abe 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -172,8 +172,8 @@ lval_func_read (struct value *v) struct lval_closure *c = (struct lval_closure *) value_computed_closure (v); struct type *type = check_typedef (value_type (v)); struct type *eltype = TYPE_TARGET_TYPE (check_typedef (value_type (c->val))); - int offset = value_offset (v); - int elsize = TYPE_LENGTH (eltype); + LONGEST offset = value_offset (v); + LONGEST elsize = TYPE_LENGTH (eltype); int n, i, j = 0; LONGEST lowb = 0; LONGEST highb = 0; @@ -201,8 +201,8 @@ lval_func_write (struct value *v, struct value *fromval) struct lval_closure *c = (struct lval_closure *) value_computed_closure (v); struct type *type = check_typedef (value_type (v)); struct type *eltype = TYPE_TARGET_TYPE (check_typedef (value_type (c->val))); - int offset = value_offset (v); - int elsize = TYPE_LENGTH (eltype); + LONGEST offset = value_offset (v); + LONGEST elsize = TYPE_LENGTH (eltype); int n, i, j = 0; LONGEST lowb = 0; LONGEST highb = 0; @@ -243,7 +243,7 @@ lval_func_write (struct value *v, struct value *fromval) static int lval_func_check_synthetic_pointer (const struct value *v, - int offset, int length) + LONGEST offset, int length) { struct lval_closure *c = (struct lval_closure *) value_computed_closure (v); /* Size of the target type in bits. */ diff --git a/gdb/p-lang.h b/gdb/p-lang.h index d862b49..287c0f4 100644 --- a/gdb/p-lang.h +++ b/gdb/p-lang.h @@ -72,7 +72,7 @@ extern void const struct type_print_options *); extern void pascal_object_print_value_fields (struct type *, const gdb_byte *, - int, + LONGEST, CORE_ADDR, struct ui_file *, int, const struct value *, diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c index 3e840d8..f639e29 100644 --- a/gdb/p-valprint.c +++ b/gdb/p-valprint.c @@ -469,7 +469,7 @@ static void pascal_object_print_static_field (struct value *, const struct value_print_options *); static void pascal_object_print_value (struct type *, const gdb_byte *, - int, + LONGEST, CORE_ADDR, struct ui_file *, int, const struct value *, const struct value_print_options *, @@ -528,7 +528,7 @@ pascal_object_is_vtbl_member (struct type *type) void pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr, - int offset, + LONGEST offset, CORE_ADDR address, struct ui_file *stream, int recurse, const struct value *val, @@ -700,7 +700,7 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr, static void pascal_object_print_value (struct type *type, const gdb_byte *valaddr, - int offset, + LONGEST offset, CORE_ADDR address, struct ui_file *stream, int recurse, const struct value *val, @@ -723,11 +723,11 @@ pascal_object_print_value (struct type *type, const gdb_byte *valaddr, for (i = 0; i < n_baseclasses; i++) { - int boffset = 0; + LONGEST boffset = 0; struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i)); const char *basename = type_name_no_tag (baseclass); const gdb_byte *base_valaddr = NULL; - int thisoffset; + LONGEST thisoffset; int skip = 0; if (BASETYPE_VIA_VIRTUAL (type, i)) diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c index e97769b..8834344 100644 --- a/gdb/python/py-prettyprint.c +++ b/gdb/python/py-prettyprint.c @@ -703,7 +703,7 @@ print_children (PyObject *printer, const char *hint, enum ext_lang_rc gdbpy_apply_val_pretty_printer (const struct extension_language_defn *extlang, struct type *type, const gdb_byte *valaddr, - int embedded_offset, CORE_ADDR address, + LONGEST embedded_offset, CORE_ADDR address, struct ui_file *stream, int recurse, const struct value *val, const struct value_print_options *options, diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h index 7eb9aa4..8545c7b 100644 --- a/gdb/python/python-internal.h +++ b/gdb/python/python-internal.h @@ -316,7 +316,7 @@ extern int gdbpy_auto_load_enabled (const struct extension_language_defn *); extern enum ext_lang_rc gdbpy_apply_val_pretty_printer (const struct extension_language_defn *, struct type *type, const gdb_byte *valaddr, - int embedded_offset, CORE_ADDR address, + LONGEST embedded_offset, CORE_ADDR address, struct ui_file *stream, int recurse, const struct value *val, const struct value_print_options *options, diff --git a/gdb/spu-tdep.c b/gdb/spu-tdep.c index ea3229c..f62e8e7 100644 --- a/gdb/spu-tdep.c +++ b/gdb/spu-tdep.c @@ -363,7 +363,7 @@ spu_value_from_register (struct gdbarch *gdbarch, struct type *type, { struct value *value = default_value_from_register (gdbarch, type, regnum, frame_id); - int len = TYPE_LENGTH (type); + LONGEST len = TYPE_LENGTH (type); if (regnum < SPU_NUM_GPRS && len < 16) { diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 8b5274d..8679965 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-06-24 David Taylor + + * gdb.base/offsets.exp: New file. + * gdb.base/offsets.c: New file. + 2016-06-23 Tom Tromey PR gdb/16483: diff --git a/gdb/testsuite/gdb.base/offsets.c b/gdb/testsuite/gdb.base/offsets.c new file mode 100644 index 0000000..2a1edeb --- /dev/null +++ b/gdb/testsuite/gdb.base/offsets.c @@ -0,0 +1,28 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2014 - 2016 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +struct big_struct +{ + char first[0x10000000 + 16]; + long second; +} big_struct; + +int +main (int argc, char *argv[]) +{ + return (0); +} diff --git a/gdb/testsuite/gdb.base/offsets.exp b/gdb/testsuite/gdb.base/offsets.exp new file mode 100644 index 0000000..b65fac7 --- /dev/null +++ b/gdb/testsuite/gdb.base/offsets.exp @@ -0,0 +1,45 @@ +# Test big offsets + +# Copyright (c) 2014- 2016 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +standard_testfile offsets.c + +if { [prepare_for_testing "failed to prepare for testing large offsets" \ + ${testfile} ${srcfile}] } { + untested offsets.exp + return -1 +} + +set test "print &big_struct test" +gdb_test_multiple "print &big_struct" "$test" { + -re "\\$\[0-9\]* = .* (0x\[0-9a-fA-F\]*) .*\[\r\n\]*$gdb_prompt $" { + set addr1 $expect_out(1,string) + pass "$test ($addr1)" + } +} + +set test "print &big_struct.second test" +gdb_test_multiple "print &big_struct.second" "$test" { + -re "\\$\[0-9\]* = .* (0x\[0-9a-fA-F\]*) .*\[\r\n\]*$gdb_prompt $" { + set addr2 $expect_out(1,string) + + if {[expr $addr2 - $addr1] == [expr 0x10000000 + 16]} { + pass "big offsets" + } else { + fail "big offsets" + } + } +} diff --git a/gdb/typeprint.c b/gdb/typeprint.c index 48a809b..e77513e 100644 --- a/gdb/typeprint.c +++ b/gdb/typeprint.c @@ -406,7 +406,7 @@ whatis_exp (char *exp, int show) struct type *real_type = NULL; struct type *type; int full = 0; - int top = -1; + LONGEST top = -1; int using_enc = 0; struct value_print_options opts; struct type_print_options flags = default_ptype_flags; diff --git a/gdb/valarith.c b/gdb/valarith.c index 254d998..de6fcfd 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -192,8 +192,8 @@ value_subscripted_rvalue (struct value *array, LONGEST index, int lowerbound) { struct type *array_type = check_typedef (value_type (array)); struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (array_type)); - unsigned int elt_size = type_length_units (elt_type); - unsigned int elt_offs = elt_size * longest_to_int (index - lowerbound); + ULONGEST elt_size = type_length_units (elt_type); + ULONGEST elt_offs = elt_size * (index - lowerbound); struct value *v; if (index < lowerbound || (!TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (array_type) 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, . */ 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; diff --git a/gdb/valprint.c b/gdb/valprint.c index 64407e8..6896da2 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -303,7 +303,7 @@ val_print_scalar_type_p (struct type *type) int valprint_check_validity (struct ui_file *stream, struct type *type, - int embedded_offset, + LONGEST embedded_offset, const struct value *val) { type = check_typedef (type); @@ -1042,7 +1042,7 @@ generic_val_print (struct type *type, const gdb_byte *valaddr, RECURSE. */ void -val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset, +val_print (struct type *type, const gdb_byte *valaddr, LONGEST embedded_offset, CORE_ADDR address, struct ui_file *stream, int recurse, const struct value *val, const struct value_print_options *options, @@ -1303,7 +1303,7 @@ val_print_type_code_flags (struct type *type, const gdb_byte *valaddr, void val_print_scalar_formatted (struct type *type, - const gdb_byte *valaddr, int embedded_offset, + const gdb_byte *valaddr, LONGEST embedded_offset, const struct value *val, const struct value_print_options *options, int size, @@ -1965,7 +1965,7 @@ maybe_print_array_index (struct type *index_type, LONGEST index, void val_print_array_elements (struct type *type, - const gdb_byte *valaddr, int embedded_offset, + const gdb_byte *valaddr, LONGEST embedded_offset, CORE_ADDR address, struct ui_file *stream, int recurse, const struct value *val, diff --git a/gdb/valprint.h b/gdb/valprint.h index 451b5fe..23a4c12 100644 --- a/gdb/valprint.h +++ b/gdb/valprint.h @@ -115,7 +115,7 @@ extern void maybe_print_array_index (struct type *index_type, LONGEST index, struct ui_file *stream, const struct value_print_options *); -extern void val_print_array_elements (struct type *, const gdb_byte *, int, +extern void val_print_array_elements (struct type *, const gdb_byte *, LONGEST, CORE_ADDR, struct ui_file *, int, const struct value *, const struct value_print_options *, @@ -125,7 +125,7 @@ extern void val_print_type_code_int (struct type *, const gdb_byte *, struct ui_file *); extern void val_print_scalar_formatted (struct type *, - const gdb_byte *, int, + const gdb_byte *, LONGEST, const struct value *, const struct value_print_options *, int, diff --git a/gdb/value.c b/gdb/value.c index 35fb503..cd59f43 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -65,10 +65,10 @@ struct internal_function struct range { /* Lowest offset in the range. */ - int offset; + LONGEST offset; /* Length of the range. */ - int length; + LONGEST length; }; typedef struct range range_s; @@ -79,8 +79,8 @@ DEF_VEC_O(range_s); [offset2, offset2+len2) overlap. */ static int -ranges_overlap (int offset1, int len1, - int offset2, int len2) +ranges_overlap (LONGEST offset1, LONGEST len1, + LONGEST offset2, LONGEST len2) { ULONGEST h, l; @@ -104,10 +104,10 @@ range_lessthan (const range_s *r1, const range_s *r2) OFFSET+LENGTH). */ static int -ranges_contain (VEC(range_s) *ranges, int offset, int length) +ranges_contain (VEC(range_s) *ranges, LONGEST offset, LONGEST length) { range_s what; - int i; + LONGEST i; what.offset = offset; what.length = length; @@ -239,15 +239,15 @@ struct value the address. If lval == lval_register, this is a further offset from location.address within the registers structure. Note also the member embedded_offset below. */ - int offset; + LONGEST offset; /* Only used for bitfields; number of bits contained in them. */ - int bitsize; + LONGEST bitsize; /* Only used for bitfields; position of start of field. For gdbarch_bits_big_endian=0 targets, it is the position of the LSB. For gdbarch_bits_big_endian=1 targets, it is the position of the MSB. */ - int bitpos; + LONGEST bitpos; /* The number of references to this value. When a value is created, the value chain holds a reference, so REFERENCE_COUNT is 1. If @@ -309,8 +309,8 @@ struct value `type', and `embedded_offset' is zero, so everything works normally. */ struct type *enclosing_type; - int embedded_offset; - int pointed_to_offset; + LONGEST embedded_offset; + LONGEST pointed_to_offset; /* Values are stored in a chain, so that they can be deleted easily over calls to the inferior. Values assigned to internal @@ -349,7 +349,7 @@ get_value_arch (const struct value *value) } int -value_bits_available (const struct value *value, int offset, int length) +value_bits_available (const struct value *value, LONGEST offset, LONGEST length) { gdb_assert (!value->lazy); @@ -357,7 +357,8 @@ value_bits_available (const struct value *value, int offset, int length) } int -value_bytes_available (const struct value *value, int offset, int length) +value_bytes_available (const struct value *value, + LONGEST offset, LONGEST length) { return value_bits_available (value, offset * TARGET_CHAR_BIT, @@ -427,7 +428,8 @@ value_entirely_optimized_out (struct value *value) OFFSET bits, and extending for the next LENGTH bits. */ static void -insert_into_bit_range_vector (VEC(range_s) **vectorp, int offset, int length) +insert_into_bit_range_vector (VEC(range_s) **vectorp, + LONGEST offset, LONGEST length) { range_s newr; int i; @@ -592,13 +594,15 @@ insert_into_bit_range_vector (VEC(range_s) **vectorp, int offset, int length) } void -mark_value_bits_unavailable (struct value *value, int offset, int length) +mark_value_bits_unavailable (struct value *value, + LONGEST offset, LONGEST length) { insert_into_bit_range_vector (&value->unavailable, offset, length); } void -mark_value_bytes_unavailable (struct value *value, int offset, int length) +mark_value_bytes_unavailable (struct value *value, + LONGEST offset, LONGEST length) { mark_value_bits_unavailable (value, offset * TARGET_CHAR_BIT, @@ -612,7 +616,7 @@ mark_value_bytes_unavailable (struct value *value, int offset, int length) static int find_first_range_overlap (VEC(range_s) *ranges, int pos, - int offset, int length) + LONGEST offset, LONGEST length) { range_s *r; int i; @@ -748,8 +752,8 @@ struct ranges_and_idx static int find_first_range_overlap_and_match (struct ranges_and_idx *rp1, struct ranges_and_idx *rp2, - int offset1, int offset2, - int length, ULONGEST *l, ULONGEST *h) + LONGEST offset1, LONGEST offset2, + LONGEST length, ULONGEST *l, ULONGEST *h) { rp1->idx = find_first_range_overlap (rp1->ranges, rp1->idx, offset1, length); @@ -870,9 +874,9 @@ value_contents_bits_eq (const struct value *val1, int offset1, } int -value_contents_eq (const struct value *val1, int offset1, - const struct value *val2, int offset2, - int length) +value_contents_eq (const struct value *val1, LONGEST offset1, + const struct value *val2, LONGEST offset2, + LONGEST length) { return value_contents_bits_eq (val1, offset1 * TARGET_CHAR_BIT, val2, offset2 * TARGET_CHAR_BIT, @@ -1109,35 +1113,35 @@ deprecated_set_value_type (struct value *value, struct type *type) value->type = type; } -int +LONGEST value_offset (const struct value *value) { return value->offset; } void -set_value_offset (struct value *value, int offset) +set_value_offset (struct value *value, LONGEST offset) { value->offset = offset; } -int +LONGEST value_bitpos (const struct value *value) { return value->bitpos; } void -set_value_bitpos (struct value *value, int bit) +set_value_bitpos (struct value *value, LONGEST bit) { value->bitpos = bit; } -int +LONGEST value_bitsize (const struct value *value) { return value->bitsize; } void -set_value_bitsize (struct value *value, int bit) +set_value_bitsize (struct value *value, LONGEST bit) { value->bitsize = bit; } @@ -1330,10 +1334,10 @@ value_ranges_copy_adjusted (struct value *dst, int dst_bit_offset, DST_OFFSET+LENGTH) range are wholly available. */ void -value_contents_copy_raw (struct value *dst, int dst_offset, - struct value *src, int src_offset, int length) +value_contents_copy_raw (struct value *dst, LONGEST dst_offset, + struct value *src, LONGEST src_offset, LONGEST length) { - int src_bit_offset, dst_bit_offset, bit_length; + LONGEST src_bit_offset, dst_bit_offset, bit_length; struct gdbarch *arch = get_value_arch (src); int unit_size = gdbarch_addressable_memory_unit_size (arch); @@ -1377,8 +1381,8 @@ value_contents_copy_raw (struct value *dst, int dst_offset, DST_OFFSET+LENGTH) range are wholly available. */ void -value_contents_copy (struct value *dst, int dst_offset, - struct value *src, int src_offset, int length) +value_contents_copy (struct value *dst, LONGEST dst_offset, + struct value *src, LONGEST src_offset, LONGEST length) { if (src->lazy) value_fetch_lazy (src); @@ -1462,14 +1466,15 @@ mark_value_bytes_optimized_out (struct value *value, int offset, int length) /* See value.h. */ void -mark_value_bits_optimized_out (struct value *value, int offset, int length) +mark_value_bits_optimized_out (struct value *value, + LONGEST offset, LONGEST length) { insert_into_bit_range_vector (&value->optimized_out, offset, length); } int value_bits_synthetic_pointer (const struct value *value, - int offset, int length) + LONGEST offset, LONGEST length) { if (value->lval != lval_computed || !value->location.computed.funcs->check_synthetic_pointer) @@ -1479,26 +1484,26 @@ value_bits_synthetic_pointer (const struct value *value, length); } -int +LONGEST value_embedded_offset (const struct value *value) { return value->embedded_offset; } void -set_value_embedded_offset (struct value *value, int val) +set_value_embedded_offset (struct value *value, LONGEST val) { value->embedded_offset = val; } -int +LONGEST value_pointed_to_offset (const struct value *value) { return value->pointed_to_offset; } void -set_value_pointed_to_offset (struct value *value, int val) +set_value_pointed_to_offset (struct value *value, LONGEST val) { value->pointed_to_offset = val; } @@ -2371,8 +2376,9 @@ get_internalvar_function (struct internalvar *var, } void -set_internalvar_component (struct internalvar *var, int offset, int bitpos, - int bitsize, struct value *newval) +set_internalvar_component (struct internalvar *var, + LONGEST offset, LONGEST bitpos, + LONGEST bitsize, struct value *newval) { gdb_byte *addr; struct gdbarch *arch; @@ -3107,7 +3113,7 @@ set_value_enclosing_type (struct value *val, struct type *new_encl_type) FIELDNO says which field. */ struct value * -value_primitive_field (struct value *arg1, int offset, +value_primitive_field (struct value *arg1, LONGEST offset, int fieldno, struct type *arg_type) { struct value *v; @@ -3137,8 +3143,8 @@ value_primitive_field (struct value *arg1, int offset, bit. Assume that the address, offset, and embedded offset are sufficiently aligned. */ - int bitpos = TYPE_FIELD_BITPOS (arg_type, fieldno); - int container_bitsize = TYPE_LENGTH (type) * 8; + LONGEST bitpos = TYPE_FIELD_BITPOS (arg_type, fieldno); + LONGEST container_bitsize = TYPE_LENGTH (type) * 8; v = allocate_value_lazy (type); v->bitsize = TYPE_FIELD_BITSIZE (arg_type, fieldno); @@ -3159,7 +3165,7 @@ value_primitive_field (struct value *arg1, int offset, /* This field is actually a base subobject, so preserve the entire object's contents for later references to virtual bases, etc. */ - int boffset; + LONGEST boffset; /* Lazy register values with offsets are not supported. */ if (VALUE_LVAL (arg1) == lval_register && value_lazy (arg1)) @@ -3248,7 +3254,7 @@ value_field (struct value *arg1, int fieldno) struct value * value_fn_field (struct value **arg1p, struct fn_field *f, int j, struct type *type, - int offset) + LONGEST offset) { struct value *v; struct type *ftype = TYPE_FN_FIELD_TYPE (f, j); @@ -3318,14 +3324,14 @@ value_fn_field (struct value **arg1p, struct fn_field *f, static LONGEST unpack_bits_as_long (struct type *field_type, const gdb_byte *valaddr, - int bitpos, int bitsize) + LONGEST bitpos, LONGEST bitsize) { enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (field_type)); ULONGEST val; ULONGEST valmask; int lsbcount; - int bytes_read; - int read_offset; + LONGEST bytes_read; + LONGEST read_offset; /* Read the minimum number of bytes required; there may not be enough bytes to read an entire ULONGEST. */ @@ -3374,7 +3380,7 @@ unpack_bits_as_long (struct type *field_type, const gdb_byte *valaddr, int unpack_value_field_as_long (struct type *type, const gdb_byte *valaddr, - int embedded_offset, int fieldno, + LONGEST embedded_offset, int fieldno, const struct value *val, LONGEST *result) { int bitpos = TYPE_FIELD_BITPOS (type, fieldno); @@ -3417,8 +3423,8 @@ unpack_field_as_long (struct type *type, const gdb_byte *valaddr, int fieldno) void unpack_value_bitfield (struct value *dest_val, - int bitpos, int bitsize, - const gdb_byte *valaddr, int embedded_offset, + LONGEST bitpos, LONGEST bitsize, + const gdb_byte *valaddr, LONGEST embedded_offset, const struct value *val) { enum bfd_endian byte_order; @@ -3456,7 +3462,7 @@ unpack_value_bitfield (struct value *dest_val, struct value * value_field_bitfield (struct type *type, int fieldno, const gdb_byte *valaddr, - int embedded_offset, const struct value *val) + LONGEST embedded_offset, const struct value *val) { int bitpos = TYPE_FIELD_BITPOS (type, fieldno); int bitsize = TYPE_FIELD_BITSIZE (type, fieldno); @@ -3477,12 +3483,12 @@ value_field_bitfield (struct type *type, int fieldno, void modify_field (struct type *type, gdb_byte *addr, - LONGEST fieldval, int bitpos, int bitsize) + LONGEST fieldval, LONGEST bitpos, LONGEST bitsize) { enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type)); ULONGEST oword; ULONGEST mask = (ULONGEST) -1 >> (8 * sizeof (ULONGEST) - bitsize); - int bytesize; + LONGEST bytesize; /* Normalize BITPOS. */ addr += bitpos / 8; @@ -3498,7 +3504,7 @@ modify_field (struct type *type, gdb_byte *addr, { /* FIXME: would like to include fieldval in the message, but we don't have a sprintf_longest. */ - warning (_("Value does not fit in %d bits."), bitsize); + warning (_("Value does not fit in %s bits."), plongest (bitsize)); /* Truncate it, otherwise adjoining fields may be corrupted. */ fieldval &= mask; @@ -3526,7 +3532,7 @@ void pack_long (gdb_byte *buf, struct type *type, LONGEST num) { enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type)); - int len; + LONGEST len; type = check_typedef (type); len = TYPE_LENGTH (type); @@ -3560,7 +3566,7 @@ pack_long (gdb_byte *buf, struct type *type, LONGEST num) static void pack_unsigned_long (gdb_byte *buf, struct type *type, ULONGEST num) { - int len; + LONGEST len; enum bfd_endian byte_order; type = check_typedef (type); diff --git a/gdb/value.h b/gdb/value.h index f8ec854..0b417b4 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -112,15 +112,15 @@ extern void deprecated_set_value_type (struct value *value, /* Only used for bitfields; number of bits contained in them. */ -extern int value_bitsize (const struct value *); -extern void set_value_bitsize (struct value *, int bit); +extern LONGEST value_bitsize (const struct value *); +extern void set_value_bitsize (struct value *, LONGEST bit); /* Only used for bitfields; position of start of field. For gdbarch_bits_big_endian=0 targets, it is the position of the LSB. For gdbarch_bits_big_endian=1 targets, it is the position of the MSB. */ -extern int value_bitpos (const struct value *); -extern void set_value_bitpos (struct value *, int bit); +extern LONGEST value_bitpos (const struct value *); +extern void set_value_bitpos (struct value *, LONGEST bit); /* Only used for bitfields; the containing value. This allows a single read from the target when displaying multiple @@ -135,8 +135,8 @@ extern void set_value_parent (struct value *value, struct value *parent); within the registers structure. Note also the member embedded_offset below. */ -extern int value_offset (const struct value *); -extern void set_value_offset (struct value *, int offset); +extern LONGEST value_offset (const struct value *); +extern void set_value_offset (struct value *, LONGEST offset); /* The comment from "struct value" reads: ``Is it modifiable? Only relevant if lval != not_lval.''. Shouldn't the value instead be @@ -205,10 +205,10 @@ extern struct type *value_actual_type (struct value *value, int resolve_simple_types, int *real_type_found); -extern int value_pointed_to_offset (const struct value *value); -extern void set_value_pointed_to_offset (struct value *value, int val); -extern int value_embedded_offset (const struct value *value); -extern void set_value_embedded_offset (struct value *value, int val); +extern LONGEST value_pointed_to_offset (const struct value *value); +extern void set_value_pointed_to_offset (struct value *value, LONGEST val); +extern LONGEST value_embedded_offset (const struct value *value); +extern void set_value_embedded_offset (struct value *value, LONGEST val); /* For lval_computed values, this structure holds functions used to retrieve and set the value (or portions of the value). @@ -246,7 +246,7 @@ struct lval_funcs /* If non-NULL, this is used to determine whether the indicated bits of VALUE are a synthetic pointer. */ int (*check_synthetic_pointer) (const struct value *value, - int offset, int length); + LONGEST offset, int length); /* Return a duplicate of VALUE's closure, for use in a new value. This may simply return the same closure, if VALUE's is @@ -283,7 +283,7 @@ extern struct value *allocate_computed_value (struct type *type, Otherwise, return 1. */ extern int valprint_check_validity (struct ui_file *stream, struct type *type, - int embedded_offset, + LONGEST embedded_offset, const struct value *val); extern struct value *allocate_optimized_out_value (struct type *type); @@ -393,7 +393,7 @@ extern void mark_value_bytes_optimized_out (struct value *value, LENGTH bits as optimized out. */ extern void mark_value_bits_optimized_out (struct value *value, - int offset, int length); + LONGEST offset, LONGEST length); /* Set or return field indicating whether a variable is initialized or not, based on debugging information supplied by the compiler. @@ -476,7 +476,7 @@ extern struct value *coerce_array (struct value *value); extending for LENGTH bits are a synthetic pointer. */ extern int value_bits_synthetic_pointer (const struct value *value, - int offset, int length); + LONGEST offset, LONGEST length); /* Given a value, determine whether the contents bytes starting at OFFSET and extending for LENGTH bytes are available. This returns @@ -484,7 +484,7 @@ extern int value_bits_synthetic_pointer (const struct value *value, byte is unavailable. */ extern int value_bytes_available (const struct value *value, - int offset, int length); + LONGEST offset, LONGEST length); /* Given a value, determine whether the contents bits starting at OFFSET and extending for LENGTH bits are available. This returns @@ -492,7 +492,7 @@ extern int value_bytes_available (const struct value *value, bit is unavailable. */ extern int value_bits_available (const struct value *value, - int offset, int length); + LONGEST offset, LONGEST length); /* Like value_bytes_available, but return false if any byte in the whole object is unavailable. */ @@ -506,13 +506,13 @@ extern int value_entirely_unavailable (struct value *value); LENGTH bytes as unavailable. */ extern void mark_value_bytes_unavailable (struct value *value, - int offset, int length); + LONGEST offset, LONGEST length); /* Mark VALUE's content bits starting at OFFSET and extending for LENGTH bits as unavailable. */ extern void mark_value_bits_unavailable (struct value *value, - int offset, int length); + LONGEST offset, LONGEST length); /* Compare LENGTH bytes of VAL1's contents starting at OFFSET1 with LENGTH bytes of VAL2's contents starting at OFFSET2. @@ -567,9 +567,9 @@ extern void mark_value_bits_unavailable (struct value *value, after the inferior is gone, it works with const values. Therefore, this routine must not be called with lazy values. */ -extern int value_contents_eq (const struct value *val1, int offset1, - const struct value *val2, int offset2, - int length); +extern int value_contents_eq (const struct value *val1, LONGEST offset1, + const struct value *val2, LONGEST offset2, + LONGEST length); /* Read LENGTH addressable memory units starting at MEMADDR into BUFFER, which is (or will be copied to) VAL's contents buffer offset by @@ -578,7 +578,7 @@ extern int value_contents_eq (const struct value *val1, int offset1, memory is likewise unavailable. STACK indicates whether the memory is known to be stack memory. */ -extern void read_value_memory (struct value *val, int embedded_offset, +extern void read_value_memory (struct value *val, LONGEST embedded_offset, int stack, CORE_ADDR memaddr, gdb_byte *buffer, size_t length); @@ -614,17 +614,18 @@ extern LONGEST unpack_field_as_long (struct type *type, const gdb_byte *valaddr, int fieldno); extern int unpack_value_field_as_long (struct type *type, const gdb_byte *valaddr, - int embedded_offset, int fieldno, + LONGEST embedded_offset, int fieldno, const struct value *val, LONGEST *result); extern void unpack_value_bitfield (struct value *dest_val, - int bitpos, int bitsize, - const gdb_byte *valaddr, int embedded_offset, + LONGEST bitpos, LONGEST bitsize, + const gdb_byte *valaddr, + LONGEST embedded_offset, const struct value *val); extern struct value *value_field_bitfield (struct type *type, int fieldno, const gdb_byte *valaddr, - int embedded_offset, + LONGEST embedded_offset, const struct value *val); extern void pack_long (gdb_byte *buf, struct type *type, LONGEST num); @@ -683,12 +684,12 @@ extern struct value *default_read_var_value (struct symbol *var, extern struct value *allocate_value (struct type *type); extern struct value *allocate_value_lazy (struct type *type); -extern void value_contents_copy (struct value *dst, int dst_offset, - struct value *src, int src_offset, - int length); -extern void value_contents_copy_raw (struct value *dst, int dst_offset, - struct value *src, int src_offset, - int length); +extern void value_contents_copy (struct value *dst, LONGEST dst_offset, + struct value *src, LONGEST src_offset, + LONGEST length); +extern void value_contents_copy_raw (struct value *dst, LONGEST dst_offset, + struct value *src, LONGEST src_offset, + LONGEST length); extern struct value *allocate_repeat_value (struct type *type, int count); @@ -766,12 +767,12 @@ extern int find_overload_match (struct value **args, int nargs, extern struct value *value_field (struct value *arg1, int fieldno); -extern struct value *value_primitive_field (struct value *arg1, int offset, +extern struct value *value_primitive_field (struct value *arg1, LONGEST offset, int fieldno, struct type *arg_type); -extern struct type *value_rtti_indirect_type (struct value *, int *, int *, +extern struct type *value_rtti_indirect_type (struct value *, int *, LONGEST *, int *); extern struct value *value_full_object (struct value *, struct type *, int, @@ -870,8 +871,8 @@ extern void set_internalvar_string (struct internalvar *var, extern void clear_internalvar (struct internalvar *var); extern void set_internalvar_component (struct internalvar *var, - int offset, - int bitpos, int bitsize, + LONGEST offset, + LONGEST bitpos, LONGEST bitsize, struct value *newvalue); extern struct internalvar *lookup_only_internalvar (const char *name); @@ -951,7 +952,7 @@ extern struct value *value_x_unop (struct value *arg1, enum exp_opcode op, enum noside noside); extern struct value *value_fn_field (struct value **arg1p, struct fn_field *f, - int j, struct type *type, int offset); + int j, struct type *type, LONGEST offset); extern int binop_types_user_defined_p (enum exp_opcode op, struct type *type1, @@ -979,7 +980,7 @@ extern void release_value_or_incref (struct value *val); extern int record_latest_value (struct value *val); extern void modify_field (struct type *type, gdb_byte *addr, - LONGEST fieldval, int bitpos, int bitsize); + LONGEST fieldval, LONGEST bitpos, LONGEST bitsize); extern void type_print (struct type *type, const char *varstring, struct ui_file *stream, int show); @@ -1009,7 +1010,7 @@ extern void value_print_array_elements (struct value *val, extern struct value *value_release_to_mark (const struct value *mark); extern void val_print (struct type *type, const gdb_byte *valaddr, - int embedded_offset, CORE_ADDR address, + LONGEST embedded_offset, CORE_ADDR address, struct ui_file *stream, int recurse, const struct value *val, const struct value_print_options *options, -- cgit v1.1