aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuis Machado <luis.machado@arm.com>2023-01-31 17:17:09 +0000
committerLuis Machado <luis.machado@arm.com>2023-10-04 16:23:40 +0100
commit7070423f17ff4756aec92aab15a88681a4f9df11 (patch)
treeddd0bd032bd48f137463beb6a79ac01412f37553
parent147fa85a600960a1e403bbed4cb76c9d7d8ab6c5 (diff)
downloadgdb-7070423f17ff4756aec92aab15a88681a4f9df11.zip
gdb-7070423f17ff4756aec92aab15a88681a4f9df11.tar.gz
gdb-7070423f17ff4756aec92aab15a88681a4f9df11.tar.bz2
corefile/bug: Use thread-specific gdbarch when dumping register state to core files
When we have a core file generated by gdb (via the gcore command), gdb dumps the target description to a note. During loading of that core file, gdb will first try to load that saved target description. This works fine for almost all architectures. But AArch64 has a few dynamically-generated target descriptions/gdbarch depending on the vector length that was in use at the time the core file was generated. The target description gdb dumps to the core file note is the one generated at the time of attachment/startup. If, for example, the SVE vector length changed during execution, this would not reflect on the core file, as gdb would still dump the initial target description. Another issue is that the gdbarch potentially doesn't match the thread's real gdbarch, and so things like the register cache may have different formats and sizes. To address this, fetch the thread's architecture before dumping its register state. That way we will always use the correct target description/gdbarch. Approved-By: Simon Marchi <simon.marchi@efficios.com> Approved-By: Tom Tromey <tom@tromey.com> Reviewed-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
-rw-r--r--gdb/linux-tdep.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index 33f84c8..f03a5b9 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -2078,15 +2078,30 @@ linux_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size)
stop_signal = GDB_SIGNAL_0;
if (signalled_thr != nullptr)
- linux_corefile_thread (signalled_thr, gdbarch, obfd, note_data, note_size,
- stop_signal);
+ {
+ /* On some architectures, like AArch64, each thread can have a distinct
+ gdbarch (due to scalable extensions), and using the inferior gdbarch
+ is incorrect.
+
+ Fetch each thread's gdbarch and pass it down to the lower layers so
+ we can dump the right set of registers. */
+ linux_corefile_thread (signalled_thr,
+ target_thread_architecture (signalled_thr->ptid),
+ obfd, note_data, note_size, stop_signal);
+ }
for (thread_info *thr : current_inferior ()->non_exited_threads ())
{
if (thr == signalled_thr)
continue;
- linux_corefile_thread (thr, gdbarch, obfd, note_data, note_size,
- stop_signal);
+ /* On some architectures, like AArch64, each thread can have a distinct
+ gdbarch (due to scalable extensions), and using the inferior gdbarch
+ is incorrect.
+
+ Fetch each thread's gdbarch and pass it down to the lower layers so
+ we can dump the right set of registers. */
+ linux_corefile_thread (thr, target_thread_architecture (thr->ptid),
+ obfd, note_data, note_size, stop_signal);
}
if (!note_data)