From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5820 invoked by alias); 16 Mar 2017 18:25:22 -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 5744 invoked by uid 89); 16 Mar 2017 18:25:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 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; Thu, 16 Mar 2017 18:25:19 +0000 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v2GIJDtg097417 for ; Thu, 16 Mar 2017 14:25:19 -0400 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0a-001b2d01.pphosted.com with ESMTP id 297xktkvbr-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 16 Mar 2017 14:25:18 -0400 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 16 Mar 2017 18:25:16 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 16 Mar 2017 18:25:14 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v2GIPEB831981718; Thu, 16 Mar 2017 18:25:14 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1AD0EAE053; Thu, 16 Mar 2017 18:24:55 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E4F0BAE055; Thu, 16 Mar 2017 18:24:54 +0000 (GMT) Received: from oc1027705133.ibm.com (unknown [9.152.212.162]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Thu, 16 Mar 2017 18:24:54 +0000 (GMT) From: Andreas Arnez To: "Ulrich Weigand" Cc: gdb-patches@sourceware.org, jan.kratochvil@redhat.com (Jan Kratochvil) Subject: Re: [PATCH] Big-endian targets: Don't ignore offset into DW_OP_stack_value References: <20170315191648.EC8B7D83328@oc3748833570.ibm.com> Date: Thu, 16 Mar 2017 18:25:00 -0000 In-Reply-To: <20170315191648.EC8B7D83328@oc3748833570.ibm.com> (Ulrich Weigand's message of "Wed, 15 Mar 2017 20:16:48 +0100 (CET)") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-GCONF: 00 x-cbid: 17031618-0020-0000-0000-000003248BAB X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17031618-0021-0000-0000-000040D20332 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-03-16_14:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1703160142 X-IsSubscribed: yes X-SW-Source: 2017-03/txt/msg00287.txt.bz2 On Wed, Mar 15 2017, Ulrich Weigand wrote: > Andreas Arnez wrote: [...] >> + /* Get type of pointed-to DIE. */ >> + struct type *orig_type = dwarf2_fetch_die_type_sect_off (die, per_cu); >> + >> /* If pointed-to DIE has a DW_AT_location, evaluate it and return the >> resulting value. Otherwise, it may have a DW_AT_const_value instead, >> or it may've been optimized out. */ >> if (baton.data != NULL) >> - return dwarf2_evaluate_loc_desc_full (TYPE_TARGET_TYPE (type), frame, >> - baton.data, baton.size, baton.per_cu, >> + return dwarf2_evaluate_loc_desc_full (orig_type, frame, baton.data, > > Can orig_type ever be NULL here? It probably would not be a good idea > to pass NULL as the type argument. >From looking at the code, it looks like it can. But only for very special cases, it seems. For instance, in case of a missing DW_AT_TYPE attribute for the pointed-to die we get the type "void" instead. > >> - if (byte_offset != 0) >> + if (subobj_byte_offset != 0) >> error (_("cannot use offset on synthetic pointer to register")); > > As an aside: now that we have the full object type, we may actually be able > to lift that restriction (do a value_from_register on the full type, and > then extract the subobject). Might be interesting to look into as a > follow-on change ... Right, I'll look into that. > >> size_t n = TYPE_LENGTH (value_type (value)); >> + size_t len = TYPE_LENGTH (subobj_type); >> + size_t max = type != NULL ? TYPE_LENGTH (type) : n; > > As mentioned above, I don't think it makes sense to allow a NULL type here. OK. I'll adjust the patch with the delta-patch below. Is that ready to apply then? -- Andreas -- >8 -- 1 file changed, 3 insertions(+), 1 deletion(-) gdb/dwarf2loc.c | 4 +++- modified gdb/dwarf2loc.c @@ -2166,6 +2166,8 @@ indirect_synthetic_pointer (sect_offset die, LONGEST byte_offset, /* Get type of pointed-to DIE. */ struct type *orig_type = dwarf2_fetch_die_type_sect_off (die, per_cu); + if (orig_type == NULL) + invalid_synthetic_pointer (); /* If pointed-to DIE has a DW_AT_location, evaluate it and return the resulting value. Otherwise, it may have a DW_AT_const_value instead, @@ -2487,7 +2489,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, struct value *value = ctx.fetch (0); size_t n = TYPE_LENGTH (value_type (value)); size_t len = TYPE_LENGTH (subobj_type); - size_t max = type != NULL ? TYPE_LENGTH (type) : n; + size_t max = TYPE_LENGTH (type); struct gdbarch *objfile_gdbarch = get_objfile_arch (objfile); struct cleanup *cleanup;