From d373d2f3986d0f19e4f7d7d8517d382bc3eda99b Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Mon, 7 Oct 2024 19:33:05 -0400 Subject: [PATCH] the --- kern/entry.S | 10 +++++----- kern/monitor.c | 13 +++++++++++++ lib/printfmt.c | 8 +++----- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/kern/entry.S b/kern/entry.S index 9550bbb..808ac11 100644 --- a/kern/entry.S +++ b/kern/entry.S @@ -3,16 +3,16 @@ #include #include -# Shift Right Logical +# Shift Right Logical #define SRL(val, shamt) (((val) >> (shamt)) & ~(-1 << (32 - (shamt)))) ################################################################### -# The kernel (this code) is linked at address ~(KERNBASE + 1 Meg), +# The kernel (this code) is linked at address ~(KERNBASE + 1 Meg), # but the bootloader loads it at address ~1 Meg. -# +# # RELOC(x) maps a symbol x from its link address to its actual -# location in physical memory (its load address). +# location in physical memory (its load address). ################################################################### #define RELOC(x) ((x) - KERNBASE) @@ -91,6 +91,6 @@ spin: jmp spin .globl bootstack bootstack: .space KSTKSIZE - .globl bootstacktop + .globl bootstacktop bootstacktop: diff --git a/kern/monitor.c b/kern/monitor.c index e137e92..95686d0 100644 --- a/kern/monitor.c +++ b/kern/monitor.c @@ -57,6 +57,19 @@ mon_kerninfo(int argc, char **argv, struct Trapframe *tf) int mon_backtrace(int argc, char **argv, struct Trapframe *tf) { + uint32_t *bp = (uint32_t *) read_ebp(); + uint32_t ip; + + cprintf("Stack backtrace:\n"); + + do { + ip = * (bp + 1); + cprintf("ebp %08x eip %08x args", bp, ip); + for (int i = 2; i < 7; i++) + cprintf(" %08x", * (bp + i)); + cprintf("\n"); + } while ((bp = (uint32_t *) *bp)); + // Your code here. return 0; } diff --git a/lib/printfmt.c b/lib/printfmt.c index 28e01c9..b1de635 100644 --- a/lib/printfmt.c +++ b/lib/printfmt.c @@ -205,11 +205,9 @@ vprintfmt(void (*putch)(int, void*), void *putdat, const char *fmt, va_list ap) // (unsigned) octal case 'o': - // Replace this with your code. - putch('X', putdat); - putch('X', putdat); - putch('X', putdat); - break; + num = getuint(&ap, lflag); + base = 8; + goto number; // pointer case 'p':