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 C69CB3858C53 for ; Thu, 19 Jan 2023 16:53:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C69CB3858C53 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) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id DA1DC1E0D3; Thu, 19 Jan 2023 11:53:48 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1674147229; bh=jlHyZxB2eArbY+YE+Nzx7u3FXVSwIw1BHgjG5upASy4=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=jMO/uEGcJxnW7rzA5+ck/nNQfMG881PQbYIJDVxW25NalLCT/6oyJafrS4JPwzsMI +TgLyFLAGzbuonl93c+Ep9oaX3TgkKdPHOwGiAEF1i5D04g2+WsrNhAuQn1xUhMeQP 401S98kHzMO9RuAWPJo8l3rUVRbk/AmU2jqa+bXw= Message-ID: Date: Thu, 19 Jan 2023 11:53:48 -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 v3 1/2] gdb: dwarf2 generic implementation for caching function data Content-Language: en-US To: =?UTF-8?Q?Torbj=c3=b6rn_SVENSSON?= , gdb-patches@sourceware.org Cc: luis.machado@arm.com, tom@tromey.com, Yvan Roux References: <20230119102948.3069226-1-torbjorn.svensson@foss.st.com> From: Simon Marchi In-Reply-To: <20230119102948.3069226-1-torbjorn.svensson@foss.st.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.0 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/19/23 05:29, Torbjörn SVENSSON via Gdb-patches wrote: > v2 -> v3: > > Addressed comments from Tom in > https://sourceware.org/pipermail/gdb-patches/2023-January/195882.html > > > --- > > When there is no dwarf2 data for a register, a function can be called > to provide the value of this register. In some situations, it might > not be trivial to determine the value to return and it would cause a > performance bottleneck to do the computation each time. > > This patch allows the called function to have a "cache" object that it > can use to store some metadata between calls to reduce the performance > impact of the complex logic. > > The cache object is unique for each function and frame, so if there are > more than one function pointer stored in the dwarf2_frame_cache->reg > array, then the appropriate pointer will be supplied (the type is not > known by the dwarf2 implementation). > > dwarf2_frame_get_fn_data can be used to retrieve the function unique > cache object. > dwarf2_frame_allocate_fn_data can be used to allocate and retrieve the > function unique cache object. > > Signed-off-by: Torbjörn SVENSSON > Signed-off-by: Yvan Roux Hi, My main question is: this approach requires each custom prev_register function to set up and manage its own cache. Did you consider caching values at a higher level? Perhaps: 1. In dwarf2_frame_prev_register, just for DWARF2_FRAME_REG_FN 2. In dwarf2_frame_prev_register, but for all kinds of registers 3. In frame_unwind_register_value, which would cache all register values for all frames regardless of the unwinder I don't know if other ways of unwinding would benefit that much from caching, but I guess it wouldn't hurt. For instance, evaluating DWARF expressions is probably generally not super expensive, but it might still benefit from getting cached. And it would be nice to write the caching code just once and have it work transparently for everything. > @@ -262,4 +264,35 @@ extern int dwarf2_fetch_cfa_info (struct gdbarch *gdbarch, CORE_ADDR pc, > const gdb_byte **cfa_start_out, > const gdb_byte **cfa_end_out); > > + > +/* Allocate a new instance of the function unique data. > + > + The main purpose of this custom function data object is to allow caching the > + value of expensive lookups in the prev_register implementation. I would replace "in the prev_register implementation" with "in prev_register implementations". There isn't only one prev_register implementation AFAIK. Simon