aboutsummaryrefslogtreecommitdiff
path: root/libc/print.c
diff options
context:
space:
mode:
authorMarvin Borner2021-03-02 21:06:05 +0100
committerMarvin Borner2021-03-02 21:06:05 +0100
commit557cb0919118624eacbe4bb95de7bd6b4decab91 (patch)
tree4d63f3ec874082139e42a5595e4890efafbbe94d /libc/print.c
parentacc4b7ccc133b64312e7ab1da3225b7945b1e13d (diff)
Added stack tracer
idk why
Diffstat (limited to 'libc/print.c')
-rw-r--r--libc/print.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/libc/print.c b/libc/print.c
index 91ecf8f..ca2ab98 100644
--- a/libc/print.c
+++ b/libc/print.c
@@ -214,6 +214,20 @@ int print(const char *str)
return strlen(str);
}
+void print_trace(u32 count)
+{
+ struct frame {
+ struct frame *ebp;
+ u32 eip;
+ } * stk;
+ __asm__ volatile("movl %%ebp, %0;" : "=r"(stk));
+ print("EBP\tEIP\n");
+ for (u32 i = 0; stk && i < count; i++) {
+ printf("0x%x\t0x%x\n", stk->ebp, stk->eip);
+ stk = stk->ebp;
+ }
+}
+
#endif
void panic(const char *format, ...)