Kill the process when bad exception occurs.

master
WangRunji 7 years ago
parent daac42ce8b
commit 859b3891c1

@ -30,7 +30,6 @@ pub extern fn rust_trap(tf: &mut TrapFrame) -> usize {
T_BRKPT => breakpoint(), T_BRKPT => breakpoint(),
T_DBLFLT => double_fault(), T_DBLFLT => double_fault(),
T_PGFLT => page_fault(tf), T_PGFLT => page_fault(tf),
T_GPFLT => general_protection_fault(),
T_IRQ0...64 => { T_IRQ0...64 => {
let irq = tf.trap_num as u8 - T_IRQ0; let irq = tf.trap_num as u8 - T_IRQ0;
match irq { match irq {
@ -50,6 +49,7 @@ pub extern fn rust_trap(tf: &mut TrapFrame) -> usize {
T_SWITCH_TOU => to_user(tf), T_SWITCH_TOU => to_user(tf),
T_SYSCALL => syscall(tf), T_SYSCALL => syscall(tf),
T_SYSCALL32 => syscall32(tf), T_SYSCALL32 => syscall32(tf),
T_DIVIDE | T_GPFLT | T_ILLOP => error(tf),
_ => panic!("Unhandled interrupt {:x}", tf.trap_num), _ => panic!("Unhandled interrupt {:x}", tf.trap_num),
} }
@ -83,17 +83,7 @@ fn page_fault(tf: &mut TrapFrame) {
return; return;
} }
loop {} error(tf);
}
fn general_protection_fault() {
error!("\nEXCEPTION: General Protection Fault");
loop {}
}
fn invalid_opcode() {
error!("\nEXCEPTION: Invalid Opcode");
loop {}
} }
use super::consts::*; use super::consts::*;
@ -152,6 +142,14 @@ fn syscall32(tf: &mut TrapFrame) {
tf.rax = ret as usize; tf.rax = ret as usize;
} }
fn error(tf: &TrapFrame) {
use process::PROCESSOR;
let mut processor = PROCESSOR.try().unwrap().lock();
let pid = processor.current_pid();
error!("Process {} error:\n{:#x?}", pid, tf);
processor.exit(pid, 0x100); // TODO: Exit code for error
}
fn set_return_rsp(tf: &TrapFrame) { fn set_return_rsp(tf: &TrapFrame) {
use arch::gdt::Cpu; use arch::gdt::Cpu;
use core::mem::size_of; use core::mem::size_of;

@ -1,10 +1,10 @@
## uCore 32bit user programs pass status ## uCore 32bit user programs pass status
- [ ] badarg - [ ] badarg
- [ ] badsegment - [ ] badsegment
- [ ] divzero - [x] divzero
- [ ] exit - [ ] exit
- [ ] faultread - [x] faultread
- [ ] faultreadkernel - [x] faultreadkernel
- [x] forktest - [x] forktest
- [x] forktree - [x] forktree
- [x] hello - [x] hello
@ -15,8 +15,8 @@
- [ ] sh - [ ] sh
- [ ] sleep - [ ] sleep
- [x] sleepkill - [x] sleepkill
- [ ] softint - [x] softint
- [x] spin - [x] spin
- [ ] testbss - [x] testbss
- [x] waitkill - [x] waitkill
- [x] yield - [x] yield

Loading…
Cancel
Save