summaryrefslogtreecommitdiff
path: root/sys/include
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-07-05 04:15:20 +0000
committerIan Moffett <ian@osmora.org>2025-07-05 04:15:20 +0000
commit88285ca7d9ac11c99b01a44d3525acb82d35e1de (patch)
treecd21b0bf1e0e8e226925cf12b66da13032668ab9 /sys/include
parent68e404c22776f547158aa8f1a88f29c757167591 (diff)
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 <ian@osmora.org>
Diffstat (limited to 'sys/include')
-rw-r--r--sys/include/sys/proc.h22
1 files changed, 22 insertions, 0 deletions
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);