aboutsummaryrefslogtreecommitdiff
path: root/gdb/elf-none-tdep.c
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2023-09-25 10:32:14 +0100
committerAndrew Burgess <aburgess@redhat.com>2023-10-03 17:43:50 +0100
commitc14993e9dc598a5ca126121f7d2a0898c26908bc (patch)
treea6929feaca342096ccba5150d50f87217295481d /gdb/elf-none-tdep.c
parent1c9b44fe07569b6ed99557faa87d5b1c21413fbf (diff)
downloadgdb-c14993e9dc598a5ca126121f7d2a0898c26908bc.zip
gdb-c14993e9dc598a5ca126121f7d2a0898c26908bc.tar.gz
gdb-c14993e9dc598a5ca126121f7d2a0898c26908bc.tar.bz2
gdb/corefile: write NT_GDB_TDESC based on signalled thread
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.
Diffstat (limited to 'gdb/elf-none-tdep.c')
-rw-r--r--gdb/elf-none-tdep.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/gdb/elf-none-tdep.c b/gdb/elf-none-tdep.c
index ce2db02..cae6600 100644
--- a/gdb/elf-none-tdep.c
+++ b/gdb/elf-none-tdep.c
@@ -110,8 +110,12 @@ elf_none_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd,
}
- /* Target description. */
- 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);
+ gcore_elf_make_tdesc_note (gdbarch, obfd, &note_data, note_size);
return note_data;
}