From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 46224 invoked by alias); 24 Jul 2015 11:27:33 -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 46211 invoked by uid 89); 24 Jul 2015 11:27:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 24 Jul 2015 11:27:32 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 188D283F7E; Fri, 24 Jul 2015 11:27:31 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t6OBRTBw016032; Fri, 24 Jul 2015 07:27:30 -0400 Message-ID: <55B22120.5010707@redhat.com> Date: Fri, 24 Jul 2015 11:27:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Simon Marchi , gdb-patches@sourceware.org Subject: Re: [PATCH 4/5] Consider addressable memory unit size in various value functions References: <1437072684-26565-1-git-send-email-simon.marchi@ericsson.com> <1437072684-26565-4-git-send-email-simon.marchi@ericsson.com> In-Reply-To: <1437072684-26565-4-git-send-email-simon.marchi@ericsson.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2015-07/txt/msg00692.txt.bz2 On 07/16/2015 07:51 PM, Simon Marchi wrote: > This patch updates various value handling functions to make them > consider the addressable memory unit size of the current architecture. > This allows to correctly extract and print values on architectures whose > addressable memory unit is not 8 bits. > > The patch doesn't cover all the code that would ideally need to be > adjusted, only the code paths that we happen to use, plus a few obvious > ones. Specifically, those areas are not covered by this patch: > > - Management of unavailable bits > - Bitfields > - C++ stuff > > Regression-tested on x86-64 Ubuntu 14.04. I saw no related test result > change. LGTM, with: > diff --git a/gdb/value.c b/gdb/value.c > index af354de..7cc67d9 100644 > --- a/gdb/value.c > +++ b/gdb/value.c > @@ -1089,8 +1089,10 @@ set_value_parent (struct value *value, struct value *parent) > gdb_byte * > value_contents_raw (struct value *value) > { > + struct gdbarch *arch = get_value_arch (value); > + int unit_size = gdbarch_addressable_memory_unit_size (arch); Missing line break. > allocate_value_contents (value); > - return value->contents + value->embedded_offset; > + return value->contents + value->embedded_offset * unit_size; > } > > > /* Copy the meta-data, adjusted. */ > - src_bit_offset = src_offset * TARGET_CHAR_BIT; > - dst_bit_offset = dst_offset * TARGET_CHAR_BIT; > - bit_length = length * TARGET_CHAR_BIT; > + src_bit_offset = src_offset * unit_size * CHAR_BIT; > + dst_bit_offset = dst_offset * unit_size * CHAR_BIT; > + bit_length = length * unit_size * CHAR_BIT; AFAICS, we don't use CHAR_BIT anywhere. Instead, use HOST_CHAR_BIT, which has a fallback definition in common/host-defs.h. Thanks, Pedro Alves