瀏覽代碼

hal: support breakpoint trap type

Breakpoint is INT 3 on x86. Also insert the int 3 instruction in
stackful().

Signed-off-by: greatbridf <greatbridf@icloud.com>
greatbridf 1 周之前
父節點
當前提交
8a6acc4fe7
共有 2 個文件被更改,包括 7 次插入0 次删除
  1. 1 0
      crates/eonix_hal/src/arch/x86_64/trap/trap_context.rs
  2. 6 0
      src/kernel/task.rs

+ 1 - 0
crates/eonix_hal/src/arch/x86_64/trap/trap_context.rs

@@ -117,6 +117,7 @@ impl RawTrapContext for TrapContext {
 
     fn trap_type(&self) -> TrapType<Self::FIrq, Self::FTimer> {
         match self.int_no {
+            3 => TrapType::Breakpoint,
             0..0x20 => TrapType::Fault(self.get_fault_type()),
             0x40 => TrapType::Timer {
                 callback: |handler| {

+ 6 - 0
src/kernel/task.rs

@@ -164,6 +164,9 @@ where
 
                         #[cfg(target_arch = "loongarch64")]
                         core::arch::asm!("break 1");
+
+                        #[cfg(target_arch = "x86_64")]
+                        core::arch::asm!("int 3");
                     }
                 }
             }
@@ -183,6 +186,9 @@ where
 
             #[cfg(target_arch = "loongarch64")]
             core::arch::asm!("break 1");
+
+            #[cfg(target_arch = "x86_64")]
+            core::arch::asm!("int 3");
         }
 
         unreachable!()