Pass the machine state from the interrupt for kernel crashes.
authorcoderain <coderain@sdf.org>
Sat, 1 Sep 2018 21:21:26 +0000 (23:21 +0200)
committercoderain <coderain@sdf.org>
Sat, 1 Sep 2018 21:21:26 +0000 (23:21 +0200)
kernel/src/exception.c

index 1e4f8231009b69b9ba4ac8b35aea2bc57ff8e3c7..218d67b96e68667069f40bfae91201806266be05 100644 (file)
@@ -34,7 +34,7 @@ static const char *exception_names[] = {
     "Memory Access Fault",
 };
 
-static void raise_exception_internal(thread_t *thread, processor_mode_t mode, exception_info_t *info)
+static void raise_exception_internal(thread_t *thread, processor_mode_t mode, exception_info_t *info, registers_t *exception_regs)
 {
     if (mode == USER_MODE)
     {
@@ -76,7 +76,7 @@ static void raise_exception_internal(thread_t *thread, processor_mode_t mode, ex
         }
         else
         {
-            KERNEL_CRASH_WITH_REGS(exception_names[info->number], thread->last_context);
+            KERNEL_CRASH_WITH_REGS(exception_names[info->number], exception_regs);
         }
     }
 }
@@ -157,7 +157,7 @@ static void exception_handler(registers_t *regs, byte_t int_num)
 
     thread_t *thread = get_current_thread();
     if (thread == NULL) KERNEL_CRASH_WITH_REGS(exception_names[info.number], regs);
-    raise_exception_internal(thread, previous_mode, &info);
+    raise_exception_internal(thread, previous_mode, &info, regs);
 }
 
 sysret_t syscall_raise_exception(handle_t thread_handle, const exception_info_t *info)
@@ -189,7 +189,7 @@ sysret_t syscall_raise_exception(handle_t thread_handle, const exception_info_t
         if (!reference_by_handle(thread_handle, OBJECT_THREAD, (object_t**)&thread)) return ERR_INVALID;
     }
 
-    raise_exception_internal(thread, USER_MODE, &safe_info);
+    raise_exception_internal(thread, USER_MODE, &safe_info, NULL);
 
     dereference(&thread->header);
     return ERR_SUCCESS;