From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 1E8A23858D1E for ; Fri, 8 Sep 2023 16:52:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1E8A23858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca 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 388GqKvw025626 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 8 Sep 2023 12:52:24 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 388GqKvw025626 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=default; t=1694191945; bh=ZDFojBQClmu2HUBlMlk9npOi9MVsW6GXgMEucPQ4+g0=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=iMIOJ9H0hUJ/ICRFjzJdq0ZNvq5sOiQquvJuFLtKbiBLrSYWhHSujTCy6Zq4Bn53m E5WxsAPnGXtL3pIJwZDzx+YOn0x0eAOSOZVN9odyEgsazTb/rcGHR+1aa1wwDOS6hE oUXSUa5t9R90s7yUhZYDAFMrDKAKVSU/Pm1BXVCo= Received: from [172.16.0.192] (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id D878B1E092; Fri, 8 Sep 2023 12:52:19 -0400 (EDT) Message-ID: Date: Fri, 8 Sep 2023 12:52:19 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 06/16] [gdbserver/aarch64] refactor: Adjust expedited registers dynamically Content-Language: fr To: Luis Machado , gdb-patches@sourceware.org Cc: thiago.bauermann@linaro.org References: <20230907152018.1031257-1-luis.machado@arm.com> <20230907152018.1031257-7-luis.machado@arm.com> <770bbc82-3823-42e8-aabf-cec185c8c6ca@polymtl.ca> From: Simon Marchi In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Fri, 8 Sep 2023 16:52:20 +0000 X-Spam-Status: No, score=-3037.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 9/8/23 12:00, Luis Machado wrote: > On 9/8/23 16:35, Simon Marchi wrote: >> On 9/7/23 11:20, Luis Machado via Gdb-patches wrote: >>> Instead of using static arrays, build the list of expedited registers >>> dynamically using a std::vector. >>> >>> This refactor shouldn't cause any user-visible changes. >>> >>> Regression-tested for aarch64-linux Ubuntu 22.04/20.04. >>> --- >>> gdbserver/linux-aarch64-tdesc.cc | 21 ++++++++++++++------- >>> 1 file changed, 14 insertions(+), 7 deletions(-) >>> >>> diff --git a/gdbserver/linux-aarch64-tdesc.cc b/gdbserver/linux-aarch64-tdesc.cc >>> index 633134955e5..3c60e1a4db0 100644 >>> --- a/gdbserver/linux-aarch64-tdesc.cc >>> +++ b/gdbserver/linux-aarch64-tdesc.cc >>> @@ -30,6 +30,8 @@ >>> /* All possible aarch64 target descriptors. */ >>> static std::unordered_map tdesc_aarch64_map; >>> >>> +static std::vector expedited_registers; >>> + >>> /* Create the aarch64 target description. */ >>> >>> const target_desc * >>> @@ -44,15 +46,20 @@ aarch64_linux_read_description (const aarch64_features &features) >>> if (tdesc == NULL) >>> { >>> tdesc = aarch64_create_target_description (features); >>> + expedited_registers.clear (); >>> + >>> + /* Configure the expedited registers. By default we include x29, sp and >>> + pc. */ >>> + expedited_registers.push_back ("x29"); >>> + expedited_registers.push_back ("sp"); >>> + expedited_registers.push_back ("pc"); >>> + >>> + if (features.vq > 0) >>> + expedited_registers.push_back ("vg"); >>> >>> - static const char *expedite_regs_aarch64[] = { "x29", "sp", "pc", NULL }; >>> - static const char *expedite_regs_aarch64_sve[] = { "x29", "sp", "pc", >>> - "vg", NULL }; >>> + expedited_registers.push_back (nullptr); >>> >>> - if (features.vq == 0) >>> - init_target_desc (tdesc, expedite_regs_aarch64); >>> - else >>> - init_target_desc (tdesc, expedite_regs_aarch64_sve); >>> + init_target_desc (tdesc, (const char **) expedited_registers.data ()); >> >> It seems weird to have a single std::vector instance. What happens if >> multiple target descriptions are created? Won't the second mess up the >> data of the first one? > > Yeah. Well spotted. I think I'll need to have a map-based entry for the expedited registers, because init_target_desc > just copies the pointer instead of the contents. This can probably be changed, to make the target desc hold a vector. Simon