From 0fb278f7cbf71272950eadb9ee7d5bd083aff27b Mon Sep 17 00:00:00 2001 From: pca006132 Date: Mon, 24 Aug 2020 16:19:25 +0800 Subject: [PATCH] runtime/kernel/core1: allows getting backtrace when kernel is not loaded --- src/runtime/src/kernel/core1.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/runtime/src/kernel/core1.rs b/src/runtime/src/kernel/core1.rs index 557c546..4b3c001 100644 --- a/src/runtime/src/kernel/core1.rs +++ b/src/runtime/src/kernel/core1.rs @@ -222,12 +222,6 @@ pub fn terminate(exception: &'static eh_artiq::Exception<'static>, backtrace: &' /// Called by llvm_libunwind #[no_mangle] extern fn dl_unwind_find_exidx(pc: *const u32, len_ptr: *mut u32) -> *const u32 { - let exidx = unsafe { - KERNEL_IMAGE.as_ref() - .expect("dl_unwind_find_exidx kernel image") - .library.get().as_ref().unwrap().exidx() - }; - let length; let start: *const u32; unsafe { @@ -235,6 +229,9 @@ extern fn dl_unwind_find_exidx(pc: *const u32, len_ptr: *mut u32) -> *const u32 length = (&__exidx_end as *const u32).offset_from(&__exidx_start) as u32; start = &__exidx_start; } else { + let exidx = KERNEL_IMAGE.as_ref() + .expect("dl_unwind_find_exidx kernel image") + .library.get().as_ref().unwrap().exidx(); length = exidx.len() as u32; start = exidx.as_ptr(); }