From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4282 invoked by alias); 18 Nov 2014 16:53:12 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 4210 invoked by uid 89); 18 Nov 2014 16:53:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,NO_DNS_FOR_FROM,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mailuogwhop.emc.com Received: from mailuogwhop.emc.com (HELO mailuogwhop.emc.com) (168.159.213.141) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Tue, 18 Nov 2014 16:53:09 +0000 Received: from maildlpprd05.lss.emc.com (maildlpprd05.lss.emc.com [10.253.24.37]) by mailuogwprd01.lss.emc.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.0) with ESMTP id sAIGr6pV010462 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 18 Nov 2014 11:53:06 -0500 X-DKIM: OpenDKIM Filter v2.4.3 mailuogwprd01.lss.emc.com sAIGr6pV010462 X-DKIM: OpenDKIM Filter v2.4.3 mailuogwprd01.lss.emc.com sAIGr6pV010462 Received: from mailsyshubprd04.lss.emc.com (mailsyshubprd04.lss.emc.com [10.253.24.26]) by maildlpprd05.lss.emc.com (RSA Interceptor) for ; Tue, 18 Nov 2014 11:52:31 -0500 Received: from usendtaylorx2l.lss.emc.com (usendtaylorx2l.lss.emc.com [10.243.10.188]) by mailsyshubprd04.lss.emc.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.0) with ESMTP id sAIGqlxJ017719 for ; Tue, 18 Nov 2014 11:52:47 -0500 Received: by usendtaylorx2l.lss.emc.com (Postfix, from userid 26043) id 53B065DA7D6; Tue, 18 Nov 2014 11:52:45 -0500 (EST) Received: from usendtaylorx2l (localhost [127.0.0.1]) by usendtaylorx2l.lss.emc.com (Postfix) with ESMTP id C19995D778C for ; Tue, 18 Nov 2014 11:52:45 -0500 (EST) From: David Taylor To: gdb-patches@sourceware.org Subject: RFA 0/2 fix for bug with large structure offsets Date: Tue, 18 Nov 2014 16:53:00 -0000 Message-ID: <18829.1416329565@usendtaylorx2l> X-RSA-Classifications: DLM_1, public X-Sentrion-Hostname: mailuogwprd01.lss.emc.com X-IsSubscribed: yes X-SW-Source: 2014-11/txt/msg00419.txt.bz2 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 from int to LONGEST or Change 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 * 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 * 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.