diff --git a/src/system/kernel/arch/arm/arch_debug.cpp b/src/system/kernel/arch/arm/arch_debug.cpp index add3ec6f2e..1966ad6cea 100644 --- a/src/system/kernel/arch/arm/arch_debug.cpp +++ b/src/system/kernel/arch/arm/arch_debug.cpp @@ -97,7 +97,7 @@ static void set_debug_argument_variable(int32 index, uint64 value) { char name[8]; - snprintf(name, sizeof(name), "_arg%ld", index); + snprintf(name, sizeof(name), "_arg%" B_PRId32, index); set_debug_variable(name, value); } @@ -179,7 +179,7 @@ print_demangled_call(const char* image, const char* symbol, addr_t args, case B_INT32_TYPE: value = read_function_argument_value(arg, valueKnown); if (valueKnown) - kprintf("int32: \33[34m%ld\33[0m", (int32)value); + kprintf("int32: \33[34m%" B_PRId32 "\33[0m", (int32)value); break; case B_INT16_TYPE: value = read_function_argument_value(arg, valueKnown); @@ -202,9 +202,9 @@ print_demangled_call(const char* image, const char* symbol, addr_t args, case B_UINT32_TYPE: value = read_function_argument_value(arg, valueKnown); if (valueKnown) { - kprintf("uint32: \33[34m%#lx\33[0m", (uint32)value); + kprintf("uint32: \33[34m%#" B_PRIx32 "\33[0m", (uint32)value); if (value < 0x100000) - kprintf(" (\33[34m%lu\33[0m)", (uint32)value); + kprintf(" (\33[34m%" B_PRIu32 "\33[0m)", (uint32)value); } break; case B_UINT16_TYPE: @@ -238,7 +238,7 @@ print_demangled_call(const char* image, const char* symbol, addr_t args, && (type == B_POINTER_TYPE || type == B_REF_TYPE)) kprintf("NULL"); else - kprintf("\33[34m%#lx\33[0m", (uint32)value); + kprintf("\33[34m%#" B_PRIx32 "\33[0m", (uint32)value); } break; } @@ -356,7 +356,7 @@ stack_trace(int argc, char **argv) } addr_t previousLocations[NUM_PREVIOUS_LOCATIONS]; - Thread* thread = NULL; + Thread* thread = thread_get_current_thread(); phys_addr_t oldPageDirectory = 0; addr_t fp = arm_get_fp(); int32 num = 0, last = 0; @@ -375,7 +375,7 @@ stack_trace(int argc, char **argv) } if (thread != NULL) { - kprintf("stack trace for thread 0x%lx \"%s\"\n", thread->id, + kprintf("stack trace for thread 0x%" B_PRIx32 " \"%s\"\n", thread->id, thread->name); kprintf(" kernel stack: %p to %p\n", @@ -403,14 +403,16 @@ stack_trace(int argc, char **argv) if (frame) { kprintf("iframe at %p\n", frame); - kprintf(" r0 0x%08lx r1 0x%08lx r2 0x%08lx r3 0x%08lx\n", + kprintf(" R00 0x%08x R01 0x%08x R02 0x%08x R03 0x%08x\n", frame->r0, frame->r1, frame->r2, frame->r3); - kprintf(" r4 0x%08lx r5 0x%08lx r6 0x%08lx r7 0x%08lx\n", + kprintf(" R04 0x%08x R05 0x%08x R06 0x%08x R07 0x%08x\n", frame->r4, frame->r5, frame->r6, frame->r7); - kprintf(" r8 0x%08lx r9 0x%08lx r10 0x%08lx r11 0x%08lx\n", + kprintf(" R08 0x%08x R09 0x%08x R10 0x%08x R11 0x%08x\n", frame->r8, frame->r9, frame->r10, frame->r11); - kprintf(" r12 0x%08lx sp 0x%08lx lr 0x%08lx pc 0x%08lx\n", + kprintf(" R12 0x%08x SPs 0x%08x LRs 0x%08x PC 0x%08x\n", frame->r12, frame->svc_sp, frame->svc_lr, frame->pc); + kprintf(" SPu 0x%08x LRu 0x%08x SPSR 0x%08x\n", + frame->usr_sp, frame->usr_lr, frame->spsr); fp = frame->svc_sp; print_stack_frame(thread, frame->pc, frame->svc_sp, frame->svc_lr, callIndex, demangle); diff --git a/src/system/kernel/arch/arm/arch_exceptions.S b/src/system/kernel/arch/arm/arch_exceptions.S index 2e71ab50db..e2fbbd503d 100644 --- a/src/system/kernel/arch/arm/arch_exceptions.S +++ b/src/system/kernel/arch/arm/arch_exceptions.S @@ -157,8 +157,9 @@ und_stack: FUNCTION(arm_undefined): PUSHFRAMEINSVC - mov r0, sp - bl arch_arm_undefined + mov r0, sp /* iframe */ + mov fp, r0 + bl arch_arm_undefined PULLFRAMEFROMSVCANDEXIT FUNCTION_END(arm_undefined) @@ -167,8 +168,9 @@ FUNCTION_END(arm_undefined) FUNCTION(arm_syscall): PUSHFRAMEINSWI - mov r0, sp - bl arch_arm_syscall + mov r0, sp /* iframe */ + mov fp, r0 + bl arch_arm_syscall PULLFRAMEINSWIANDEXIT FUNCTION_END(arm_syscall) @@ -179,11 +181,12 @@ FUNCTION(arm_prefetch_abort): nop /* Make absolutely sure any pending */ nop /* imprecise aborts have occurred. */ #endif - sub lr, lr, #4 + sub lr, lr, #4 /* Adjust LR */ PUSHFRAMEINSVC - mov r0, sp - bl arch_arm_prefetch_abort + mov r0, sp /* iframe */ + mov fp, r0 + bl arch_arm_prefetch_abort PULLFRAMEFROMSVCANDEXIT FUNCTION_END(arm_prefetch_abort) @@ -194,11 +197,12 @@ FUNCTION(arm_data_abort): nop /* Make absolutely sure any pending */ nop /* imprecise aborts have occurred. */ #endif - sub lr, lr, #8 /* Adjust the lr */ + sub lr, lr, #8 /* Adjust LR */ PUSHFRAMEINSVC - mov r0, sp - bl arch_arm_data_abort + mov r0, sp /* iframe */ + mov fp, r0 + bl arch_arm_data_abort PULLFRAMEFROMSVCANDEXIT FUNCTION_END(arm_data_abort) @@ -210,23 +214,25 @@ FUNCTION_END(arm_reserved) FUNCTION(arm_irq): - sub lr, lr, #4 + sub lr, lr, #4 /* Adjust LR */ PUSHFRAMEINSVC - mov r0, sp /* iframe */ - bl arch_arm_irq + mov r0, sp /* iframe */ + mov fp, r0 + bl arch_arm_irq PULLFRAMEFROMSVCANDEXIT FUNCTION_END(arm_irq) FUNCTION(arm_fiq): - sub lr, lr, #4 + sub lr, lr, #4 /* Adjust LR */ PUSHFRAMEINSVC - mov r0, sp /* iframe */ - bl arch_arm_fiq - + mov r0, sp /* iframe */ + mov fp, r0 + bl arch_arm_fiq + PULLFRAMEFROMSVCANDEXIT FUNCTION_END(arm_fiq) diff --git a/src/system/kernel/arch/arm/arch_int.cpp b/src/system/kernel/arch/arm/arch_int.cpp index 0cb17447ed..6eeac52ea1 100644 --- a/src/system/kernel/arch/arm/arch_int.cpp +++ b/src/system/kernel/arch/arm/arch_int.cpp @@ -252,6 +252,8 @@ arch_arm_syscall(struct iframe *iframe) print_iframe("Software interrupt", iframe); #endif + IFrameScope scope(iframe); + uint32_t syscall = *(uint32_t *)(iframe->pc-4) & 0x00ffffff; TRACE("syscall number: %d\n", syscall);