Browse Source

Pass the machine state from the interrupt for kernel crashes.

coderain 5 years ago
parent
commit
49d75449f0
1 changed files with 4 additions and 4 deletions
  1. 4 4
      kernel/src/exception.c

+ 4 - 4
kernel/src/exception.c

@@ -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;