From 88285ca7d9ac11c99b01a44d3525acb82d35e1de Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Sat, 5 Jul 2025 04:15:20 +0000 Subject: kernel/amd64: Add support for coredumps To make debugging userland program crashes easier, this commit introduces coredumps that store the last known process state into a temporary /tmp/core.X file (where X is the PID of the faulting process). Signed-off-by: Ian Moffett --- sys/include/sys/proc.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'sys/include') diff --git a/sys/include/sys/proc.h b/sys/include/sys/proc.h index 7aa04b2..54764d0 100644 --- a/sys/include/sys/proc.h +++ b/sys/include/sys/proc.h @@ -53,6 +53,26 @@ #define PROC_MAX_FILEDES 256 #define PROC_SIGMAX 64 +/* + * The coredump structure, contains information + * about crashes. + * + * @pid: PID of process that has crashed + * @fault_addr: Address of faulting memory access + * @tf: Copy of the programs trapframe + * @checksum: CRC32 checksum of entire coredump + * + * XXX: DO NOT REORDER (always add to the end before 'checksum') + */ +struct __packed coredump { + pid_t pid; + uintptr_t fault_addr; + struct trapframe tf; + + /* XXX: Add entries above the checksum */ + uint32_t checksum; +}; + struct proc { pid_t pid; struct exec_prog exec; @@ -88,7 +108,9 @@ struct proc { struct proc *this_td(void); struct proc *get_child(struct proc *cur, pid_t pid); + void proc_reap(struct proc *td); +void proc_coredump(struct proc *td, uintptr_t fault_addr); pid_t getpid(void); pid_t getppid(void); -- cgit v1.2.3