67 lines
2.9 KiB
Diff
67 lines
2.9 KiB
Diff
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
|
From: root <root@dell-pexr7620-01.khw.eng.bos2.dc.redhat.com>
|
|
Date: Thu, 11 Apr 2024 14:05:47 -0700
|
|
Subject: gdb-rhel-10464-xsave-update-21of21.patch
|
|
|
|
;; Backport "gdb/corefile: write NT_GDB_TDESC based on signalled thread"
|
|
;; (Andrew Burgess, RHEL-10464)
|
|
|
|
When creating a core file from within GDB we include a NT_GDB_TDESC
|
|
that includes the target description of the architecture in use.
|
|
|
|
For architectures with dynamic architectures (e.g. AArch64 with
|
|
sve/sme) the original architecture, calculated from the original
|
|
target description, might not match the per-thread architecture.
|
|
|
|
In the general case, where each thread has a different architecture,
|
|
then we really need a separate NT_GDB_TDESC for each thread, however,
|
|
there's currently no way to read in multiple NT_GDB_TDESC.
|
|
|
|
This commit is a step towards per-thread NT_GDB_TDESC. In this commit
|
|
I have updated the function that writes the NT_GDB_TDESC to accept a
|
|
gdbarch (rather than calling target_gdbarch() to find a gdbarch), and
|
|
I now pass in the gdbarch of the signalled thread.
|
|
|
|
In many cases (though NOT all) targets with dynamic architectures
|
|
really only use a single architecture, even when there are multiple
|
|
threads, so in the common case, this should ensure that GDB emits an
|
|
architecture that is more likely to be correct.
|
|
|
|
Additional work will be needed in order to support corefiles with
|
|
truly per-thread architectures, but that will need to be done in the
|
|
future.
|
|
|
|
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
|
|
--- a/gdb/linux-tdep.c
|
|
+++ b/gdb/linux-tdep.c
|
|
@@ -1975,12 +1975,12 @@ find_signalled_thread ()
|
|
set to nullptr. */
|
|
|
|
static char *
|
|
-gcore_elf_make_tdesc_note (bfd *obfd,
|
|
+gcore_elf_make_tdesc_note (struct gdbarch *gdbarch, bfd *obfd,
|
|
char *note_data,
|
|
int *note_size)
|
|
{
|
|
/* Append the target description to the core file. */
|
|
- const struct target_desc *tdesc = gdbarch_target_desc (target_gdbarch ());
|
|
+ const struct target_desc *tdesc = gdbarch_target_desc (gdbarch);
|
|
const char *tdesc_xml
|
|
= tdesc == nullptr ? nullptr : tdesc_get_features_xml (tdesc);
|
|
if (tdesc_xml != nullptr && *tdesc_xml != '\0')
|
|
@@ -2083,8 +2083,12 @@ linux_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size)
|
|
note_data = linux_make_mappings_corefile_notes (gdbarch, obfd,
|
|
note_data, note_size);
|
|
|
|
- /* Target description. */
|
|
- note_data = gcore_elf_make_tdesc_note (obfd, note_data, note_size);
|
|
+ /* Include the target description when possible. Some architectures
|
|
+ allow for per-thread gdbarch so we should really be emitting a tdesc
|
|
+ per-thread, however, we don't currently support reading in a
|
|
+ per-thread tdesc, so just emit the tdesc for the signalled thread. */
|
|
+ gdbarch = target_thread_architecture (signalled_thr->ptid);
|
|
+ note_data = gcore_elf_make_tdesc_note (gdbarch, obfd, note_data, note_size);
|
|
|
|
return note_data;
|
|
}
|