summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authortrimill <trimill@trimillxyz.org>2024-01-30 10:19:33 -0500
committertrimill <trimill@trimillxyz.org>2024-01-30 10:19:33 -0500
commit6b8f33c22d41488b88fcd35331867858d8f67763 (patch)
tree4a62ac9c6136a9e9b94cab0b6838add70accfe31 /include
parentrefactor, improve exception message (diff)
downloadcorn-6b8f33c22d41488b88fcd35331867858d8f67763.tar.gz
corn-6b8f33c22d41488b88fcd35331867858d8f67763.tar.bz2
corn-6b8f33c22d41488b88fcd35331867858d8f67763.zip
added backtraces
Diffstat (limited to 'include')
-rw-r--r--include/backtrace.h20
-rw-r--r--include/panic.h2
2 files changed, 22 insertions, 0 deletions
diff --git a/include/backtrace.h b/include/backtrace.h
new file mode 100644
index 0000000..2abece7
--- /dev/null
+++ b/include/backtrace.h
@@ -0,0 +1,20 @@
+#pragma once
+
+#include <stddef.h>
+
+// Fill dst with a stack trace consisting of return addresses
+// in order from top to bottom. returns the number filled (at most len)
+size_t backtrace(void **dst, size_t len);
+
+
+// same as backtrace but with specified instruction and base pointer
+size_t backtrace_ex(void **dst, size_t len, void* ip, void *bp);
+
+// TODO symbols
+//size_t backtrace_symbols(char *const *dst, size_t len);
+
+// Log a backtrace
+void log_backtrace();
+
+// same as log_backtrace with specified insruction and base pointer
+void log_backtrace_ex(void *ip, void *bp);
diff --git a/include/panic.h b/include/panic.h
index 21715fd..4f8592e 100644
--- a/include/panic.h
+++ b/include/panic.h
@@ -6,3 +6,5 @@
#define panic(msg) _panic_impl(_PANIC_STR(__LINE__), __FILE__, msg)
_Noreturn void _panic_impl(char *line, char *file, char *msg);
+
+_Noreturn void panic_interrupt(void *ip, void *bp, char *msg);