From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-sender-0.a4lg.com (mail-sender.a4lg.com [153.120.152.154]) by sourceware.org (Postfix) with ESMTPS id D73F43858403 for ; Sun, 16 Oct 2022 15:31:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D73F43858403 Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail-sender-0.a4lg.com (Postfix) with ESMTPSA id B326C300089; Sun, 16 Oct 2022 15:31:11 +0000 (UTC) Message-ID: <1a4f3042-a278-ba8f-ae8c-1cfe77ce64c9@irq.a4lg.com> Date: Mon, 17 Oct 2022 00:31:09 +0900 Mime-Version: 1.0 Subject: Re: [RFC PATCH 1/1] gdb/riscv: Cache per-BFD disassembler Content-Language: en-US To: Tom Tromey , gdb-patches@sourceware.org References: <760e2c443b1244b2a0a64f7f865e905b9ef90a72.1665287884.git.research_trasio@irq.a4lg.com> <871qrameqe.fsf@tromey.com> From: Tsukasa OI In-Reply-To: <871qrameqe.fsf@tromey.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, SPF_HELO_NONE, 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 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: , X-List-Received-Date: Sun, 16 Oct 2022 15:31:39 -0000 On 2022/10/15 3:39, Tom Tromey wrote: >>>>>> Tsukasa OI via Gdb-patches writes: > >> +static int >> +riscv_print_insn (bfd_vma memaddr, disassemble_info *info) >> +{ >> + static disassembler_ftype disassemble_fn = NULL; >> + static bfd *abfd = NULL; > > This seems mildly dangerous, in that a BFD could be destroyed, then a > new one created with the same address. > > It's better to cache things using the registry system. > See gdb/registry.h. You can look for "registry" for examples. > > Tom > Thanks for letting me know. Because my opcodes-side optimization on RISC-V will hide most of the performance improvements made by that proposed patch, I will need to redo the benchmark after I write a patch to use registry system. If registry cost is too high, I will have to scrap this idea instead of using the registry system. Thanks, Tsukasa