From: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
To: gdb-patches@sourceware.org
Cc: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
Subject: [PATCH 7/8] gdb/aarch64: Factor out most of the thread_architecture method
Date: Thu, 8 Sep 2022 06:41:50 +0000 [thread overview]
Message-ID: <20220908064151.3959930-8-thiago.bauermann@linaro.org> (raw)
In-Reply-To: <20220908064151.3959930-1-thiago.bauermann@linaro.org>
The same logic will be used by a subsequent commit when remotely debugging
an aarch64-linux target.
The code isn't changed, just moved around.
---
gdb/aarch64-linux-nat.c | 25 +------------------------
gdb/aarch64-tdep.c | 34 ++++++++++++++++++++++++++++++++++
gdb/aarch64-tdep.h | 2 ++
3 files changed, 37 insertions(+), 24 deletions(-)
diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index 633cbc08796c..ff4c69f6af7d 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -891,36 +891,13 @@ aarch64_linux_nat_target::thread_architecture (ptid_t ptid)
inferior *inf = find_inferior_ptid (this, ptid);
gdb_assert (inf != NULL);
- /* If this is a 32-bit architecture, then this is ARM, not AArch64.
- There's no SVE vectors here, so just return the inferior
- architecture. */
- if (gdbarch_bfd_arch_info (inf->gdbarch)->bits_per_word == 32)
- return inf->gdbarch;
-
- /* Only return it if the current vector length matches the one in the tdep. */
- aarch64_gdbarch_tdep *tdep
- = gdbarch_tdep<aarch64_gdbarch_tdep> (inf->gdbarch);
int vq = aarch64_sve_get_vq (ptid.lwp ());
/* If ptrace fails we can't determine vq, but the thread_architecture method
always succeeds so all we can do here is assert that vq is valid. */
gdb_assert (vq >= 0);
- if (vq == tdep->vq)
- return inf->gdbarch;
-
- /* We reach here if the vector length for the thread is different from its
- value at process start. Lookup gdbarch via info (potentially creating a
- new one) by using a target description that corresponds to the new vq value
- and the current architecture features. */
-
- const struct target_desc *tdesc = gdbarch_target_desc (inf->gdbarch);
- aarch64_features features = aarch64_features_from_target_desc (tdesc);
- features.vq = vq;
- struct gdbarch_info info;
- info.bfd_arch_info = bfd_lookup_arch (bfd_arch_aarch64, bfd_mach_aarch64);
- info.target_desc = aarch64_read_description (features);
- return gdbarch_find_by_info (info);
+ return aarch64_update_gdbarch (inf->gdbarch, vq);
}
/* Implement the "supports_memory_tagging" target_ops method. */
diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index 7229b53838e8..18c2b1ec1523 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -3420,6 +3420,40 @@ aarch64_cannot_store_register (struct gdbarch *gdbarch, int regnum)
|| regnum == AARCH64_PAUTH_CMASK_REGNUM (tdep->pauth_reg_base));
}
+/* Helper function for the "thread_architecture" target_ops method.
+
+ Returns a new gdbarch that is equivalent to the given gdbarch, but with SVE
+ registers reflecting the given vq value. */
+
+struct gdbarch *
+aarch64_update_gdbarch (struct gdbarch *gdbarch, uint64_t vq)
+{
+ /* If this is a 32-bit architecture, then this is ARM, not AArch64.
+ There's no SVE vectors here, so just return the inferior
+ architecture. */
+ if (gdbarch_bfd_arch_info (gdbarch)->bits_per_word == 32)
+ return gdbarch;
+
+ /* Only return it if the current vector length matches the one in the tdep. */
+ aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
+ if (vq == tdep->vq)
+ return gdbarch;
+
+ /* We reach here if the vector length for the thread is different from its
+ value at process start. Lookup gdbarch via info (potentially creating a
+ new one) by using a target description that corresponds to the new vq
+ value and the current architecture features. */
+
+ const struct target_desc *tdesc = gdbarch_target_desc (gdbarch);
+ aarch64_features features = aarch64_features_from_target_desc (tdesc);
+ features.vq = vq;
+
+ struct gdbarch_info info;
+ info.bfd_arch_info = bfd_lookup_arch (bfd_arch_aarch64, bfd_mach_aarch64);
+ info.target_desc = aarch64_create_target_description (features);
+ return gdbarch_find_by_info (info);
+}
+
/* Implement the stack_frame_destroyed_p gdbarch method. */
static int
diff --git a/gdb/aarch64-tdep.h b/gdb/aarch64-tdep.h
index d8513023c376..3d78515e167f 100644
--- a/gdb/aarch64-tdep.h
+++ b/gdb/aarch64-tdep.h
@@ -139,4 +139,6 @@ void aarch64_displaced_step_fixup (struct gdbarch *gdbarch,
bool aarch64_displaced_step_hw_singlestep (struct gdbarch *gdbarch);
+struct gdbarch *aarch64_update_gdbarch (struct gdbarch *gdbarch, uint64_t vq);
+
#endif /* aarch64-tdep.h */
next prev parent reply other threads:[~2022-09-08 6:43 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-08 6:41 [PATCH 0/8] gdbserver improvements for AArch64 SVE support Thiago Jung Bauermann
2022-09-08 6:41 ` [PATCH 1/8] gdbserver: Add asserts in register_size and register_data functions Thiago Jung Bauermann
2022-09-20 7:36 ` Luis Machado
2022-11-26 1:36 ` Thiago Jung Bauermann
2022-09-08 6:41 ` [PATCH 2/8] gdbserver: Add thread parameter to linux_get_auxv and linux_get_hwcap Thiago Jung Bauermann
2022-09-20 7:43 ` Luis Machado
2022-11-26 1:37 ` Thiago Jung Bauermann
2022-09-08 6:41 ` [PATCH 3/8] gdb, gdbserver/aarch64-linux: Allow aarch64_sve_get_vq to return error Thiago Jung Bauermann
2022-09-20 8:07 ` Luis Machado
2022-11-26 1:42 ` Thiago Jung Bauermann
2022-09-08 6:41 ` [PATCH 4/8] gdbserver/linux-aarch64: Factor out function to get aarch64_features Thiago Jung Bauermann
2022-09-20 8:08 ` Luis Machado
2022-11-26 1:44 ` Thiago Jung Bauermann
2022-09-08 6:41 ` [PATCH 5/8] gdbserver: Move target description from being per-process to being per-thread Thiago Jung Bauermann
2022-09-20 11:21 ` Luis Machado
2022-11-26 1:47 ` Thiago Jung Bauermann
2022-09-08 6:41 ` [PATCH 6/8] gdbserver/linux-aarch64: When inferior stops, update its target description Thiago Jung Bauermann
2022-09-20 8:48 ` Luis Machado
2022-11-26 1:49 ` Thiago Jung Bauermann
2022-09-08 6:41 ` Thiago Jung Bauermann [this message]
2022-09-20 8:52 ` [PATCH 7/8] gdb/aarch64: Factor out most of the thread_architecture method Luis Machado
2022-11-26 1:49 ` Thiago Jung Bauermann
2022-09-08 6:41 ` [PATCH 8/8] gdb/aarch64: When remote debugging detect changes in the target description Thiago Jung Bauermann
2022-09-20 8:59 ` Luis Machado
2022-11-26 1:50 ` Thiago Jung Bauermann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220908064151.3959930-8-thiago.bauermann@linaro.org \
--to=thiago.bauermann@linaro.org \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).