From patchwork Thu Aug 8 11:40:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Arnez X-Patchwork-Id: 34005 Received: (qmail 116382 invoked by alias); 8 Aug 2019 11:40:20 -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 116374 invoked by uid 89); 8 Aug 2019 11:40:20 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=H*Ad:U*uweigand 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; Thu, 08 Aug 2019 11:40:19 +0000 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x78BcgZV146744 for ; Thu, 8 Aug 2019 07:40:17 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0a-001b2d01.pphosted.com with ESMTP id 2u8h8bcbce-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 08 Aug 2019 07:40:17 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 8 Aug 2019 12:40:15 +0100 Received: from b06avi18878370.portsmouth.uk.ibm.com (9.149.26.194) 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) Thu, 8 Aug 2019 12:40:13 +0100 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x78BeAoZ35455286 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 8 Aug 2019 11:40:10 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C015542041; Thu, 8 Aug 2019 11:40:10 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A871F42047; Thu, 8 Aug 2019 11:40:10 +0000 (GMT) Received: from oc0404454431.ibm.com (unknown [9.152.222.95]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Thu, 8 Aug 2019 11:40:10 +0000 (GMT) From: Andreas Arnez To: gdb-patches@sourceware.org Cc: Ulrich Weigand Subject: [PATCH] s390: Implement 'type_align' gdbarch method Date: Thu, 08 Aug 2019 13:40:08 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) MIME-Version: 1.0 x-cbid: 19080811-0020-0000-0000-0000035D3D18 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19080811-0021-0000-0000-000021B23FA4 Message-Id: The align.exp test case yields many FAILs on s390x, since GDB's _Alignoff doesn't always agree with the compiler's. On s390x, the maximum alignment is 8, but GDB returns an alignment of 16 for 16-byte data types such as "long double". This is fixed by implementing the type_align gdbarch method. The new method returns an alignment of 8 for all integer, floating-point, and vector types larger than 8 bytes. With this change, all align.exp tests pass. gdb/ChangeLog: * s390-tdep.c (s390_type_align): New function. (s390_gdbarch_init): Set it as type_align gdbarch method. --- gdb/s390-tdep.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c index 4b931017a8..871efc59bc 100644 --- a/gdb/s390-tdep.c +++ b/gdb/s390-tdep.c @@ -52,6 +52,37 @@ constexpr gdb_byte s390_break_insn[] = { 0x0, 0x1 }; typedef BP_MANIPULATION (s390_break_insn) s390_breakpoint; +/* Types. */ + +/* Implement the gdbarch type alignment method. */ + +static ULONGEST +s390_type_align (gdbarch *gdbarch, struct type *t) +{ + t = check_typedef (t); + + if (TYPE_LENGTH (t) > 8) + { + switch (TYPE_CODE (t)) + { + case TYPE_CODE_INT: + case TYPE_CODE_RANGE: + case TYPE_CODE_FLT: + case TYPE_CODE_ENUM: + case TYPE_CODE_CHAR: + case TYPE_CODE_BOOL: + case TYPE_CODE_DECFLOAT: + return 8; + + case TYPE_CODE_ARRAY: + if (TYPE_VECTOR (t)) + return 8; + break; + } + } + return 0; +} + /* Decoding S/390 instructions. */ /* Read a single instruction from address AT. */ @@ -6944,6 +6975,8 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_long_double_bit (gdbarch, 128); set_gdbarch_long_double_format (gdbarch, floatformats_ia64_quad); + set_gdbarch_type_align (gdbarch, s390_type_align); + /* Breakpoints. */ /* Amount PC must be decremented by after a breakpoint. This is often the number of bytes returned by gdbarch_breakpoint_from_pc but not