This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: RFA 0/2 fix for bug with large structure offsets
- From: David Taylor <dtaylor at usendtaylorx2l dot lss dot emc dot com>
- To: "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>
- Date: Thu, 11 Dec 2014 15:26:09 -0500
- Subject: Re: RFA 0/2 fix for bug with large structure offsets
- Authentication-results: sourceware.org; auth=none
- References: <18829 dot 1416329565 at usendtaylorx2l>
Ping.
In the slightly over three weeks since I posted this and the two related
parts, I have seen only two replies off list, nothing on list.
This bug is affecting us and I'd like some version of a fix for it to go
in. Any chance?
Thanks.
David Taylor <dtaylor@emc.com> wrote:
> The following is a fix for bug 17520 (structure offset wrong when 1/4 GB
> or greater).
>
> Fixing this touched a lot of files. The bulk of the changes can be
> summarized with one of two lines:
>
> Change <function arg> from int to LONGEST
> or
> Change <local arg> from int to LONGEST.
>
> Occasionally the last part is
>
> from unsigned int to ULONGEST
> or
> from int * to LONGEST *.
>
> As described in bug 17520, if you have a big structure, and try to get
> the address of a structure member that is 1/4 GB or more from the start
> of the structure, GDB will report the wrong value. For example, if you
> have:
>
> struct big_struct
> {
> char first[0x10000000 + 16];
> long second;
> } big_struct;
>
> Then GDB will report an address for big_struct.second that is less than
> the address of the structure, big_struct.
>
> GDB assumes that the *bit* offset of the member will fit into an int.
> Even in a 32-bit environment, that is not a safe assumption.
>
> This patch changes it from int to LONGEST.
>
> There are a couple of warning messages that are affected. Since LONGEST
> is sometimes a long (LP64 environments) and sometimes a long long (ILP32
> environments), I chose to change the format from %d to %lld and cast the
> arg to long long.
>
> There were no testsuite regressions on i686 GNU/Linux nor on x86-64
> GNU/Linux.
>
> The bulk of the patch is in part 1. Part 2 is just a trivial testsuite
> patch (a new test). The git diffs are relative to the head of the trunk
> as of late last week.
>
> Here are the ChangeLog entries.
>
> gdb/ChangeLog:
>
> 2014-11-18 David Taylor <dtaylor@emc.com>
>
> * 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:
>
> 2014-11-18 David Taylor <dtaylor@emc.com>
>
> * 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.
>