Merge pull request #131 from N9w-x/backtrace

fix: bug in backtrace
This commit is contained in:
Yifan Wu 2023-12-30 01:22:16 +08:00 committed by GitHub
commit bd40a54662
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,7 @@ use super::{ProcessControlBlock, TaskContext, TaskControlBlock};
use crate::sync::UPIntrFreeCell;
use crate::trap::TrapContext;
use alloc::sync::Arc;
use core::arch::asm;
use lazy_static::*;
pub struct Processor {
@ -91,7 +92,14 @@ pub fn current_trap_cx_user_va() -> usize {
}
pub fn current_kstack_top() -> usize {
current_task().unwrap().kstack.get_top()
if let Some(task) = current_task() {
task.kstack.get_top()
} else {
let mut boot_stack_top;
unsafe { asm!("la {},boot_stack_top",out(reg) boot_stack_top) };
boot_stack_top
}
// current_task().unwrap().kstack.get_top()
}
pub fn schedule(switched_task_cx_ptr: *mut TaskContext) {