Skip to content

Commit d04e27c

Browse files
authored
Merge pull request #485 from wedsonaf/panic-source
rust: report file and line number that caused a panic.
2 parents 9f9b29b + e1bd831 commit d04e27c

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
@@ -228,3 +228,14 @@ macro_rules! container_of {
228228
ptr.wrapping_offset(-offset) as *const $type
229229
}}
230230
}
231+
232+
#[cfg(not(any(testlib, test)))]
233+
#[panic_handler]
234+
fn panic(info: &core::panic::PanicInfo<'_>) -> ! {
235+
extern "C" {
236+
fn rust_helper_BUG() -> !;
237+
}
238+
pr_emerg!("{}\n", info);
239+
// SAFETY: FFI call.
240+
unsafe { rust_helper_BUG() };
241+
}

0 commit comments

Comments
 (0)