Add the temporary panic support for LoongArch
This commit is contained in:
parent
ef1d26d81b
commit
b0b242edbc
|
|
@ -34,7 +34,6 @@ ostd-test = { version = "0.15.2", path = "libs/ostd-test" }
|
|||
ostd-pod = { git = "https://github.com/asterinas/ostd-pod", rev = "c4644be", version = "0.1.1" }
|
||||
spin = "0.9.4"
|
||||
smallvec = "1.13.2"
|
||||
unwinding = { version = "=0.2.5", default-features = false, features = ["fde-gnu-eh-frame-hdr", "hide-trace", "panic", "personality", "unwinder"] }
|
||||
volatile = "0.6.1"
|
||||
bitvec = { version = "1.0", default-features = false, features = ["alloc"] }
|
||||
|
||||
|
|
@ -51,11 +50,17 @@ iced-x86 = { version = "1.21.0", default-features = false, features = [
|
|||
"gas",
|
||||
], optional = true }
|
||||
tdx-guest = { version = "0.2.1", optional = true }
|
||||
unwinding = { version = "=0.2.5", default-features = false, features = ["fde-gnu-eh-frame-hdr", "hide-trace", "panic", "personality", "unwinder"] }
|
||||
|
||||
[target.riscv64gc-unknown-none-elf.dependencies]
|
||||
riscv = { version = "0.11.1", features = ["s-mode"] }
|
||||
sbi-rt = "0.0.3"
|
||||
fdt = { version = "0.1.5", features = ["pretty-printing"] }
|
||||
unwinding = { version = "=0.2.5", default-features = false, features = ["fde-gnu-eh-frame-hdr", "hide-trace", "panic", "personality", "unwinder"] }
|
||||
|
||||
[target.loongarch64-unknown-none.dependencies]
|
||||
loongArch64 = "0.2.5"
|
||||
fdt = { version = "0.1.5", features = ["pretty-printing"] }
|
||||
|
||||
[features]
|
||||
default = ["cvm_guest"]
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@
|
|||
|
||||
use core::ffi::c_void;
|
||||
|
||||
pub use unwinding::panic::{begin_panic, catch_unwind};
|
||||
|
||||
use crate::{
|
||||
arch::qemu::{exit_qemu, QemuExitCode},
|
||||
early_print, early_println,
|
||||
|
|
@ -16,10 +14,6 @@ extern crate cfg_if;
|
|||
extern crate gimli;
|
||||
|
||||
use gimli::Register;
|
||||
use unwinding::abi::{
|
||||
UnwindContext, UnwindReasonCode, _Unwind_Backtrace, _Unwind_FindEnclosingFunction,
|
||||
_Unwind_GetGR, _Unwind_GetIP,
|
||||
};
|
||||
|
||||
/// The default panic handler for OSTD based kernels.
|
||||
///
|
||||
|
|
@ -52,10 +46,19 @@ pub fn abort() -> ! {
|
|||
exit_qemu(QemuExitCode::Failed);
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "loongarch64"))]
|
||||
pub use unwinding::panic::{begin_panic, catch_unwind};
|
||||
|
||||
/// Prints the stack trace of the current thread to the console.
|
||||
///
|
||||
/// The printing procedure is protected by a spin lock to prevent interleaving.
|
||||
#[cfg(not(target_arch = "loongarch64"))]
|
||||
pub fn print_stack_trace() {
|
||||
use unwinding::abi::{
|
||||
UnwindContext, UnwindReasonCode, _Unwind_Backtrace, _Unwind_FindEnclosingFunction,
|
||||
_Unwind_GetGR, _Unwind_GetIP,
|
||||
};
|
||||
|
||||
/// We acquire a global lock to prevent the frames in the stack trace from
|
||||
/// interleaving. The spin lock is used merely for its simplicity.
|
||||
static BACKTRACE_PRINT_LOCK: SpinLock<()> = SpinLock::new(());
|
||||
|
|
@ -106,3 +109,22 @@ pub fn print_stack_trace() {
|
|||
let mut data = CallbackData { counter: 0 };
|
||||
_Unwind_Backtrace(callback, &mut data as *mut _ as _);
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "loongarch64")]
|
||||
pub fn catch_unwind<R, F: FnOnce() -> R>(
|
||||
f: F,
|
||||
) -> Result<R, alloc::boxed::Box<dyn core::any::Any + Send>> {
|
||||
// TODO: Support unwinding in LoongArch.
|
||||
Ok(f())
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "loongarch64")]
|
||||
pub fn begin_panic<R>(_: alloc::boxed::Box<R>) {
|
||||
// TODO: Support panic context in LoongArch.
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "loongarch64")]
|
||||
pub fn print_stack_trace() {
|
||||
// TODO: Support stack trace print in LoongArch.
|
||||
early_println!("Printing stack trace:");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue