From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 55078 invoked by alias); 10 Mar 2017 19:24:41 -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 54243 invoked by uid 89); 10 Mar 2017 19:24:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 spammy=focuses, states 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, 10 Mar 2017 19:24:22 +0000 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v2AJNpPR012247 for ; Fri, 10 Mar 2017 14:24:09 -0500 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0a-001b2d01.pphosted.com with ESMTP id 293p3b0sa3-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 10 Mar 2017 14:24:09 -0500 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 10 Mar 2017 19:24:07 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 10 Mar 2017 19:24:05 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v2AJO5a520381970; Fri, 10 Mar 2017 19:24:05 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E7409A4040; Fri, 10 Mar 2017 19:23:58 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C0796A4053; Fri, 10 Mar 2017 19:23:58 +0000 (GMT) Received: from oc1027705133.ibm.com (unknown [9.152.212.162]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Fri, 10 Mar 2017 19:23:58 +0000 (GMT) From: Andreas Arnez To: "Ulrich Weigand" Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] PR gdb/21226: Take DWARF stack value pieces from LSB end References: <20170310174317.2A0E0D806B1@oc3748833570.ibm.com> Date: Fri, 10 Mar 2017 19:24:00 -0000 In-Reply-To: <20170310174317.2A0E0D806B1@oc3748833570.ibm.com> (Ulrich Weigand's message of "Fri, 10 Mar 2017 18:43:17 +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: 17031019-0012-0000-0000-000004E160F9 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17031019-0013-0000-0000-0000178FC573 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-03-10_12:,, 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-1703100151 X-IsSubscribed: yes X-SW-Source: 2017-03/txt/msg00147.txt.bz2 On Fri, Mar 10 2017, Ulrich Weigand wrote: > Andreas Arnez wrote: > >> When taking a DW_OP_piece or DW_OP_bit_piece from a DW_OP_stack_value, the >> existing logic always takes the piece from the lowest-addressed end, which >> is wrong on big-endian targets. The DWARF standard states that the >> "DW_OP_bit_piece operation describes a sequence of bits using the least >> significant bits of that value", and this also matches the current logic >> in GCC. For instance, the GCC guality test case pr54970.c fails on s390x >> because of this. >> >> This fix adjusts the piece accordingly on big-endian targets. It is >> assumed that: >> >> * DW_OP_piece shall take the piece from the LSB end as well; >> >> * pieces reaching outside the stack value bits are considered undefined, >> and a zero value can be used instead. > > These assumptions look good to me. > >> The new logic also respects the DW_OP_bit_piece offset for >> DW_OP_stack_values. Previously the offset was ignored. Note that it is >> still ignored for all other types of DWARF pieces. > > I'm not really sure about that. If we're going to support the offset, > shouldn't we then support it for all piece types? I'm not sure it > is a good idea to support it for some but not others ... This patch specifically focuses on fixing the bug with stack value pieces; I didn't want to intermingle it with fixes for the other piece types. So I'll drop the offset support from this patch and re-introduce it with another patch that adds offset support for all piece types. > >> case DWARF_VALUE_STACK: >> { >> - size_t n = this_size; >> + ULONGEST obj_size = 8 * TYPE_LENGTH (value_type (p->v.value)); >> >> - if (n > c->addr_size - source_offset) >> - n = (c->addr_size >= source_offset >> - ? c->addr_size - source_offset >> - : 0); > > c->addr_size is now unused. This is a left-over from the days when stack > values were untyped, and were always assumed to be integers the size of > a target address. Now that we have a proper typed stack, c->addr_size > is not really relevant anymore. It should be completely removed from > the piece_closure data structure (and all code that initializes it). OK, I'll look into providing a separate patch for that. > >> + /* Use zeroes if piece reaches beyond stack value. */ >> + if (p->offset + p->size > obj_size) >> + goto skip_copy; > > I'm not sure I like those gotos :-( > >> - if (p->location != DWARF_VALUE_OPTIMIZED_OUT >> - && p->location != DWARF_VALUE_IMPLICIT_POINTER) >> - copy_bitwise (contents, dest_offset_bits, >> - intermediate_buffer, source_offset_bits % 8, >> - this_size_bits, bits_big_endian); >> + copy_bitwise (contents, dest_offset_bits, >> + intermediate_buffer, source_offset_bits % 8, >> + this_size_bits, bits_big_endian); >> >> + skip_copy: > > At this point, it seems better to just duplicate the copy_bitwise > call to all those switch clauses that actually need it. OK. (The original author seems to have thought differently, and I tried to follow the existing scheme, to keep the changes local.) > > Bye, > Ulrich