Skip to content

Commit

Permalink
Merge pull request torvalds#485 from wedsonaf/panic-source
Browse files Browse the repository at this point in the history
rust: report file and line number that caused a panic.
  • Loading branch information
wedsonaf authored Aug 20, 2021
2 parents 9f9b29b + e1bd831 commit d04e27c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
11 changes: 0 additions & 11 deletions rust/compiler_builtins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,3 @@ define_panicking_intrinsics!("`u64` division/modulo should not be used", {
__aeabi_uldivmod,
__mulodi4,
});

extern "C" {
fn rust_helper_BUG() -> !;
}

#[panic_handler]
fn panic(_info: &core::panic::PanicInfo<'_>) -> ! {
unsafe {
rust_helper_BUG();
}
}
11 changes: 11 additions & 0 deletions rust/kernel/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,14 @@ macro_rules! container_of {
ptr.wrapping_offset(-offset) as *const $type
}}
}

#[cfg(not(any(testlib, test)))]
#[panic_handler]
fn panic(info: &core::panic::PanicInfo<'_>) -> ! {
extern "C" {
fn rust_helper_BUG() -> !;
}
pr_emerg!("{}\n", info);
// SAFETY: FFI call.
unsafe { rust_helper_BUG() };
}

0 comments on commit d04e27c

Please sign in to comment.