From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 765EF3858D20 for ; Fri, 27 Jan 2023 21:26:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 765EF3858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca Received: from [10.0.0.11] (unknown [217.28.27.60]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 277211E0D3; Fri, 27 Jan 2023 16:26:13 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1674854773; bh=UVFvSEvqODPMDNlQrM9adXjwF4IfDsF2vCfPk8i9YJ0=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=mkc9mFKFXCoIwkndTA0e83x32kONOhS/fZQ/B3YDKJ5s9uYEUhH5vSHeVeh2cVnQ6 QbfIAa/C7dO/DSg54dSXOkhZPfVBuQuULuboN+0X/OJAFP5MPTqv1kr3GzkuVnnP70 bk13/t85TLipbBcqaKzvahF1EgVDXgirCPqwH87w= Message-ID: <552fb204-0365-5ecc-0e47-086b860325c4@simark.ca> Date: Fri, 27 Jan 2023 16:26:12 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: [PATCH] Make addrmap const-correct in cooked index Content-Language: en-US To: Tom Tromey Cc: gdb-patches@sourceware.org References: <20230127162603.4127820-1-tromey@adacore.com> <8446b53b-bd73-637b-7613-45c896d7240f@simark.ca> <87cz6zptg4.fsf@tromey.com> <993c562b-ff57-771d-f13f-654a85701239@simark.ca> From: Simon Marchi In-Reply-To: <993c562b-ff57-771d-f13f-654a85701239@simark.ca> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 1/27/23 16:20, Simon Marchi via Gdb-patches wrote: > > > On 1/27/23 16:18, Tom Tromey wrote: >>>>>>> "Simon" == Simon Marchi writes: >> >> Simon> -void * >> Simon> +const void * >> Simon> addrmap_fixed::find (CORE_ADDR addr) const >> Simon> { >> Simon> const struct addrmap_transition *bottom = &transitions[0]; >> >> Actually, this is going to rely on casting away const in some spots. >> >> For example cooked_index::lookup: >> >> dwarf2_per_cu_data *lookup (CORE_ADDR addr) const >> { >> return (dwarf2_per_cu_data *) m_addrmap->find (addr); >> } >> >> Probably we can't constify dwarf2_per_cu_data all over. > > I suppose in this case we can consider that it's the DWARF code that is > broken, and that it knows the risks of casting away the const. But at > least the addrmap code will be correct. Or, if the client code legitimately wants to modify the contained objects, then we provide a non-const version of addrmap::find that returns a non-const pointer. Simon