From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id WE1VLYhB1GOOEyMAWB0awg (envelope-from ) for ; Fri, 27 Jan 2023 16:26:32 -0500 Received: by simark.ca (Postfix, from userid 112) id AA9DF1E128; Fri, 27 Jan 2023 16:26:32 -0500 (EST) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=LYfVHuKO; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,NICE_REPLY_A, RCVD_IN_DNSWL_MED,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 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 5C0C11E0D3 for ; Fri, 27 Jan 2023 16:26:32 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D7FCB3858D20 for ; Fri, 27 Jan 2023 21:26:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D7FCB3858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1674854791; bh=JzVfI+AdGLkxM+sntWPSuXgXLfPDLVmrrwswPNzEUvQ=; h=Date:Subject:To:Cc:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=LYfVHuKOrNxnY3BwURlFKS0DGIs8u682Yo3+1DZGxCaB/tBNCBuGewL594Q/aMggY rxTORdqPDEGpTUnuQamcpVmSBC6qbtc2QNSgMUinElnu2/tq9ChL/Qe4lNtQuExCSc Hv1sesiUFPHbl8x6xrVJfjdO30uadgQSLSgB+tSM= 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 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) 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> In-Reply-To: <993c562b-ff57-771d-f13f-654a85701239@simark.ca> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" 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