From patchwork Wed Oct 2 13:22:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Arnez X-Patchwork-Id: 34787 Received: (qmail 130954 invoked by alias); 2 Oct 2019 13:22:28 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 130944 invoked by uid 89); 2 Oct 2019 13:22:27 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 02 Oct 2019 13:22:26 +0000 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x92DMJIs017488 for ; Wed, 2 Oct 2019 09:22:23 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0a-001b2d01.pphosted.com with ESMTP id 2vcsupwrnm-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 02 Oct 2019 09:22:23 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 2 Oct 2019 14:22:21 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 2 Oct 2019 14:22:18 +0100 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x92DMHls45547624 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 2 Oct 2019 13:22:17 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 83D72A405C; Wed, 2 Oct 2019 13:22:17 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5CDAEA4054; Wed, 2 Oct 2019 13:22:17 +0000 (GMT) Received: from oc0404454431.ibm.com (unknown [9.152.222.48]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Wed, 2 Oct 2019 13:22:17 +0000 (GMT) From: Andreas Arnez To: Tom Tromey Cc: gdb-patches@sourceware.org, Marco Barisione Subject: Re: [PATCH] gdb/testsuite: Fix py-format-string.exp on big-endian platforms References: <87sgoc4ckv.fsf@tromey.com> Date: Wed, 02 Oct 2019 15:22:15 +0200 In-Reply-To: <87sgoc4ckv.fsf@tromey.com> (Tom Tromey's message of "Tue, 01 Oct 2019 11:09:36 -0600") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) MIME-Version: 1.0 x-cbid: 19100213-0020-0000-0000-000003745963 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19100213-0021-0000-0000-000021CA5E3F Message-Id: On Tue, Oct 01 2019, Tom Tromey wrote: >>>>>> "Andreas" == Andreas Arnez writes: > > Andreas> * gdb.python/py-format-string.c (main): Initialize > Andreas> a_struct_with_union.the_union.an_int with a "palindrome" integer > Andreas> instead of just 42, for endianness-independence. > Andreas> * gdb.python/py-format-string.exp (default_regexp_dict) > Andreas> (test_pretty_structs, test_format): Adjust expected output to the > Andreas> changed integer value. > > Thank you for doing this. No problem. I'd just like the number of testsuite FAILs on s390x to drop to a reasonable amount again. > > Andreas> + /* Choose a value whose first byte (little-/big-endian) is 42. */ > Andreas> + a_struct_with_union.the_union.an_int = 0x2a00002a; > > Maybe for size-independence it would be better to memset the entire > union to 0x2a? You mean in anticipation of this union being extended in the future? Sure, I can do that; see updated patch below. OK to apply? --- Andreas --- >8 --- Subject: [PATCH v2] gdb/testsuite: Fix py-format-string.exp on big-endian platforms GDB's py-format-string test case depends on endianness. In particular it relies on the first byte of the machine representation of 42 (as an int) to be 42 as well. While this is indeed the case for little-endian machines, big-endian machines store a zero in the first byte instead. The wrong assumption leads to lots of FAILs on such architectures. Fix this by filling the affected union with bytes of the same value, such that endianness does not matter. Use the value 42, to keep the character in the first byte unchanged. gdb/testsuite/ChangeLog: * gdb.python/py-format-string.c (string.h): New include. (main): Fill a_struct_with_union.the_union.an_int with bytes of the same value, for endianness-independence. * gdb.python/py-format-string.exp (default_regexp_dict) (test_pretty_structs, test_format): Adjust expected output to the changed initialization. --- gdb/testsuite/gdb.python/py-format-string.c | 6 +++++- gdb/testsuite/gdb.python/py-format-string.exp | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/gdb/testsuite/gdb.python/py-format-string.c b/gdb/testsuite/gdb.python/py-format-string.c index 120ecce989..017f92080b 100644 --- a/gdb/testsuite/gdb.python/py-format-string.c +++ b/gdb/testsuite/gdb.python/py-format-string.c @@ -15,6 +15,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include + typedef struct point { int x; @@ -84,7 +86,9 @@ main () struct point another_point = { 123, 456 }; struct_union_t a_struct_with_union; - a_struct_with_union.the_union.an_int = 42; + /* Fill the union in an endianness-independent way. */ + memset (&a_struct_with_union.the_union, 42, + sizeof (a_struct_with_union.the_union)); enum_t an_enum = ENUM_BAR; diff --git a/gdb/testsuite/gdb.python/py-format-string.exp b/gdb/testsuite/gdb.python/py-format-string.exp index ebb2074ce8..ad71fe0e51 100644 --- a/gdb/testsuite/gdb.python/py-format-string.exp +++ b/gdb/testsuite/gdb.python/py-format-string.exp @@ -124,7 +124,7 @@ set default_regexp_dict [dict create \ "a_point_t_pointer" $default_pointer_regexp \ "a_point_t_ref" "Pretty Point \\(42, 12\\)" \ "another_point" "Pretty Point \\(123, 456\\)" \ - "a_struct_with_union" "\\{the_union = \\{an_int = 42, a_char = 42 '\\*'\\}\\}" \ + "a_struct_with_union" "\\{the_union = \\{an_int = 707406378, a_char = 42 '\\*'\\}\\}" \ "an_enum" "ENUM_BAR" \ "a_string" "${default_pointer_regexp} \"hello world\"" \ "a_binary_string" "${default_pointer_regexp} \"hello\"" \ @@ -333,7 +333,7 @@ proc test_pretty_structs {} { global current_lang set a_struct_with_union_pretty \ - "\\{\[\r\n\]+ the_union = \\{\[\r\n\]+ an_int = 42,\[\r\n\]+ a_char = 42 '\\*'\[\r\n\]+ \\}\[\r\n\]+\\}" + "\\{\[\r\n\]+ the_union = \\{\[\r\n\]+ an_int = 707406378,\[\r\n\]+ a_char = 42 '\\*'\[\r\n\]+ \\}\[\r\n\]+\\}" check_var_with_bool_opt "pretty_structs" "a_point_t" check_var_with_bool_opt "pretty_structs" "a_point_t_pointer" @@ -814,7 +814,7 @@ proc test_format {} { check_format_string "a_point_t_pointer" $opts check_format_string "another_point" $opts check_format_string "a_struct_with_union" $opts \ - "\\{the_union = \\{an_int = 0x2a, a_char = 0x2a\\}\\}" + "\\{the_union = \\{an_int = 0x2a2a2a2a, a_char = 0x2a\\}\\}" check_format_string "an_enum" $opts \ "0x1" check_format_string "a_string" $opts \ @@ -851,7 +851,7 @@ proc test_format {} { $decimal_pointer_regexp check_format_string "another_point" $opts check_format_string "a_struct_with_union" $opts \ - "\\{the_union = \\{an_int = 42, a_char = 42\\}\\}" + "\\{the_union = \\{an_int = 707406378, a_char = 42\\}\\}" check_format_string "an_enum" $opts \ "1" check_format_string "a_string" $opts \