From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 65744 invoked by alias); 9 Aug 2019 18:30:58 -0000 Mailing-List: contact gdb-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: , Sender: gdb-cvs-owner@sourceware.org List-Subscribe: Sender: gdb-cvs-owner@sourceware.org Received: (qmail 65563 invoked by uid 10119); 9 Aug 2019 18:30:53 -0000 Date: Fri, 09 Aug 2019 18:30:00 -0000 Message-ID: <20190809183053.65562.qmail@sourceware.org> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Andreas Arnez To: gdb-cvs@sourceware.org Subject: [binutils-gdb] s390: Implement 'type_align' gdbarch method X-Act-Checkin: binutils-gdb X-Git-Author: Andreas Arnez X-Git-Refname: refs/heads/master X-Git-Oldrev: f211b8c0b91fc7b1657079a495f05a9a4d957821 X-Git-Newrev: 1022c627dbd9d7f7f67ac68f16de05474de7a75a X-SW-Source: 2019-08/txt/msg00047.txt.bz2 https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1022c627dbd9d7f7f67ac68f16de05474de7a75a commit 1022c627dbd9d7f7f67ac68f16de05474de7a75a Author: Andreas Arnez Date: Fri Aug 9 20:27:03 2019 +0200 s390: Implement 'type_align' gdbarch method 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. Diff: --- gdb/ChangeLog | 5 +++++ gdb/s390-tdep.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6e6390c..00e4bac 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2019-08-09 Andreas Arnez + + * s390-tdep.c (s390_type_align): New function. + (s390_gdbarch_init): Set it as type_align gdbarch method. + 2019-08-09 Tom de Vries PR gdb/24591 diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c index 4b93101..871efc5 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