diff options
author | Luis Machado <luis.machado@arm.com> | 2023-09-07 16:20:15 +0100 |
---|---|---|
committer | Luis Machado <luis.machado@arm.com> | 2023-10-04 16:23:40 +0100 |
commit | b93d537fba70f46eae96edaea6010314c047f7ec (patch) | |
tree | f4b0acb209a3858cf21b30367e3a245cb3b51612 /gdb/arch-utils.h | |
parent | 7070423f17ff4756aec92aab15a88681a4f9df11 (diff) | |
download | gdb-b93d537fba70f46eae96edaea6010314c047f7ec.zip gdb-b93d537fba70f46eae96edaea6010314c047f7ec.tar.gz gdb-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.h')
-rw-r--r-- | gdb/arch-utils.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h index 2bdc325..e53950c 100644 --- a/gdb/arch-utils.h +++ b/gdb/arch-utils.h @@ -305,6 +305,12 @@ extern void default_read_core_file_mappings read_core_file_mappings_pre_loop_ftype pre_loop_cb, read_core_file_mappings_loop_ftype loop_cb); +/* Default implementation of gdbarch + use_target_description_from_corefile_notes. */ +extern bool default_use_target_description_from_corefile_notes + (struct gdbarch *gdbarch, + struct bfd *corefile_bfd); + /* Default implementation of gdbarch default_get_return_buf_addr method. */ extern CORE_ADDR default_get_return_buf_addr (struct type *val_typegdbarch, frame_info_ptr cur_frame); |