@samitouri / QOSamiQemu / commits / 9db18ed063

linux-user/alpha: add coredump support

Define HAVE_ELF_CORE_DUMP and target_elf_gregset_t in target_elf.h, mirroring the kernel's elf_gregset_t (ELF_NGREG = 66): r0-r31 [0..31], f0-f31 [32..63], pc [64], unique [65]. Implement elf_core_copy_regs() in elfload.c to populate the gregset from CPUAlphaState. Without this, bprm->core_dump is NULL for Alpha targets. When a guest signal goes unhandled, dump_core_and_abort() skips the core write and falls through to die_with_signal(), which re-raises the signal to the host. The host kernel then writes an x86-64 core file for the qemu-alpha process instead of an Alpha guest core. v2: Store thread unique field, same as in Linux kernel. Added by Helge & suggested by Richard. Signed-off-by: Matt Turner <mattst88@gmail.com> Signed-off-by: Helge Deller <deller@gmx.de> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

Matt Turner committed May 25, 2026 at 17:53 UTC 9db18ed0631d09f349057c22f7872b2c45275d0c
2 files changed +25
linux-user/alpha/elfload.c
+12
@@ -3,8 +3,20 @@
3 #include "qemu/osdep.h"
4 #include "qemu.h"
5 #include "loader.h"
6 +#include "target_elf.h"
7
8
9 +void elf_core_copy_regs(target_elf_gregset_t *r, const CPUAlphaState *env)
10 +{
11 + int i;
12 +
13 + for (i = 0; i < 31; i++) {
14 + r->regs[i] = tswap64(env->ir[i]);
15 + }
16 + r->pc = tswap64(env->pc);
17 + r->unique = tswap64(env->unique);
18 +}
19 +
20 const char *get_elf_cpu_model(uint32_t eflags)
21 {
22 return "ev67";
linux-user/alpha/target_elf.h
+13
@@ -11,4 +11,17 @@
11 #define ELF_CLASS ELFCLASS64
12 #define ELF_MACHINE EM_ALPHA
13
14 +#define HAVE_ELF_CORE_DUMP 1
15 +
16 +/*
17 + * Matches the kernel's elf_gregset_t (ELF_NGREG = 33):
18 + * r0-r30 at indices 0-30, pc at 31, ps at 32.
19 + * r31 (hardwired zero) is not stored; pc occupies index 31.
20 + */
21 +typedef struct target_elf_gregset_t {
22 + abi_ulong regs[31]; /* integer registers r0-r30 [0..30] */
23 + abi_ulong pc; /* program counter [31] */
24 + abi_ulong unique; /* thread's UNIQUE field [32] */
25 +} target_elf_gregset_t;
26 +
27 #endif