From: Matthieu Longo <matthieu.longo@arm.com>
To: <gdb-patches@sourceware.org>
Cc: Luis Machado <luis.machado@amd.com>,
Luis Machado <luis.machado.foss@gmail.com>,
Andrew Burgess <aburgess@redhat.com>,
"Yury Khrustalev" <yury.khrustalev@arm.com>,
Pedro Alves <pedro@palves.net>, "Tom Tromey" <tom@tromey.com>,
Matthieu Longo <matthieu.longo@arm.com>
Subject: [PATCH v1 10/10] gdb/linux: add helpers to read AT_HWCAP3 and AT_HWCAP4
Date: Tue, 7 Jul 2026 16:49:00 +0100 [thread overview]
Message-ID: <20260707154900.94542-11-matthieu.longo@arm.com> (raw)
In-Reply-To: <20260707154900.94542-1-matthieu.longo@arm.com>
Add linux_get_hwcap3 and linux_get_hwcap4 helpers to GDB and gdbserver,
mirroring the existing linux_get_hwcap and linux_get_hwcap2 interfaces.
The new helpers retrieve the AT_HWCAP3 and AT_HWCAP4 auxiliary vector
entry either from explicitly supplied auxv data or from the current
inferior.
This prepares for future features that depend on HWCAP3 and HWCAP4
capability bits.
---
gdb/linux-tdep.c | 38 ++++++++++++++++++++++++++++++++++++++
gdb/linux-tdep.h | 22 ++++++++++++++++++++++
gdbserver/linux-low.cc | 28 ++++++++++++++++++++++++++++
gdbserver/linux-low.h | 8 ++++++++
4 files changed, 96 insertions(+)
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index d89c5ae8504..24774ad3c3d 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -3142,6 +3142,44 @@ linux_get_hwcap2 ()
current_inferior ()->arch ());
}
+/* See linux-tdep.h. */
+
+CORE_ADDR
+linux_get_hwcap3 (const std::optional<gdb::byte_vector> &auxv,
+ target_ops *target, gdbarch *gdbarch)
+{
+ return linux_get_hwcap_helper (auxv, target, gdbarch, AT_HWCAP3);
+}
+
+/* See linux-tdep.h. */
+
+CORE_ADDR
+linux_get_hwcap3 ()
+{
+ return linux_get_hwcap3 (target_read_auxv (),
+ current_inferior ()->top_target (),
+ current_inferior ()->arch ());
+}
+
+/* See linux-tdep.h. */
+
+CORE_ADDR
+linux_get_hwcap4 (const std::optional<gdb::byte_vector> &auxv,
+ target_ops *target, gdbarch *gdbarch)
+{
+ return linux_get_hwcap_helper (auxv, target, gdbarch, AT_HWCAP4);
+}
+
+/* See linux-tdep.h. */
+
+CORE_ADDR
+linux_get_hwcap4 ()
+{
+ return linux_get_hwcap4 (target_read_auxv (),
+ current_inferior ()->top_target (),
+ current_inferior ()->arch ());
+}
+
/* Display whether the gcore command is using the
/proc/PID/coredump_filter file. */
diff --git a/gdb/linux-tdep.h b/gdb/linux-tdep.h
index c19839fde2c..9b30392fb04 100644
--- a/gdb/linux-tdep.h
+++ b/gdb/linux-tdep.h
@@ -91,6 +91,28 @@ extern CORE_ADDR linux_get_hwcap2 (const std::optional<gdb::byte_vector> &auxv,
extern CORE_ADDR linux_get_hwcap2 ();
+/* Fetch the AT_HWCAP3 entry from auxv data AUXV. Use TARGET and GDBARCH to
+ parse auxv entries.
+
+ On error, 0 is returned. */
+extern CORE_ADDR linux_get_hwcap3 (const std::optional<gdb::byte_vector> &auxv,
+ struct target_ops *target, gdbarch *gdbarch);
+
+/* Same as the above, but obtain all the inputs from the current inferior. */
+
+extern CORE_ADDR linux_get_hwcap3 ();
+
+/* Fetch the AT_HWCAP4 entry from auxv data AUXV. Use TARGET and GDBARCH to
+ parse auxv entries.
+
+ On error, 0 is returned. */
+extern CORE_ADDR linux_get_hwcap4 (const std::optional<gdb::byte_vector> &auxv,
+ struct target_ops *target, gdbarch *gdbarch);
+
+/* Same as the above, but obtain all the inputs from the current inferior. */
+
+extern CORE_ADDR linux_get_hwcap4 ();
+
/* Returns true if ADDR belongs to a shadow stack memory range. If this
is the case, assign the shadow stack memory range to RANGE
[start_address, end_address). */
diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index ade5e9e2a1c..029f64321c2 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -70,6 +70,14 @@
#define AT_HWCAP2 26
#endif
+#ifndef AT_HWCAP3
+#define AT_HWCAP3 29
+#endif
+
+#ifndef AT_HWCAP4
+#define AT_HWCAP4 30
+#endif
+
/* Some targets did not define these ptrace constants from the start,
so gdbserver defines them locally here. In the future, these may
be removed after they are added to asm/ptrace.h. */
@@ -7198,6 +7206,26 @@ linux_get_hwcap2 (int pid, int wordsize)
return hwcap2;
}
+/* See linux-low.h. */
+
+CORE_ADDR
+linux_get_hwcap3 (int pid, int wordsize)
+{
+ CORE_ADDR hwcap3 = 0;
+ linux_get_auxv (pid, wordsize, AT_HWCAP3, &hwcap3);
+ return hwcap3;
+}
+
+/* See linux-low.h. */
+
+CORE_ADDR
+linux_get_hwcap4 (int pid, int wordsize)
+{
+ CORE_ADDR hwcap4 = 0;
+ linux_get_auxv (pid, wordsize, AT_HWCAP4, &hwcap4);
+ return hwcap4;
+}
+
#ifdef HAVE_LINUX_REGSETS
void
initialize_regsets_info (struct regsets_info *info)
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 03e11202955..c2ebdc228bc 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -977,4 +977,12 @@ CORE_ADDR linux_get_hwcap (int pid, int wordsize);
CORE_ADDR linux_get_hwcap2 (int pid, int wordsize);
+/* Fetch the AT_HWCAP3 entry from the auxv vector, where entries are length
+ WORDSIZE, of process with pid PID. If no entry was found, return 0. */
+CORE_ADDR linux_get_hwcap3 (int pid, int wordsize);
+
+/* Fetch the AT_HWCAP4 entry from the auxv vector, where entries are length
+ WORDSIZE, of process with pid PID. If no entry was found, return 0. */
+CORE_ADDR linux_get_hwcap4 (int pid, int wordsize);
+
#endif /* GDBSERVER_LINUX_LOW_H */
--
2.55.0
next prev parent reply other threads:[~2026-07-07 15:53 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-07 15:48 [PATCH v1 00/10] gdb: bugfix 31207 and various refactoring in linux-tdep Matthieu Longo
2026-07-07 15:48 ` [PATCH v1 01/10] gdb/linux-tdep: change linux_fill_prpsinfo to return bool Matthieu Longo
2026-07-09 6:26 ` Thiago Jung Bauermann
2026-07-09 12:23 ` Simon Marchi
2026-07-27 14:38 ` Matthieu Longo
2026-07-07 15:48 ` [PATCH v1 02/10] gdb: rely on the first alive thread TPID when reading Linux procfs files Matthieu Longo
2026-07-09 6:29 ` Thiago Jung Bauermann
2026-07-13 9:11 ` Matthieu Longo
2026-07-09 14:24 ` Simon Marchi
2026-07-14 15:47 ` Matthieu Longo
2026-07-07 15:48 ` [PATCH v1 03/10] target_fileio_read_stralloc: add an optional length parameter Matthieu Longo
2026-07-09 6:30 ` Thiago Jung Bauermann
2026-07-13 15:26 ` Matthieu Longo
2026-07-24 2:50 ` Thiago Jung Bauermann
2026-07-27 14:52 ` Matthieu Longo
2026-07-29 1:57 ` Thiago Jung Bauermann
2026-07-21 21:28 ` Luis
2026-07-27 14:48 ` Matthieu Longo
2026-07-27 14:53 ` Matthieu Longo
2026-07-07 15:48 ` [PATCH v1 04/10] gdb support: add gdb::replace algorithm for iterators and ranges Matthieu Longo
2026-07-09 6:30 ` Thiago Jung Bauermann
2026-07-10 21:21 ` Kevin Buettner
2026-07-13 15:51 ` Matthieu Longo
2026-07-21 21:33 ` Luis
2026-07-27 14:58 ` Matthieu Longo
2026-07-07 15:48 ` [PATCH v1 05/10] gdb: introduce helper class file_reader_t Matthieu Longo
2026-07-09 6:33 ` Thiago Jung Bauermann
2026-07-13 17:17 ` Matthieu Longo
2026-07-10 21:43 ` Kevin Buettner
2026-07-13 16:31 ` Matthieu Longo
2026-07-13 15:50 ` Schimpe, Christina
2026-07-13 17:12 ` Matthieu Longo
2026-07-22 16:36 ` Joos, Christina
2026-07-27 15:13 ` Matthieu Longo
2026-07-07 15:48 ` [PATCH v1 06/10] gdb/linux-tdep: migrate linux_info_proc to file_reader_t Matthieu Longo
2026-07-09 6:35 ` Thiago Jung Bauermann
2026-07-13 17:20 ` Matthieu Longo
2026-07-21 21:43 ` Luis
2026-07-27 17:11 ` Matthieu Longo
2026-07-07 15:48 ` [PATCH v1 07/10] gdb/linux-tdep: migrate linux_find_memory_regions_full " Matthieu Longo
2026-07-09 6:36 ` Thiago Jung Bauermann
2026-07-14 8:40 ` Matthieu Longo
2026-07-24 2:51 ` Thiago Jung Bauermann
2026-07-21 21:47 ` Luis
2026-07-27 17:14 ` Matthieu Longo
2026-07-07 15:48 ` [PATCH v1 08/10] gdb/linux-tdep: migrate parse_smaps_data " Matthieu Longo
2026-07-09 6:41 ` Thiago Jung Bauermann
2026-07-14 8:49 ` Matthieu Longo
2026-07-24 2:52 ` Thiago Jung Bauermann
2026-07-21 21:49 ` Luis
2026-07-27 17:17 ` Matthieu Longo
2026-07-07 15:48 ` [PATCH v1 09/10] gdb/linux-tdep: parse ProtectionKey in /proc/PID/smaps Matthieu Longo
2026-07-09 6:42 ` Thiago Jung Bauermann
2026-07-14 9:12 ` Matthieu Longo
2026-07-14 9:29 ` Matthieu Longo
2026-07-24 2:58 ` Thiago Jung Bauermann
2026-07-24 10:27 ` Yury Khrustalev
2026-07-25 6:40 ` Thiago Jung Bauermann
2026-07-27 8:22 ` Yury Khrustalev
2026-07-29 1:10 ` Thiago Jung Bauermann
2026-07-21 21:57 ` Luis
2026-07-27 17:54 ` Matthieu Longo
2026-07-07 15:49 ` Matthieu Longo [this message]
2026-07-09 6:44 ` [PATCH v1 10/10] gdb/linux: add helpers to read AT_HWCAP3 and AT_HWCAP4 Thiago Jung Bauermann
2026-07-21 21:58 ` Luis
2026-07-27 17:32 ` Matthieu Longo
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=20260707154900.94542-11-matthieu.longo@arm.com \
--to=matthieu.longo@arm.com \
--cc=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=luis.machado.foss@gmail.com \
--cc=luis.machado@amd.com \
--cc=pedro@palves.net \
--cc=tom@tromey.com \
--cc=yury.khrustalev@arm.com \
/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