@samitouri / QOSamiQemu / commits / 2304a65529

linux-user/alpha: write the floating-point registers to a core dump

A guest core carried only the general-purpose registers, so a debugger opening one reported every floating-point register as unavailable -- including the arguments of the function that crashed. Implement HAVE_ELF_CORE_FPREGS for Alpha: define target_elf_fpregset_t to match the kernel's layout ($f0-$f30 plus the control register in the slot $f31 would occupy) and fill it from elf_core_copy_fpregs(). Checked with lldb on a core from a program that faults with live values in $f16 and $f17: both read back correctly, as does the control register. Signed-off-by: Matt Turner <mattst88@gmail.com> Reviewed-by: Helge Deller <deller@gmx.de> Signed-off-by: Helge Deller <deller@gmx.de>

Matt Turner committed Aug 5, 2026 at 13:15 UTC 2304a655296aa3bf5e416cf5ce33e481fb87f73a
2 files changed +21
linux-user/alpha/elfload.c
+10
@@ -32,3 +32,13 @@ const char *get_elf_cpu_model(uint32_t eflags)
32 {
33 return "ev67";
34 }
35 +
36 +void elf_core_copy_fpregs(target_elf_fpregset_t *r, const CPUAlphaState *env)
37 +{
38 + int i;
39 +
40 + for (i = 0; i < 31; i++) {
41 + r->fpr[i] = tswap64(env->fir[i]);
42 + }
43 + r->fpcr = tswap64(cpu_alpha_load_fpcr((CPUAlphaState *)env));
44 +}
linux-user/alpha/target_elf.h
+11
@@ -19,6 +19,17 @@
19 * r0-r30 at indices 0-30, pc at 31, ps at 32.
20 * r31 (hardwired zero) is not stored; pc occupies index 31.
21 */
22 +/*
23 + * The floating-point note holds $f0 through $f30 and then the control
24 + * register in the slot $f31 would occupy; $f31 reads as zero.
25 + */
26 +#define HAVE_ELF_CORE_FPREGS 1
27 +
28 +typedef struct target_elf_fpregset_t {
29 + uint64_t fpr[31]; /* $f0-$f30 */
30 + uint64_t fpcr; /* the slot for $f31 */
31 +} target_elf_fpregset_t;
32 +
33 typedef struct target_elf_gregset_t {
34 abi_ulong regs[31]; /* integer registers r0-r30 [0..30] */
35 abi_ulong pc; /* program counter [31] */