From patchwork Tue May 9 17:46:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Arnez X-Patchwork-Id: 20353 Received: (qmail 126030 invoked by alias); 9 May 2017 17:58:40 -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 126020 invoked by uid 89); 9 May 2017 17:58:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=Marks 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; Tue, 09 May 2017 17:58:38 +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 v49HwUbD098651 for ; Tue, 9 May 2017 13:58:40 -0400 Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110]) by mx0a-001b2d01.pphosted.com with ESMTP id 2abfbds17a-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 09 May 2017 13:58:39 -0400 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 9 May 2017 18:58:37 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 9 May 2017 18:58:35 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v49HwZc337224518 for ; Tue, 9 May 2017 17:58:35 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8A6BA52041 for ; Tue, 9 May 2017 17:55:58 +0100 (BST) Received: from oc1027705133.ibm.com (unknown [9.152.212.109]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 7070C5203F for ; Tue, 9 May 2017 17:55:58 +0100 (BST) From: Andreas Arnez To: gdb-patches@sourceware.org Subject: [PATCH v2 17/19] Fix bit-/byte-offset mismatch in parameter to read_value_memory Date: Tue, 9 May 2017 19:46:13 +0200 In-Reply-To: <1494352015-10465-1-git-send-email-arnez@linux.vnet.ibm.com> References: <1494352015-10465-1-git-send-email-arnez@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17050917-0016-0000-0000-0000049782E7 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17050917-0017-0000-0000-00002796E9AE Message-Id: <1494352015-10465-18-git-send-email-arnez@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-05-09_14:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1705090099 X-IsSubscribed: yes The function read_value_memory accepts a parameter embedded_offset and expects it to represent the byte offset into the given value. However, the only invocation with a possibly non-zero embedded_offset happens in read_pieced_value, where a bit offset is passed instead. Adjust the implementation of read_value_memory to meet the caller's expectation. This implicitly fixes the invocation in read_pieced_value. gdb/ChangeLog: * valops.c (read_value_memory): Change embedded_offset to represent a bit offset instead of a byte offset. * value.h (read_value_memory): Adjust comment. --- gdb/valops.c | 7 ++++--- gdb/value.h | 9 ++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gdb/valops.c b/gdb/valops.c index 93ae6cf..8675e6c 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -958,7 +958,7 @@ value_at_lazy (struct type *type, CORE_ADDR addr) } void -read_value_memory (struct value *val, LONGEST embedded_offset, +read_value_memory (struct value *val, LONGEST bit_offset, int stack, CORE_ADDR memaddr, gdb_byte *buffer, size_t length) { @@ -984,8 +984,9 @@ read_value_memory (struct value *val, LONGEST embedded_offset, if (status == TARGET_XFER_OK) /* nothing */; else if (status == TARGET_XFER_UNAVAILABLE) - mark_value_bytes_unavailable (val, embedded_offset + xfered_total, - xfered_partial); + mark_value_bits_unavailable (val, (xfered_total * HOST_CHAR_BIT + + bit_offset), + xfered_partial * HOST_CHAR_BIT); else if (status == TARGET_XFER_EOF) memory_error (TARGET_XFER_E_IO, memaddr + xfered_total); else diff --git a/gdb/value.h b/gdb/value.h index a1d1609..fb7f13d 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -581,12 +581,11 @@ extern int value_contents_eq (const struct value *val1, LONGEST offset1, /* Read LENGTH addressable memory units starting at MEMADDR into BUFFER, which is (or will be copied to) VAL's contents buffer offset by - EMBEDDED_OFFSET (that is, to &VAL->contents[EMBEDDED_OFFSET]). - Marks value contents ranges as unavailable if the corresponding - memory is likewise unavailable. STACK indicates whether the memory - is known to be stack memory. */ + BIT_OFFSET bits. Marks value contents ranges as unavailable if + the corresponding memory is likewise unavailable. STACK indicates + whether the memory is known to be stack memory. */ -extern void read_value_memory (struct value *val, LONGEST embedded_offset, +extern void read_value_memory (struct value *val, LONGEST bit_offset, int stack, CORE_ADDR memaddr, gdb_byte *buffer, size_t length);