diff mbox

PR 17520 -- structure offset wrong when 1/4 GB or greater

Message ID 1418954030-16797-1-git-send-email-dtaylor@emc.com
State New
Headers show

Commit Message

David Taylor Dec. 19, 2014, 1:53 a.m. UTC
This patch addresses PR 17520 -- structure offset wrong when 1/4 GB or
greater.

When calculating the offset of a structure member, GDB did the
calculation using 32 bit signed integers.  Because GDB uses this
same machinery for bit fields and for non bit fields, it does the
offset calcuation first in bits and then, if a byte offset is desired
it divides by 8.

This meant that if the offset was 1/4 G bytes or greater, the returned
value would be wrong.  Such large offsets were possible on 32-bit
architectures and even more so on 64-bit ones.

With this change GDB uses 64-bit integers.

Tested on x86-64 GNU/Linux with no regressions.

    gdb/ChangeLog:

	    * c-lang.h (cp_print_value_fields, cp_print_value_fields_rtti):
	    Modify prototypes to match new function definitions.
	    * c-valprint.c (c_value_print): Change local top from int to
	    LONGEST.
	    * cp-abi.c (baseclass_offset): Change embedded_offset from int to
	    LONGEST.  (value_rtti_type): Change top from int * to LONGEST *.
	    * cp-abi.h (value_rtti_type, baseclass_offset): Modify prototypes
	    to match new function definitions.
	    (struct cp_abi_ops): For field rtti_type, change type of arg top
	    from int * to LONGEST *.  For field baseclass_offset, change type
	    of arg embeeded_offset from int to LONGEST.
	    * cp-valprint.c (cp_print_value, cp_print_value_fields)
	    (cp_print_value_fields_rtti): Change type of function argument
	    offset from int to LONGEST.
	    (cp_print_value): Change locals thisoffset and boffset from int to
	    LONGEST.
	    * d-valprint.c (dynamic_array_type): Change local embedded_offset
	    from int to LONGEST.
	    * dwarf2loc.c (indirect_pieced_value): Change local bit_offset
	    from int to LONGEST.
	    * eval.c (evaluate_subexp_standard): Change local top from int to
	    LONGEST.
	    * extension-priv.h (struct extension_language_ops): For member
	    apply_val_pretty_printer, change type of arg embedded_offset from
	    int to LONGEST.
	    * extension.c (apply_ext_lang_val_pretty_printer): Change arg
	    embedded_offset from int to LONGEST.
	    * extension.h: Ditto.
	    * findvar.c (read_frame_register_value): Change types of offset
	    and reg_offset from int to LONGEST.
	    * gdbtypes.c (recursive_dump_type): In printfi_filtered call
	    change format for bitpos from %d to %lld and cast arg to long long
	    (arg is a LONGEST which could be either a long or a long long).
	    * gdbtypes.h (union field_location): Change member bitpos from int
	    to LONGEST.
	    * gnu-v2-abi.c (gnuv2_value_rtti_type): Change type of function
	    arg top from int * to LONGEST *.  (gnuv2_baseclass_offset): Change
	    type of arg embedded_offset from int to LONGEST; change local
	    field_offset from int to LONGEST.
	    * gnu-v3-abi.c (gnuv3_rtti_type): Change type of arg top_p from
	    int * to LONGEST *.  (gnuv3_baseclass_offset): Change type of arg
	    embedded_offset from int to LONGEST.
	    * go-valprint.c (print_go_string): Change type of arg
	    embedded_offset from int to LONGEST.
	    * scm-pretty-print.c (gdbscm_apply_val_pretty_printer): Change
	    type of arg embedded_offset from int to LONGEST.
	    * jv-valprint.c (java_print_value_fields): Change type of arg
	    offset from int to LONGEST.
	    * opencl-lang.c (lval_func_read): Change locals offset and elsize
	    from int to LONGEST.  (lval_func_write): Change type of locals
	    offset and elsize from int to LONGEST.
	    * p-lang.h (pascal_object_print_value_fields): Modify prototype to
	    match new function definition.
	    * p-valprint.c (pascal_object_print_value): Change type arg offset
	    from int to LONGEST; change locals boffset and thisoffset from int
	    to LONGEST. (pascal_object_print_value)
	    (pascal_object_print_value_fields): Change type arg offset from
	    int to LONGEST.
	    * python/py-prettyprint.c (gdbpy_apply_val_pretty_printer): Change
	    type of arg embedded_offset from int to LONGEST.
	    * python/python-internal.h (gdbpy_apply_val_pretty_printer):
	    Modify prototype to match new function definition.
	    * spu-tdep.c (spu_value_from_register): Change local len from int
	    to LONGEST.
	    * typeprint.c (whatis_exp): Change type of local top from int to
	    LONGEST.
	    * valarith.c (value_subscripted_rvalue): Change type of local
	    elt_offs from unsigned int to ULONGEST.
	    * valops.c (search_struct_method): Change type of arg offset from
	    int to LONGEST.  (find_method_list): Change type of offset from
	    int to LONGEST; change type of arg boffset from int * to
	    LONGEST *.  (value_cast_structs): Change type of local top from
	    int to LONGEST.  (dynamic_cast_check_1): Change type of arg
	    embedded_offset from int to LONGEST; change type of local offset
	    from int to LONGEST.  (dynamic_cast_check_2): Change type of arg
	    embedded_offset from int to LONGEST; change type of local offset
	    from int to LONGEST.  (value_dynamic_cast): Change type of local
	    top from int to LONGEST. (read_value_memory): Change type of arg
	    embedded_offset from int to LONGEST.  (value_assign): Change type
	    of local offset from int to LONGEST.  (value_arry): Change local
	    typelength from unsigned int to ULONGEST.  (update_search_result):
	    Change type of arg last_boffset from int * to
	    LONGEST *.  (do_search_struct_field): Change type of arg
	    last_boffset from int * to LONGEST *; change local new_offset from
	    int to LONGEST; change local boffset from int to
	    LONGEST.  (search_struct_field): Change local boffset from int to
	    LONGEST.  (seach_struct_method): Change arg offset from int to
	    LONGEST; change locals base_offset and this_offset from int to
	    LONGEST.  (find_method_list): Change arg offset from int to
	    LONGEST; change arg boffset from int * to LONGEST *; change local
	    base_offset from int to LONGEST.  (value_find_oload_method_list):
	    Change arg offset from int to LONGEST; change arg boffset from
	    int * to LONGEST *.  (find_overload_match): Change local boffset
	    from int to LONGEST.  (value_rtti_indirect_type): change arg top
	    from int * to LONGEST *.  (value_full_object): Change type of
	    local topt from int to LONGEST.
	    * valprint.c (valprint_check_validity): Change type of arg
	    embedded_offset from int to LONGEST.  (val_print): Ditto.
	    (val_print_scalar_formatted): Ditto.  (val_print_arry_elements):
	    Ditto.
	    * valprint.h (val_print_array_elements, val_print_scalar_formatted):
	    Modify prototypes to match new function definitions.
	    * value.c (struct range): Change members offset and length from
	    int to LONGEST.
	    (ranges_overlap): Change all args from int to LONGEST.
	    (ranges_contain): Change args offset and length from int to
	    LONGEST; change local i from int to LONGEST.
	    (struct value): Change members offset, bitsize, bitpos,
	    embedded_offset, and pointed_to_offset from int to LONGEST.
	    (value_bits_available): Change args offset and length from int to
	    LONGEST.
	    (value_bytes_available): Ditto.  (mark_value_bits_unavailable):
	    Ditto.  (mark_value_bytes_unavailable):
	    Ditto.  (find_first_range_overlap): Ditto.  (value_offset): Change
	    return type from int to LONGEST.  (set_value_offset): Change arg
	    offset from int to LONGEST.  (value_bitpos): Change return type
	    from int to LONGEST.  (set_value_bitpos): Change arg bit from int
	    to LONGEST.  (value_bitsize): Change return type from int to
	    LONGEST.  (set_value_bitsize): Change arg bit from int to LONGEST.
	    value_contents_copy_raw): Change args dst_offset, src_offset, and
	    length from int to LONGEST; change locals src_bit_offset,
	    dst_bit_offset, and bit_length from int to
	    LONGEST.  (value_contents_copy): Change args dst_offset,
	    src_offset, and length from int to
	    LONGEST.  (value_bits_synthetic_pointer): Change args offset and
	    length from int to LONGEST.  (value_embedded_offset); Change
	    return type from int to LONGEST.  (set_value_embedded_offset):
	    Change arg val from int to LONGEST.  (value_pointed_to_offset);
	    Change return type from int to
	    LONGEST.  (set_value_pointed_to_offset): Change arg val from int
	    to LONGEST.  (set_internalvar_component): Change args offset,
	    bitpos, bitsize from int to LONGEST.  (value_primitive_field):
	    Change arg offset from int to LONGEST; change locals bitpos,
	    container_bitsize, boffset from int to LONGEST.  (value_fn_field):
	    Change arg offset from int to LONGEST.  (unpack_bits_as_long):
	    Change locals bytes_read, read_offset from int to LONGEST.
	    (unpack_value_field_as_long): Change arg embedded_offset from int
	    to LONGEST.  (unpack_value_bitfield): Change arg embedded_offset
	    from int to LONGEST.  (value_field_bitfield): Change arg
	    embedded_offset from int to LONGEST.  (modify_field): Change args
	    bitpos and bitsize from int to LONGEST; change local bytesize from
	    int to LONGEST; modify warning to use %lld rather than %d and cast
	    corresponding arg to long long int.  (pack_long): Change local len
	    from int to LONGEST.  (pack_usigned_long): Ditto.
	    * value.h (value_bitsize, set_value_bitsize, value_bitpos)
	    (set_value_bitpos, value_offset, set_value_offset)
	    (value_pointed_to_offset, set_value_pointed_to_offset)
	    (value_embedded_offset, set_value_embedded_offset)
	    (valprint_check_validity, value_bits_synthetic_pointer)
	    (value_bytes_available, value_bits_available)
	    (mark_value_bytes_unavailable, mark_value_bits_unavailable)
	    (read_value_memory, unpack_value_field_as_long, value_bitfield)
	    (value_field_bitfield, value_contents_copy)
	    (value_contents_copy_raw, value_primitive_field)
	    (value_rtti_indirect_type, set_internalvar_component)
	    (value_fn_field, modify_field, val_print): Modify prototypes to
	    match new definitions.

    gdb/testsuite/ChangeLog:

	    * gdb.base/Makefile.in (EXECUTABLES): Add offsets to the list.
	    * gdb.base/offsets.exp: New file.  Test large member offsets.
	    * gdb.base/offsets.c: New file.  Used in testing large member
	    offsets.
---
 gdb/c-lang.h                       |  4 +-
 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                    |  3 +-
 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/scm-pretty-print.c       |  2 +-
 gdb/jv-valprint.c                  |  2 +-
 gdb/opencl-lang.c                  |  8 ++--
 gdb/p-lang.h                       |  2 +-
 gdb/p-valprint.c                   | 10 ++--
 gdb/python/py-prettyprint.c        |  2 +-
 gdb/python/python-config.py        |  2 +-
 gdb/python/python-internal.h       |  2 +-
 gdb/spu-tdep.c                     |  2 +-
 gdb/testsuite/gdb.base/Makefile.in |  2 +-
 gdb/testsuite/gdb.base/offsets.c   | 11 +++++
 gdb/testsuite/gdb.base/offsets.exp | 51 ++++++++++++++++++++
 gdb/typeprint.c                    |  2 +-
 gdb/valarith.c                     |  2 +-
 gdb/valops.c                       | 64 +++++++++++++------------
 gdb/valprint.c                     |  8 ++--
 gdb/valprint.h                     |  4 +-
 gdb/value.c                        | 98 +++++++++++++++++++-------------------
 gdb/value.h                        | 66 ++++++++++++-------------
 36 files changed, 239 insertions(+), 171 deletions(-)
 create mode 100644 gdb/testsuite/gdb.base/offsets.c
 create mode 100644 gdb/testsuite/gdb.base/offsets.exp

Comments

Eli Zaretskii Dec. 19, 2014, 9:07 a.m. UTC | #1
> From: David Taylor <dtaylor@emc.com>
> Cc: David Taylor <dtaylor@emc.com>
> Date: Thu, 18 Dec 2014 20:53:50 -0500
> 
> This patch addresses PR 17520 -- structure offset wrong when 1/4 GB or
> greater.
> 
> When calculating the offset of a structure member, GDB did the
> calculation using 32 bit signed integers.  Because GDB uses this
> same machinery for bit fields and for non bit fields, it does the
> offset calcuation first in bits and then, if a byte offset is desired
> it divides by 8.
> 
> This meant that if the offset was 1/4 G bytes or greater, the returned
> value would be wrong.  Such large offsets were possible on 32-bit
> architectures and even more so on 64-bit ones.
> 
> With this change GDB uses 64-bit integers.

I see you use %lld to print the 64-bit integer quantities, but I think
you should use inttypes.h's PRId64 instead.  At least MinGW32 use the
Windows runtime, which doesn't understand %lld, AFAIK.  And using
inttypes.h's macros is more portable anyway.

Thanks.
Joel Brobecker Dec. 19, 2014, 12:40 p.m. UTC | #2
> I see you use %lld to print the 64-bit integer quantities, but I think
> you should use inttypes.h's PRId64 instead.  At least MinGW32 use the
> Windows runtime, which doesn't understand %lld, AFAIK.  And using
> inttypes.h's macros is more portable anyway.

That's a really good point.

Since these are LONGEST/ULONGEST, let's use plongest and pulongest
instead.
Joel Brobecker Dec. 20, 2014, 6:27 p.m. UTC | #3
On Thu, Dec 18, 2014 at 08:53:50PM -0500, David Taylor wrote:
> This patch addresses PR 17520 -- structure offset wrong when 1/4 GB or
> greater.
> 
> When calculating the offset of a structure member, GDB did the
> calculation using 32 bit signed integers.  Because GDB uses this
> same machinery for bit fields and for non bit fields, it does the
> offset calcuation first in bits and then, if a byte offset is desired
> it divides by 8.
> 
> This meant that if the offset was 1/4 G bytes or greater, the returned
> value would be wrong.  Such large offsets were possible on 32-bit
> architectures and even more so on 64-bit ones.
> 
> With this change GDB uses 64-bit integers.

FTR, increasing type size of field bitpos here does NOT increase
the overall size of struct main_type, because it's part of a union
where other fields are already a LONGEST. So, memory-allocation-wise,
we should be OK.

> Tested on x86-64 GNU/Linux with no regressions.
> 
>     gdb/ChangeLog:
> 
> 	    * c-lang.h (cp_print_value_fields, cp_print_value_fields_rtti):
> 	    Modify prototypes to match new function definitions.
[...]
> 	    match new definitions.
> 
>     gdb/testsuite/ChangeLog:
> 
> 	    * gdb.base/Makefile.in (EXECUTABLES): Add offsets to the list.
> 	    * gdb.base/offsets.exp: New file.  Test large member offsets.
> 	    * gdb.base/offsets.c: New file.  Used in testing large member
> 	    offsets.

A general comment regarding ChangeLog formatting: when you modify
multiple functions in a given file, and the description of the change
for each function is different, you correctly put the next function's
name between '(' and ')', but you also need to do it on the next line.
Eg, instead of...

        * gnu-v3-abi.c (gnuv3_rtti_type): Change type of arg top_p from
        int * to LONGEST *.  (gnuv3_baseclass_offset): Change type of arg

... write...

        * gnu-v3-abi.c (gnuv3_rtti_type): Change type of arg top_p from
        int * to LONGEST *.
        (gnuv3_baseclass_offset): Change type of arg [...]

Also, do not provide any info about "why" you make a change. If you
feel the need to provide that info, this needs to be in the code
rather than in the ChangeLog. One example (moot for this patch, but
a good example nonetheless):

        * gdbtypes.c (recursive_dump_type): In printfi_filtered call
        change format for bitpos from %d to %lld and cast arg to long long
        (arg is a LONGEST which could be either a long or a long long).

Similarly, for the testsuite/ChangeLog entry, you can just say "New
file.".

But, for your patch in particular, enumerating every single change
that is a direct consequence of the change in struct main_type just
makes for a fairly useless ChangeLog entry because it is nearly
unreadable. For cases like this, we are allowed to simplify a bit
the ChangeLog entry. Perhaps you could use something like:

        * cp-abi.c: Changeg all parameters and variables used as struct
        field offsets from int to LONGEST.
        * cp-abi.h, cp-valprint.c, extension.c, extension.h,
        otherfile.h, otherfile.c, something.h, something.c,
        etc.c, [...]: Likewise.

For those files where you did make more than this mechanical change,
just document them separately. For instance:

**** FIXME ****

>  	printfi_filtered (spaces + 2,
> -			  "[%d] bitpos %d bitsize %d type ",
> -			  idx, TYPE_FIELD_BITPOS (type, idx),
> +			  "[%d] bitpos %lld bitsize %d type ",
> +			  idx, (long long int)TYPE_FIELD_BITPOS (type, idx),

As discussed earlier in another email, please use %s and plongest
instead. (I will skip other instances of this issue, but can you
take care of all other instances, please? - thank you!).


>  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)

This line is now too long - can you split it? Make sure that you use
tabs + spaces when doing so, not just spaces (not my choice, but the
current convention at the moment).

> diff --git a/gdb/testsuite/gdb.base/offsets.c b/gdb/testsuite/gdb.base/offsets.c
> new file mode 100644
> index 0000000..bf1e7ad
> --- /dev/null
> +++ b/gdb/testsuite/gdb.base/offsets.c
> @@ -0,0 +1,11 @@
> +struct big_struct

Can you add a copyright header to that file, please? All files should
have a copyright header unless there is a compelling reason whe cannot
add it.

> +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)"
> +    }
> +    timeout {
> +	fail "$test (timeout)"
> +    }

The "timeout" block is unnecessary. gdb_test_multiple adds it for you
(among many many other things which are the reasons why we ask people
use use either gdb_test or gdb_test_multiple rather than gdb_expect).

> +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)
> +	pass "$test ($addr2)"
> +    }
> +    timeout {
> +	fail "$test (timeout)"
> +    }

Same here... but see below...

> +}
> +
> +if {[expr $addr2 - $addr1] == [expr 0x10000000 + 16]} {
> +    pass "big offsets"
> +} else {
> +    fail "big offsets"

You can do a little better: Compute the expected address for addr2,
and make that the expected address in the second test's expected
output.  That way, the second test will fail, as it should, if
the feature regresses.

> --- a/gdb/valarith.c
> +++ b/gdb/valarith.c
> @@ -193,7 +193,7 @@ 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 (elt_type);
> -  unsigned int elt_offs = elt_size * longest_to_int (index - lowerbound);
> +  ULONGEST elt_offs = elt_size * longest_to_int (index - lowerbound);

I think you may have an issue, here, but I might be wrong, as my C foo
is not that good. elt_size is declared as an int, and longest_to_int
also returns an int, so I think the multiplication might be done as
int, and only then is the promotion to ULONGEST performed, I think.
To me, it'd be better to declare elt_size as ULONGEST, and then remove
the call to longest_to_int.

> -      int offset = baseclass_offset (search_type, i, valaddr, embedded_offset,
> -				     address, val);
> +      LONGEST offset = baseclass_offset (search_type, i, valaddr, embedded_offset,
> +					 address, val);

This line is now too long. A number of other functions you changed
in this file have the same problem. Can you fix those as well?

>  int
> -value_bits_available (const struct value *value, int offset, int length)
> +value_bits_available (const struct value *value, LONGEST offset, LONGEST length)

Ditto.

>  int
> -value_bytes_available (const struct value *value, int offset, int length)
> +value_bytes_available (const struct value *value, LONGEST offset, LONGEST length)

Ditto.

>  void
> -mark_value_bits_unavailable (struct value *value, int offset, int length)
> +mark_value_bits_unavailable (struct value *value, LONGEST offset, LONGEST length)

Likewise.

>  void
> -mark_value_bytes_unavailable (struct value *value, int offset, int length)
> +mark_value_bytes_unavailable (struct value *value, LONGEST offset, LONGEST length)

Ditto.

I hope I didn't miss any other case like that, can you double-check me?

>  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)

One more, different file...

> @@ -3325,7 +3325,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 %lld bits."), (long long int)bitsize);

Same as before, use %s and plongest...

>  extern void unpack_value_bitfield (struct value *dest_val,
>  				   int bitpos, int bitsize,
> -				   const gdb_byte *valaddr, int embedded_offset,
> +				   const gdb_byte *valaddr, LONGEST embedded_offset,
>  				   const struct value *val);

Line too long...

That's it! I expect the next iteration of the patch will get approved!
David Taylor Jan. 12, 2015, 4:53 p.m. UTC | #4
Joel Brobecker <brobecker@adacore.com> wrote:

> On Thu, Dec 18, 2014 at 08:53:50PM -0500, David Taylor wrote:

> >     gdb/ChangeLog:
> >
> >           * c-lang.h (cp_print_value_fields, cp_print_value_fields_rtti):
> >           Modify prototypes to match new function definitions.
> [...]
> >           match new definitions.
> >
> >     gdb/testsuite/ChangeLog:
> >
> >           * gdb.base/Makefile.in (EXECUTABLES): Add offsets to the list.
> >           * gdb.base/offsets.exp: New file.  Test large member offsets.
> >           * gdb.base/offsets.c: New file.  Used in testing large member
> >           offsets.
> 
> A general comment regarding ChangeLog formatting: when you modify
> multiple functions in a given file, and the description of the change
> for each function is different, you correctly put the next function's
> name between '(' and ')', but you also need to do it on the next line.
> Eg, instead of...
> 
>         * gnu-v3-abi.c (gnuv3_rtti_type): Change type of arg top_p from
>         int * to LONGEST *.  (gnuv3_baseclass_offset): Change type of arg
> 
> ... write...
> 
>         * gnu-v3-abi.c (gnuv3_rtti_type): Change type of arg top_p from
>         int * to LONGEST *.
>         (gnuv3_baseclass_offset): Change type of arg [...]

Okay.

> Also, do not provide any info about "why" you make a change. If you
> feel the need to provide that info, this needs to be in the code
> rather than in the ChangeLog. One example (moot for this patch, but
> a good example nonetheless):
> 
>         * gdbtypes.c (recursive_dump_type): In printfi_filtered call
>         change format for bitpos from %d to %lld and cast arg to long long
>         (arg is a LONGEST which could be either a long or a long long).
> 
> Similarly, for the testsuite/ChangeLog entry, you can just say "New
> file.".
> 
> But, for your patch in particular, enumerating every single change
> that is a direct consequence of the change in struct main_type just
> makes for a fairly useless ChangeLog entry because it is nearly
> unreadable. For cases like this, we are allowed to simplify a bit
> the ChangeLog entry. Perhaps you could use something like:
> 
>         * cp-abi.c: Changeg all parameters and variables used as struct
>         field offsets from int to LONGEST.
>         * cp-abi.h, cp-valprint.c, extension.c, extension.h,
>         otherfile.h, otherfile.c, something.h, something.c,
>         etc.c, [...]: Likewise.

I've used ditto / likewise in the past, but only when saying,
effectively, what was done with this function is the same as what was
done with that previous function, never at the file level.  In fact, I
thought that listing all the affected functions was a hard requirement.
I also, and I wrote it, found the ChangeLog to be pretty much
unreadable.

> For those files where you did make more than this mechanical change,
> just document them separately. For instance:
> 
> **** FIXME ****

I think that 99% or close to it of the changes fall into one of the
variants of:

    Change { function parameter | local variable } <foo> from
    { int to LONGEST | unsigned int to ULONGEST | int * to LONGEST * }

The two exceptions that come to mind (without scanning the diff for
verification) are:

    . the printing related changes
    . the testsuite related changes

> >       printfi_filtered (spaces + 2,
> > -                       "[%d] bitpos %d bitsize %d type ",
> > -                       idx, TYPE_FIELD_BITPOS (type, idx),
> > +                       "[%d] bitpos %lld bitsize %d type ",
> > +                       idx, (long long int)TYPE_FIELD_BITPOS (type, idx),
> 
> As discussed earlier in another email, please use %s and plongest
> instead. (I will skip other instances of this issue, but can you
> take care of all other instances, please? - thank you!).

Okay, will do.

> >  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)
> 
> This line is now too long - can you split it? Make sure that you use
> tabs + spaces when doing so, not just spaces (not my choice, but the
> current convention at the moment).

I think I've caught all of these.  Should be fixed in the next posting.

> > diff --git a/gdb/testsuite/gdb.base/offsets.c b/gdb/testsuite/gdb.base/offsets.c
> > new file mode 100644
> > index 0000000..bf1e7ad
> > --- /dev/null
> > +++ b/gdb/testsuite/gdb.base/offsets.c
> > @@ -0,0 +1,11 @@
> > +struct big_struct
> 
> Can you add a copyright header to that file, please? All files should
> have a copyright header unless there is a compelling reason whe cannot
> add it.

Done.

The file is short enough that I'm not sure that it really is
copyrightable -- but, the lawyers can argue that one, I don't care.  I
noticed that most of the testsuite *.c files, at least in gdb.base do
not have copyright notices.

> > +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)"
> > +    }
> > +    timeout {
> > +     fail "$test (timeout)"
> > +    }
> 
> The "timeout" block is unnecessary. gdb_test_multiple adds it for you
> (among many many other things which are the reasons why we ask people
> use use either gdb_test or gdb_test_multiple rather than gdb_expect).

I found an example that did something similar to what I wanted and
copied it.  It had the timeout within the gdb_test_multiple, so that is
what I did, too.

I try to do as little as possible in Tcl as every time I do anything
significant, by the time I'm done I'm remembering just how much I hate
writing Tcl code.

I'll modify it to remove the timeouts.

> > +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)
> > +     pass "$test ($addr2)"
> > +    }
> > +    timeout {
> > +     fail "$test (timeout)"
> > +    }
> 
> Same here... but see below...
> 
> > +}
> > +
> > +if {[expr $addr2 - $addr1] == [expr 0x10000000 + 16]} {
> > +    pass "big offsets"
> > +} else {
> > +    fail "big offsets"
> 
> You can do a little better: Compute the expected address for addr2,
> and make that the expected address in the second test's expected
> output.  That way, the second test will fail, as it should, if
> the feature regresses.

I'll look into it.

> > --- a/gdb/valarith.c
> > +++ b/gdb/valarith.c
> > @@ -193,7 +193,7 @@ 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 (elt_type);
> > -  unsigned int elt_offs = elt_size * longest_to_int (index - lowerbound);
> > +  ULONGEST elt_offs = elt_size * longest_to_int (index - lowerbound);
> 
> I think you may have an issue, here, but I might be wrong, as my C foo
> is not that good. elt_size is declared as an int, and longest_to_int
> also returns an int, so I think the multiplication might be done as
> int, and only then is the promotion to ULONGEST performed, I think.
> To me, it'd be better to declare elt_size as ULONGEST, and then remove
> the call to longest_to_int.

Will do.

> > -      int offset = baseclass_offset (search_type, i, valaddr, embedded_offset,
> > -                                  address, val);
> > +      LONGEST offset = baseclass_offset (search_type, i, valaddr, embedded_offset,
> > +                                      address, val);
> 
> This line is now too long. A number of other functions you changed
> in this file have the same problem. Can you fix those as well?

I think I've caught them all.

[...]

> I hope I didn't miss any other case like that, can you double-check me?

Will do.

> That's it! I expect the next iteration of the patch will get approved!

Good to hear.  Thanks for taking the time to review it.  I expect to
post an updated version later this week, possibly later today, but I
won't promise the latter.

> --
> Joel

David
Joel Brobecker Jan. 13, 2015, 9:30 a.m. UTC | #5
> > Can you add a copyright header to that file, please? All files should
> > have a copyright header unless there is a compelling reason whe cannot
> > add it.
> 
> Done.
> 
> The file is short enough that I'm not sure that it really is
> copyrightable -- but, the lawyers can argue that one, I don't care.

Indeed, some files might be small enough as to not be legally
significant in terms of copyright issues. But rather than introduce
a human decision into the mix, it's just easier to add copyright
headers everywhere. And we have the script which updates all copyright
notices everywhere at the start of the year which tells us if new files
have been introduced without a copyright header.

> I noticed that most of the testsuite *.c files, at least in gdb.base
> do not have copyright notices.

That is a mistake that we should be correcting, but it usually takes
someone seeing the error, then digging through history to figure out
the copyright range, and then adding it.

> I found an example that did something similar to what I wanted and
> copied it.  It had the timeout within the gdb_test_multiple, so that is
> what I did, too.

For TCL, I do the same, but unfortunately, there is a lot of old
baggage, as you've discovered. We try to fix this too, as we see it,
but it's a nearly endless source of work, so progress is usually, er,
slow (understatement).

In case you haven't seen it yet, there is a cookbook:
http://sourceware.org/gdb/wiki/GDBTestcaseCookbook

If some recipes are missing, we'd be glad to add to it.

> I try to do as little as possible in Tcl as every time I do anything
> significant, by the time I'm done I'm remembering just how much I hate
> writing Tcl code.

+1.
diff mbox

Patch

diff --git a/gdb/c-lang.h b/gdb/c-lang.h
index 5a2f878..f2a2987 100644
--- a/gdb/c-lang.h
+++ b/gdb/c-lang.h
@@ -120,14 +120,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-valprint.c b/gdb/c-valprint.c
index c61e18e..c732292 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -460,7 +460,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 7055acb..3b029c3 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)
 {
   volatile struct gdb_exception ex;
@@ -104,7 +104,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;
   volatile struct gdb_exception e;
diff --git a/gdb/cp-abi.h b/gdb/cp-abi.h
index 7d4b7f3..25115fe 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 8f456bf..757e99a 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,
@@ -414,7 +414,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,
@@ -431,7 +431,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,
@@ -456,7 +457,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,
@@ -466,7 +467,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)
@@ -480,7 +481,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;
       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 788b3d5..6cb8aed 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 fd5856c..3278c1c 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -2009,7 +2009,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;
 
diff --git a/gdb/eval.c b/gdb/eval.c
index c2ab879..1e913b4 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1887,7 +1887,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 9237273..dbf620f 100644
--- a/gdb/extension-priv.h
+++ b/gdb/extension-priv.h
@@ -175,7 +175,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 93359c5..64b2c40a 100644
--- a/gdb/extension.c
+++ b/gdb/extension.c
@@ -480,7 +480,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 c08d98d..108234b 100644
--- a/gdb/extension.h
+++ b/gdb/extension.h
@@ -217,7 +217,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 512c572..a90c8b0 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -659,8 +659,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 (check_typedef (value_type (value)));
 
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 0048f6a..303a7aa 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -3941,8 +3941,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 %lld bitsize %d type ",
+			  idx, (long long int)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 b4d4f3a..4304173 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -597,7 +597,7 @@  struct main_type
 	   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 5b73c92..6b96915 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 d673e77..9aba18e 100644
--- a/gdb/gnu-v3-abi.c
+++ b/gdb/gnu-v3-abi.c
@@ -275,7 +275,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));
@@ -432,7 +432,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 d7026a4..4446b74 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/scm-pretty-print.c b/gdb/guile/scm-pretty-print.c
index 5c94c78..5b93535 100644
--- a/gdb/guile/scm-pretty-print.c
+++ b/gdb/guile/scm-pretty-print.c
@@ -955,7 +955,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 91b45e2..0f5be63 100644
--- a/gdb/jv-valprint.c
+++ b/gdb/jv-valprint.c
@@ -265,7 +265,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 7af3632..0567eb0 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;
diff --git a/gdb/p-lang.h b/gdb/p-lang.h
index ea2d37c..7827bd6 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 63f6222..4b2f378 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -467,7 +467,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 *,
@@ -526,7 +526,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,
@@ -697,7 +697,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,
@@ -720,11 +720,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;
       volatile struct gdb_exception ex;
       int skip = 0;
 
diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c
index 35579fb..4fd35a9 100644
--- a/gdb/python/py-prettyprint.c
+++ b/gdb/python/py-prettyprint.c
@@ -686,7 +686,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-config.py b/gdb/python/python-config.py
index c2b2969..f18cef2 100644
--- a/gdb/python/python-config.py
+++ b/gdb/python/python-config.py
@@ -59,11 +59,11 @@  for opt in opt_flags:
 
     elif opt in ('--libs', '--ldflags'):
         libs = []
+        libs.append('-lpython'+pyver + abiflags)
         if getvar('LIBS') is not None:
             libs.extend(getvar('LIBS').split())
         if getvar('SYSLIBS') is not None:
             libs.extend(getvar('SYSLIBS').split())
-        libs.append('-lpython'+pyver + abiflags)
         # add the prefix/lib/pythonX.Y/config dir, but only if there is no
         # shared library in prefix/lib/.
         if opt == '--ldflags':
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
index 544fe93..4787d4e 100644
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -313,7 +313,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 fe8f1d9..1646ce5 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/gdb.base/Makefile.in b/gdb/testsuite/gdb.base/Makefile.in
index dda3169..d828d35 100644
--- a/gdb/testsuite/gdb.base/Makefile.in
+++ b/gdb/testsuite/gdb.base/Makefile.in
@@ -43,7 +43,7 @@  EXECUTABLES = a2-run advance all-types annota1 annota1-watch_thread_num \
 	watch-vfork watch_thread_num watchpoint watchpoint-cond-gone \
 	watchpoint-hw watchpoint-hw-hit-once watchpoint-solib watchpoints \
 	wchar whatis whatis-exp catch-syscall \
-	pr10179 gnu_vector
+	pr10179 gnu_vector offsets
 
 MISCELLANEOUS = coremmap.data dprintf-pendshr.sl ../foobar.baz fixsectshr.sl \
 	pendshr.sl shreloc1.sl shreloc2.sl twice-tmp.c \
diff --git a/gdb/testsuite/gdb.base/offsets.c b/gdb/testsuite/gdb.base/offsets.c
new file mode 100644
index 0000000..bf1e7ad
--- /dev/null
+++ b/gdb/testsuite/gdb.base/offsets.c
@@ -0,0 +1,11 @@ 
+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..f7587943
--- /dev/null
+++ b/gdb/testsuite/gdb.base/offsets.exp
@@ -0,0 +1,51 @@ 
+# Test big offsets
+
+# Copyright (c) 2014 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 <http://www.gnu.org/licenses/>.
+
+standard_testfile offsets.c
+
+if { [prepare_for_testing ${testfile}.exp $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)"
+    }
+    timeout {
+	fail "$test (timeout)"
+    }
+}
+
+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)
+	pass "$test ($addr2)"
+    }
+    timeout {
+	fail "$test (timeout)"
+    }
+}
+
+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 0650177..859aca8 100644
--- a/gdb/typeprint.c
+++ b/gdb/typeprint.c
@@ -402,7 +402,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 154629b..f987178 100644
--- a/gdb/valarith.c
+++ b/gdb/valarith.c
@@ -193,7 +193,7 @@  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 (elt_type);
-  unsigned int elt_offs = elt_size * longest_to_int (index - lowerbound);
+  ULONGEST elt_offs = elt_size * longest_to_int (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 2f81a59..03656d1 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,8 @@  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 +683,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 +693,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 +724,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 +956,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)
 {
@@ -1028,7 +1030,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?
 
@@ -1115,7 +1117,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;
@@ -1596,7 +1598,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;
 
@@ -1771,7 +1773,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)
@@ -1795,10 +1797,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;
@@ -1845,7 +1847,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
@@ -1884,7 +1886,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))
 	{
@@ -1961,7 +1963,7 @@  search_struct_field (const char *name, struct value *arg1, int offset,
 		     struct type *type, int looking_for_baseclass)
 {
   struct value *result = NULL;
-  int boffset = 0;
+  LONGEST boffset = 0;
 
   do_search_struct_field (name, arg1, offset, type, looking_for_baseclass,
 			  &result, &boffset, type);
@@ -1978,7 +1980,7 @@  search_struct_field (const char *name, struct value *arg1, int offset,
 
 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;
@@ -2042,8 +2044,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))
 	{
@@ -2278,10 +2280,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;
@@ -2338,7 +2340,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))
 	{
@@ -2378,10 +2380,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;
 
@@ -2492,7 +2494,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);
 
@@ -3590,7 +3592,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;
   struct type *type, *real_type, *target_type;
@@ -3645,7 +3647,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 b995304..facb0a3 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -298,7 +298,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)
 {
   CHECK_TYPEDEF (type);
@@ -734,7 +734,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,
@@ -956,7 +956,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,
@@ -1615,7 +1615,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 6698247..c2a4391 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 *,
@@ -129,7 +129,7 @@  extern void val_print_type_code_flags (struct type *type,
 				       struct ui_file *stream);
 
 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 3a9c3a9..154adbf 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
      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
@@ -341,7 +341,7 @@  struct 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);
 
@@ -349,7 +349,7 @@  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,
@@ -584,13 +584,13 @@  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,
@@ -604,7 +604,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;
@@ -1028,35 +1028,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;
 }
@@ -1245,12 +1245,12 @@  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)
 {
   range_s *r;
   int i;
-  int src_bit_offset, dst_bit_offset, bit_length;
+  LONGEST src_bit_offset, dst_bit_offset, bit_length;
 
   /* A lazy DST would make that this copy operation useless, since as
      soon as DST's contents were un-lazied (by a later value_contents
@@ -1292,8 +1292,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);
@@ -1374,7 +1374,7 @@  mark_value_bits_optimized_out (struct value *value, int offset, int 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)
@@ -1384,26 +1384,26 @@  value_bits_synthetic_pointer (const struct value *value,
 								  length);
 }
 
-int
+LONGEST
 value_embedded_offset (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 (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;
 }
@@ -2243,8 +2243,8 @@  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;
 
@@ -2948,7 +2948,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;
@@ -2976,8 +2976,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);
@@ -2998,7 +2998,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))
@@ -3075,7 +3075,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);
@@ -3151,8 +3151,8 @@  unpack_bits_as_long (struct type *field_type, const gdb_byte *valaddr,
   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.  */
@@ -3201,7 +3201,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);
@@ -3245,7 +3245,7 @@  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,
+		       const gdb_byte *valaddr, LONGEST embedded_offset,
 		       const struct value *val)
 {
   enum bfd_endian byte_order;
@@ -3283,7 +3283,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);
@@ -3304,12 +3304,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;
@@ -3325,7 +3325,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 %lld bits."), (long long int)bitsize);
 
       /* Truncate it, otherwise adjoining fields may be corrupted.  */
       fieldval &= mask;
@@ -3353,7 +3353,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);
@@ -3387,7 +3387,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 a8c33fb..c1839ca 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -108,15 +108,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
@@ -131,8 +131,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
@@ -201,10 +201,10 @@  extern struct type *value_actual_type (struct value *value,
 				       int resolve_simple_types,
 				       int *real_type_found);
 
-extern int value_pointed_to_offset (struct value *value);
-extern void set_value_pointed_to_offset (struct value *value, int val);
-extern int value_embedded_offset (struct value *value);
-extern void set_value_embedded_offset (struct value *value, int val);
+extern LONGEST value_pointed_to_offset (struct value *value);
+extern void set_value_pointed_to_offset (struct value *value, LONGEST val);
+extern LONGEST value_embedded_offset (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).
@@ -279,7 +279,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);
@@ -472,7 +472,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
@@ -480,7 +480,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
@@ -488,7 +488,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.  */
@@ -502,13 +502,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.
@@ -574,7 +574,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);
 
@@ -610,17 +610,17 @@  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,
+				   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);
@@ -677,12 +677,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);
 
@@ -760,12 +760,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,
@@ -864,8 +864,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);
@@ -945,7 +945,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,
@@ -973,7 +973,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);
@@ -1003,7 +1003,7 @@  extern void value_print_array_elements (struct value *val,
 extern struct value *value_release_to_mark (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,