From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x31.google.com (mail-oa1-x31.google.com [IPv6:2001:4860:4864:20::31]) by sourceware.org (Postfix) with ESMTPS id A73263858015 for ; Thu, 8 Sep 2022 06:43:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A73263858015 Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-11e9a7135easo41917737fac.6 for ; Wed, 07 Sep 2022 23:43:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=j4j1afw3lj1F3VKZ2UnrfOq+raFZ22XJAsrlUV+PP5Q=; b=xOL84i5j4DuI8lpgh47Ku2FfXJkch98GnRiijpljBJjXaK2eaa5hW2GdV3nV9pkAy3 ibcUqrbUpiJnTVarvSBFtWWS7V1FL9T/0rViOfxV4YoPsFWOL1jJGNUQZBo50+LSYh9K qWQsPbvlX8fFRGkMtBxTa/AU8gbg+O1zbnSMV6uMOtbWOB4Ww2em1WxG96G4o8zXKFCw 4QMjrEbCCmZgn3CRWBMV1515qbfB50W1OdimwFKxfNZPT+qum7w4MNEMTTmfji7XP+wM TA1nf9xYNQapHxgk0gPQLEaF2MgNQQjVPVTeiGm2xD2OxIIVTSEXXHSwaftMbCby9szW op/g== X-Gm-Message-State: ACgBeo3iJOtV0g1yu/F4m3gQhEDCcUTdwPhWZ0rEbrKkWJgW5rn+eVBd dqCw8T4bqLF+mtZ6g8d0O+g9mBuXlGR6QA== X-Google-Smtp-Source: AA6agR7jXcD7jPoD0ODwafWTXKYoTLOe7d+YuZpcjBOoF4JJnaB1yA5R/DKtahvVf9z9cKQB1QKcNg== X-Received: by 2002:a05:6870:5712:b0:12a:dff3:824e with SMTP id k18-20020a056870571200b0012adff3824emr618185oap.51.1662619386896; Wed, 07 Sep 2022 23:43:06 -0700 (PDT) Received: from localhost ([2804:14d:7e39:8470:8eab:4efc:ca3b:b046]) by smtp.gmail.com with ESMTPSA id y25-20020a9d4619000000b006389650374dsm8051981ote.54.2022.09.07.23.43.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Sep 2022 23:43:06 -0700 (PDT) From: Thiago Jung Bauermann To: gdb-patches@sourceware.org Cc: Thiago Jung Bauermann Subject: [PATCH 6/8] gdbserver/linux-aarch64: When inferior stops, update its target description Date: Thu, 8 Sep 2022 06:41:49 +0000 Message-Id: <20220908064151.3959930-7-thiago.bauermann@linaro.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220908064151.3959930-1-thiago.bauermann@linaro.org> References: <20220908064151.3959930-1-thiago.bauermann@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: Thu, 08 Sep 2022 06:43:09 -0000 Introduce new arch_update_tdesc method to the linux_process_target class. This allows aarch64-linux to probe the inferior's vq register and provide an updated target description reflecting the new vector length. --- gdbserver/linux-aarch64-low.cc | 21 +++++++++++++++++++++ gdbserver/linux-low.cc | 18 ++++++++++++++++++ gdbserver/linux-low.h | 5 +++++ 3 files changed, 44 insertions(+) diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc index 8c4306ab8794..cc90eae1e36b 100644 --- a/gdbserver/linux-aarch64-low.cc +++ b/gdbserver/linux-aarch64-low.cc @@ -99,6 +99,9 @@ protected: void low_arch_setup () override; + gdb::optional + arch_update_tdesc (const thread_info *thread) override; + bool low_cannot_fetch_register (int regno) override; bool low_cannot_store_register (int regno) override; @@ -902,6 +905,24 @@ aarch64_target::low_arch_setup () aarch64_linux_get_debug_reg_capacity (lwpid_of (current_thread)); } +/* Implementation of linux target ops method "arch_update_tdesc". */ + +gdb::optional +aarch64_target::arch_update_tdesc (const thread_info *thread) +{ + gdb::optional features + = aarch64_get_arch_features (thread); + + if (!features.has_value()) + return {}; + + /* Adjust the register sets we should use for this particular set of + features. */ + aarch64_adjust_register_sets(*features); + + return aarch64_linux_read_description (*features); +} + /* Implementation of linux target ops method "get_regs_info". */ const regs_info * diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc index d37eb120e114..2a7c6f166a65 100644 --- a/gdbserver/linux-low.cc +++ b/gdbserver/linux-low.cc @@ -483,6 +483,12 @@ linux_process_target::arch_setup_thread (thread_info *thread) low_arch_setup (); } +gdb::optional +linux_process_target::arch_update_tdesc (const thread_info *thread) +{ + return {}; +} + int linux_process_target::handle_extended_wait (lwp_info **orig_event_lwp, int wstat) @@ -2354,6 +2360,18 @@ linux_process_target::filter_event (int lwpid, int wstat) return; } } + else + { + /* Give the arch code an opportunity to update the target + description. */ + gdb::optional new_tdesc + = arch_update_tdesc (thread); + if (new_tdesc.has_value () && *new_tdesc != thread->tdesc) + { + regcache_release (); + thread->tdesc = *new_tdesc; + } + } } if (WIFSTOPPED (wstat) && child->must_set_ptrace_flags) diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h index bd1ec31dc5a4..fba462744953 100644 --- a/gdbserver/linux-low.h +++ b/gdbserver/linux-low.h @@ -602,6 +602,11 @@ class linux_process_target : public process_stratum_target /* Architecture-specific setup for the current thread. */ virtual void low_arch_setup () = 0; + /* Allows arch-specific code to update the target description when the + inferior stops. */ + virtual gdb::optional + arch_update_tdesc (const thread_info *thread); + /* Return false if we can fetch/store the register, true if we cannot fetch/store the register. */ virtual bool low_cannot_fetch_register (int regno) = 0;