From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id Jvu1E3legGCCPgAAWB0awg (envelope-from ) for ; Wed, 21 Apr 2021 13:18:49 -0400 Received: by simark.ca (Postfix, from userid 112) id 43D3C1F104; Wed, 21 Apr 2021 13:18:49 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id A004C1E789 for ; Wed, 21 Apr 2021 13:18:48 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 32BDD3892015; Wed, 21 Apr 2021 17:18:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 32BDD3892015 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1619025528; bh=O1oVJOt9H0OHdha6BUt+MRDfzyxhlgMI7Tkuw/CqvUs=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=IH2p/6Eo0zv50zQZ4JIL3Bi1LxD7YI0NsRMu6shc1HjMmjhkl9gU9/+zoYWOrs5GW ZVjNZmj+IWANJYAa/H3H2bSw96mDIF8J4DyYxUuObEf0tuTl7w4uuR53RIlmvbsE0x ejvFTmDKMrcJrF4STZ5H8VdZLpmyzNJTnIfM1tB0= Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 0A5F93838001 for ; Wed, 21 Apr 2021 17:18:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0A5F93838001 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 13LHIW5K008507 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 21 Apr 2021 13:18:37 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 13LHIW5K008507 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id A818C1E789; Wed, 21 Apr 2021 13:18:32 -0400 (EDT) Subject: Re: [PATCH] gdb: allow default_addressable_memory_unit_size to handle more cases To: Andrew Burgess , gdb-patches@sourceware.org References: <20210421165919.1418455-1-andrew.burgess@embecosm.com> Message-ID: Date: Wed, 21 Apr 2021 13:18:32 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210421165919.1418455-1-andrew.burgess@embecosm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Wed, 21 Apr 2021 17:18:32 +0000 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" On 2021-04-21 12:59 p.m., Andrew Burgess wrote: > Currently default_addressable_memory_unit_size always returns 1, > indicating 1 byte is 1 octet. If a target has something other than > this (common) setup then the target should override the > default_addressable_memory_unit_size. > > However, the bfd library already knows about each targets octets per > byte, so it seems redundant making targets override this method to > tell GDB something it already knows (through bfd). > > In this commit I propose to make default_addressable_memory_unit_size > return a value based on bfd's bits per byte. I checked, and for every > target that GDB currently supports the bits per byte in bfd is 8, so > the current behaviour will not change. > > In fact, the only targets in bfd that have bits per byte set to > something other than 8 can be found in cpu-tic4x.c and cpu-tic54x.c, I > don't believe these are supported by GDB right now. > > I don't propose to remove the ability to override > default_addressable_memory_unit_size, this allows targets additional > flexibility for how to handle weird combinations of byte sizes. > > This change was motivated by an out of tree target I was working on, > but it seemed like it was a good change that others might benefit > from. > > There should be no user visible changes after this commit. > > gdb/ChangeLog: > > * arch-utils.c (default_addressable_memory_unit_size): Return a > value based on bfd's bits per byte. > --- > gdb/ChangeLog | 5 +++++ > gdb/arch-utils.c | 8 +++++--- > 2 files changed, 10 insertions(+), 3 deletions(-) > > diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c > index e1d5afd6039..36681e96b61 100644 > --- a/gdb/arch-utils.c > +++ b/gdb/arch-utils.c > @@ -1005,13 +1005,15 @@ default_gnu_triplet_regexp (struct gdbarch *gdbarch) > return gdbarch_bfd_arch_info (gdbarch)->arch_name; > } > > -/* Default method for gdbarch_addressable_memory_unit_size. By default, a memory byte has > - a size of 1 octet. */ > +/* Default method for gdbarch_addressable_memory_unit_size. The default is > + based on the bits_per_byte defined in the bfd library for the current > + architecture, this is usually 8-bits, and so this function will usually > + return 1 indicating 1 bytes is 1 octet. */ > > int > default_addressable_memory_unit_size (struct gdbarch *gdbarch) > { > - return 1; > + return gdbarch_bfd_arch_info (gdbarch)->bits_per_byte / 8; > } > > void > I think that makes sense, and therefore LGTM. Simon