Skip to content

Commit e1bd831

Browse files
committed
rust: report information about a panic.
At the moment we get a mangled call stack. This prints the panic message and source location. Moving the panic handler do the `kernel` crate allows us to use `pr_emerg` to print the panic info. Signed-off-by: Wedson Almeida Filho <[email protected]>
1 parent 5f44006 commit e1bd831

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

rust/compiler_builtins.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,3 @@ define_panicking_intrinsics!("`u64` division/modulo should not be used", {
133133
__aeabi_uldivmod,
134134
__mulodi4,
135135
});
136-
137-
extern "C" {
138-
fn rust_helper_BUG() -> !;
139-
}
140-
141-
#[panic_handler]
142-
fn panic(_info: &core::panic::PanicInfo<'_>) -> ! {
143-
unsafe {
144-
rust_helper_BUG();
145-
}
146-
}

rust/kernel/lib.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,14 @@ macro_rules! container_of {
226226
ptr.wrapping_offset(-offset) as *const $type
227227
}}
228228
}
229+
230+
#[cfg(not(any(testlib, test)))]
231+
#[panic_handler]
232+
fn panic(info: &core::panic::PanicInfo<'_>) -> ! {
233+
extern "C" {
234+
fn rust_helper_BUG() -> !;
235+
}
236+
pr_emerg!("{}\n", info);
237+
// SAFETY: FFI call.
238+
unsafe { rust_helper_BUG() };
239+
}

0 commit comments

Comments
 (0)