From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 68997 invoked by alias); 11 Oct 2019 14:50:04 -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 68982 invoked by uid 89); 11 Oct 2019 14:50:03 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.9 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=s390-tdep.c, s390tdepc, UD:s390-tdep.c 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; Fri, 11 Oct 2019 14:50:02 +0000 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x9BEltEx096803 for ; Fri, 11 Oct 2019 10:50:01 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0a-001b2d01.pphosted.com with ESMTP id 2vjtdd45gf-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 11 Oct 2019 10:50:00 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 11 Oct 2019 15:49:58 +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) Fri, 11 Oct 2019 15:49:56 +0100 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x9BEnrEg45219956 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Oct 2019 14:49:53 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1104BAE055; Fri, 11 Oct 2019 14:49:53 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DF941AE051; Fri, 11 Oct 2019 14:49:52 +0000 (GMT) Received: from oc0404454431.ibm.com (unknown [9.152.222.45]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Fri, 11 Oct 2019 14:49:52 +0000 (GMT) From: Andreas Arnez To: gdb-patches@sourceware.org Cc: Ulrich Weigand Subject: [PATCH] s390: Fix infcalls passing a single-field struct with static members Date: Fri, 11 Oct 2019 14:50:00 -0000 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain x-cbid: 19101114-0020-0000-0000-0000037835AC X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19101114-0021-0000-0000-000021CE4787 Message-Id: X-SW-Source: 2019-10/txt/msg00299.txt.bz2 The infcall-nested-structs test case yields 36 FAILs on s390x because GCC and GDB disagree on how to pass a C++ struct like this as an argument to a function: struct s { float x; static float y; }; For the purpose of argument passing, GCC ignores static fields, while GDB does not. Thus GCC passes the argument in a floating-point register and GDB passes it via memory. Fix this by explicitly ignoring static fields when detecting single-field structs. gdb/ChangeLog: * s390-tdep.c (s390_effective_inner_type): Ignore static fields when unwrapping single-field structs. --- gdb/s390-tdep.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c index e7f1215e1a..6bd0528cf4 100644 --- a/gdb/s390-tdep.c +++ b/gdb/s390-tdep.c @@ -1637,11 +1637,26 @@ s390_address_class_name_to_type_flags (struct gdbarch *gdbarch, static struct type * s390_effective_inner_type (struct type *type, unsigned int min_size) { - while (TYPE_CODE (type) == TYPE_CODE_STRUCT - && TYPE_NFIELDS (type) == 1) + while (TYPE_CODE (type) == TYPE_CODE_STRUCT) { - struct type *inner = check_typedef (TYPE_FIELD_TYPE (type, 0)); + struct type *inner = NULL; + /* Find a non-static field, if any. Unless there's exactly one, + abort the unwrapping. */ + for (int i = 0; i < TYPE_NFIELDS (type); i++) + { + struct field f = TYPE_FIELD (type, i); + + if (field_is_static (&f)) + continue; + if (inner != NULL) + return type; + inner = FIELD_TYPE (f); + } + + if (inner == NULL) + break; + inner = check_typedef (inner); if (TYPE_LENGTH (inner) < min_size) break; type = inner; -- 2.17.0