From patchwork Fri Apr 15 10:41:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Arnez X-Patchwork-Id: 11748 Received: (qmail 26746 invoked by alias); 15 Apr 2016 10:43:11 -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 26696 invoked by uid 89); 15 Apr 2016 10:43:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=(unknown) X-HELO: e06smtp06.uk.ibm.com Received: from e06smtp06.uk.ibm.com (HELO e06smtp06.uk.ibm.com) (195.75.94.102) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Fri, 15 Apr 2016 10:43:09 +0000 Received: from localhost by e06smtp06.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 15 Apr 2016 11:43:06 +0100 Received: from d06dlp01.portsmouth.uk.ibm.com (9.149.20.13) by e06smtp06.uk.ibm.com (192.168.101.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 15 Apr 2016 11:43:02 +0100 X-IBM-Helo: d06dlp01.portsmouth.uk.ibm.com X-IBM-MailFrom: arnez@linux.vnet.ibm.com X-IBM-RcptTo: gdb-patches@sourceware.org Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 7041C17D8062 for ; Fri, 15 Apr 2016 11:43:46 +0100 (BST) Received: from d06av08.portsmouth.uk.ibm.com (d06av08.portsmouth.uk.ibm.com [9.149.37.249]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u3FAh1v861603882 for ; Fri, 15 Apr 2016 10:43:01 GMT Received: from d06av08.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av08.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u3FAh0Gp002460 for ; Fri, 15 Apr 2016 04:43:00 -0600 Received: from oc1027705133.ibm.com (dyn-9-152-212-180.boeblingen.de.ibm.com [9.152.212.180]) by d06av08.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u3FAgKOs000892; Fri, 15 Apr 2016 04:43:00 -0600 From: Andreas Arnez To: gdb-patches@sourceware.org Cc: Ulrich Weigand Subject: [PATCH 1/2] S390: Take value from sub-register if applicable Date: Fri, 15 Apr 2016 12:41:38 +0200 Message-Id: <1460716939-27850-2-git-send-email-arnez@linux.vnet.ibm.com> In-Reply-To: <1460716939-27850-1-git-send-email-arnez@linux.vnet.ibm.com> References: <1460716939-27850-1-git-send-email-arnez@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16041510-0025-0000-0000-000013602A70 X-IsSubscribed: yes On an s390 target with vector registers store.exp emits various FAILs while trying to access a variable located in an unwound floating-point register. In those cases the variable's DWARF location happens to be DW_OP_reg24, which refers to FP register f8 or to vector register v8, depending on whether the target has vector registers. But while f8 is call-saved and thus can be unwound by GDB, v8 is not. Thus an uplevel variable with such a location can neither be read nor written. A similar situation occurs on an s390 (32-bit) target with high GPRs. For that case we already have logic in s390_unwind_pseudo_register which unwinds a full GPR by casting its lower half to the larger type. However, that cast does not result in an lvalue, so an uplevel variable based on such a location is readable, but not writable. Again, this results in various FAILs from store.exp. Both issues are addressed with a change to the s390 implementation of the gdbarch method 'value_from_register': If the given type is small enough to fit in the appropriate sub-register, then take the value from that sub-register instead of from the full register. gdb/ChangeLog: * s390-linux-tdep.c (s390_value_from_register): Use sub-register if appropriate. --- gdb/s390-linux-tdep.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/gdb/s390-linux-tdep.c b/gdb/s390-linux-tdep.c index fc57592..8b4efb1 100644 --- a/gdb/s390-linux-tdep.c +++ b/gdb/s390-linux-tdep.c @@ -518,12 +518,18 @@ s390_value_from_register (struct gdbarch *gdbarch, struct type *type, int regnum, struct frame_id frame_id) { struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); - struct value *value = default_value_from_register (gdbarch, type, - regnum, frame_id); - check_typedef (type); + unsigned int len = TYPE_LENGTH (check_typedef (type)); + struct value *value; - if ((regnum >= S390_F0_REGNUM && regnum <= S390_F15_REGNUM - && TYPE_LENGTH (type) < 8) + /* If the value fits in a sub-register, use that instead. */ + if (regnum_is_vxr_full (tdep, regnum) && len <= 8) + regnum = regnum - tdep->v0_full_regnum + S390_F0_REGNUM; + else if (regnum_is_gpr_full (tdep, regnum) && len <= 4) + regnum = regnum - tdep->gpr_full_regnum + S390_R0_REGNUM; + + value = default_value_from_register (gdbarch, type, regnum, frame_id); + + if ((regnum >= S390_F0_REGNUM && regnum <= S390_F15_REGNUM && len < 8) || regnum_is_vxr_full (tdep, regnum) || (regnum >= S390_V16_REGNUM && regnum <= S390_V31_REGNUM)) set_value_offset (value, 0);