aboutsummaryrefslogtreecommitdiff
path: root/gdb/arch-utils.c
diff options
context:
space:
mode:
authorLuis Machado <luis.machado@arm.com>2023-09-07 16:20:15 +0100
committerLuis Machado <luis.machado@arm.com>2023-10-04 16:23:40 +0100
commitb93d537fba70f46eae96edaea6010314c047f7ec (patch)
treef4b0acb209a3858cf21b30367e3a245cb3b51612 /gdb/arch-utils.c
parent7070423f17ff4756aec92aab15a88681a4f9df11 (diff)
downloadbinutils-b93d537fba70f46eae96edaea6010314c047f7ec.zip
binutils-b93d537fba70f46eae96edaea6010314c047f7ec.tar.gz
binutils-b93d537fba70f46eae96edaea6010314c047f7ec.tar.bz2
corefile/bug: Add hook to control the use of target description notes from corefiles
Due to the nature of the AArch64 SVE/SME extensions in GDB, each thread can potentially have distinct target descriptions/gdbarches. When loading a gcore-generated core file, at the moment GDB gives priority to the target description dumped to NT_GDB_TDESC. Though technically correct for most targets, it doesn't work correctly for AArch64 with SVE or SME support. The correct approach for AArch64/Linux is to either have per-thread target description notes in the corefiles or to rely on the gdbarch_core_read_description hook, so it can figure out the proper target description for a given thread based on the various available register notes. The former, although more correct, doesn't address the case of existing gdb's that only output a single target description note. This patch goes for the latter, and adds a new gdbarch hook to conditionalize the use of the corefile target description note. The hook is called use_target_description_from_corefile_notes. The hook defaults to returning true, meaning targets will use the corefile target description note. AArch64 Linux overrides the hook to return false when it detects any of the SVE or SME register notes in the corefile. Otherwise it should be fine for AArch64 Linux to use the corefile target description note. When we support per-thread target description notes, then we can augment the AArch64 Linux hook to rely on those notes. Regression-tested on aarch64-linux Ubuntu 22.04/20.04. Approved-By: Simon Marchi <simon.marchi@efficios.com> Reviewed-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
Diffstat (limited to 'gdb/arch-utils.c')
-rw-r--r--gdb/arch-utils.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index 56c7fd2..2e597be 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -1092,6 +1092,16 @@ default_read_core_file_mappings
{
}
+/* See arch-utils.h. */
+bool
+default_use_target_description_from_corefile_notes (struct gdbarch *gdbarch,
+ struct bfd *corefile_bfd)
+{
+ /* Always trust the corefile target description contained in the target
+ description note. */
+ return true;
+}
+
CORE_ADDR
default_get_return_buf_addr (struct type *val_type, frame_info_ptr cur_frame)
{