diff --git a/examples/mps3-an536/reference/el2_hello-armv8r-none-eabihf.out b/examples/mps3-an536/reference/el2_hello-armv8r-none-eabihf.out index 97d1c10..bf0ed13 100644 --- a/examples/mps3-an536/reference/el2_hello-armv8r-none-eabihf.out +++ b/examples/mps3-an536/reference/el2_hello-armv8r-none-eabihf.out @@ -19,7 +19,7 @@ PANIC: PanicInfo { message: I am an example panic, location: Location { file: "src/bin/el2_hello.rs", - line: 27, + line: 28, column: 5, }, can_unwind: true, diff --git a/examples/mps3-an536/reference/hello-armv8r-none-eabihf.out b/examples/mps3-an536/reference/hello-armv8r-none-eabihf.out index 0d377af..3d5180e 100644 --- a/examples/mps3-an536/reference/hello-armv8r-none-eabihf.out +++ b/examples/mps3-an536/reference/hello-armv8r-none-eabihf.out @@ -3,7 +3,7 @@ PANIC: PanicInfo { message: I am an example panic, location: Location { file: "src/bin/hello.rs", - line: 18, + line: 20, column: 5, }, can_unwind: true, diff --git a/examples/mps3-an536/reference/svc-a32-armv8r-none-eabihf.out b/examples/mps3-an536/reference/svc-a32-armv8r-none-eabihf.out index d8cc028..fe4deb8 100644 --- a/examples/mps3-an536/reference/svc-a32-armv8r-none-eabihf.out +++ b/examples/mps3-an536/reference/svc-a32-armv8r-none-eabihf.out @@ -2,13 +2,3 @@ x = 1, y = 2, z = 3.000 In svc_handler, with arg=0xabcdef In svc_handler, with arg=0x456789 x = 1, y = 2, z = 3.000 -PANIC: PanicInfo { - message: I am an example panic, - location: Location { - file: "src/bin/svc-a32.rs", - line: 21, - column: 5, - }, - can_unwind: true, - force_no_backtrace: false, -} diff --git a/examples/mps3-an536/reference/svc-t32-armv8r-none-eabihf.out b/examples/mps3-an536/reference/svc-t32-armv8r-none-eabihf.out index 3476848..c9edfeb 100644 --- a/examples/mps3-an536/reference/svc-t32-armv8r-none-eabihf.out +++ b/examples/mps3-an536/reference/svc-t32-armv8r-none-eabihf.out @@ -2,13 +2,3 @@ x = 1, y = 2, z = 3.000 In svc_handler, with arg=0x000012 In svc_handler, with arg=0x000034 x = 1, y = 2, z = 3.000 -PANIC: PanicInfo { - message: I am an example panic, - location: Location { - file: "src/bin/svc-t32.rs", - line: 23, - column: 5, - }, - can_unwind: true, - force_no_backtrace: false, -} diff --git a/examples/mps3-an536/src/bin/el2_hello.rs b/examples/mps3-an536/src/bin/el2_hello.rs index 2cbffc4..c1a5236 100644 --- a/examples/mps3-an536/src/bin/el2_hello.rs +++ b/examples/mps3-an536/src/bin/el2_hello.rs @@ -24,6 +24,7 @@ fn main() -> ! { } } + mps3_an536::want_panic(); panic!("I am an example panic"); } diff --git a/examples/mps3-an536/src/bin/hello.rs b/examples/mps3-an536/src/bin/hello.rs index ffb3f11..331988c 100644 --- a/examples/mps3-an536/src/bin/hello.rs +++ b/examples/mps3-an536/src/bin/hello.rs @@ -4,9 +4,10 @@ #![no_main] use aarch32_rt::entry; -use mps3_an536 as _; use semihosting::println; +use mps3_an536 as _; + /// The entry-point to the Rust application. /// /// It is called by the start-up code in `aarch32-rt`. @@ -15,5 +16,6 @@ fn main() -> ! { let x = 1.0f64; let y = x * 2.0; println!("Hello, this is semihosting! x = {:0.3}, y = {:0.3}", x, y); + mps3_an536::want_panic(); panic!("I am an example panic"); } diff --git a/examples/mps3-an536/src/bin/svc-a32.rs b/examples/mps3-an536/src/bin/svc-a32.rs index 353c070..cade824 100644 --- a/examples/mps3-an536/src/bin/svc-a32.rs +++ b/examples/mps3-an536/src/bin/svc-a32.rs @@ -18,7 +18,7 @@ fn main() -> ! { println!("x = {}, y = {}, z = {:0.3}", x, y, z); aarch32_cpu::svc!(0xABCDEF); println!("x = {}, y = {}, z = {:0.3}", x, y, z); - panic!("I am an example panic"); + semihosting::process::exit(0); } /// This is our SVC exception handler diff --git a/examples/mps3-an536/src/bin/svc-t32.rs b/examples/mps3-an536/src/bin/svc-t32.rs index 10900f8..47e7471 100644 --- a/examples/mps3-an536/src/bin/svc-t32.rs +++ b/examples/mps3-an536/src/bin/svc-t32.rs @@ -20,7 +20,7 @@ fn main() -> ! { svc12_from_t32(); } println!("x = {}, y = {}, z = {:0.3}", x, y, z); - panic!("I am an example panic"); + semihosting::process::exit(0); } /// This is our SVC exception handler diff --git a/examples/mps3-an536/src/lib.rs b/examples/mps3-an536/src/lib.rs index 12fca0c..1574dee 100644 --- a/examples/mps3-an536/src/lib.rs +++ b/examples/mps3-an536/src/lib.rs @@ -64,6 +64,8 @@ pub const VIRTUAL_TIMER_PPI: arm_gic::IntId = arm_gic::IntId::ppi(11); #[cfg(not(arm_architecture = "v8-r"))] compile_error!("This example is only compatible to the ARMv8-R architecture"); +static WANT_PANIC: AtomicBool = AtomicBool::new(false); + /// Called when the application raises an unrecoverable `panic!`. /// /// Prints the panic to the console and then exits QEMU using a semihosting @@ -72,7 +74,16 @@ compile_error!("This example is only compatible to the ARMv8-R architecture"); #[cfg(target_os = "none")] fn panic(info: &core::panic::PanicInfo) -> ! { semihosting::println!("PANIC: {:#?}", info); - semihosting::process::abort(); + if WANT_PANIC.load(Ordering::Relaxed) { + semihosting::process::exit(0); + } else { + semihosting::process::abort(); + } +} + +/// Set the panic function as no longer returning a failure code via semihosting +pub fn want_panic() { + WANT_PANIC.store(true, Ordering::Relaxed); } #[derive(Clone, Debug)] diff --git a/examples/versatileab/reference/hello-armv4t-none-eabi.out b/examples/versatileab/reference/hello-armv4t-none-eabi.out index 0d377af..59aae22 100644 --- a/examples/versatileab/reference/hello-armv4t-none-eabi.out +++ b/examples/versatileab/reference/hello-armv4t-none-eabi.out @@ -3,7 +3,7 @@ PANIC: PanicInfo { message: I am an example panic, location: Location { file: "src/bin/hello.rs", - line: 18, + line: 19, column: 5, }, can_unwind: true, diff --git a/examples/versatileab/reference/hello-armv5te-none-eabi.out b/examples/versatileab/reference/hello-armv5te-none-eabi.out index 0d377af..59aae22 100644 --- a/examples/versatileab/reference/hello-armv5te-none-eabi.out +++ b/examples/versatileab/reference/hello-armv5te-none-eabi.out @@ -3,7 +3,7 @@ PANIC: PanicInfo { message: I am an example panic, location: Location { file: "src/bin/hello.rs", - line: 18, + line: 19, column: 5, }, can_unwind: true, diff --git a/examples/versatileab/reference/hello-armv7a-none-eabi.out b/examples/versatileab/reference/hello-armv7a-none-eabi.out index 0d377af..59aae22 100644 --- a/examples/versatileab/reference/hello-armv7a-none-eabi.out +++ b/examples/versatileab/reference/hello-armv7a-none-eabi.out @@ -3,7 +3,7 @@ PANIC: PanicInfo { message: I am an example panic, location: Location { file: "src/bin/hello.rs", - line: 18, + line: 19, column: 5, }, can_unwind: true, diff --git a/examples/versatileab/reference/hello-armv7a-none-eabihf.out b/examples/versatileab/reference/hello-armv7a-none-eabihf.out index 0d377af..59aae22 100644 --- a/examples/versatileab/reference/hello-armv7a-none-eabihf.out +++ b/examples/versatileab/reference/hello-armv7a-none-eabihf.out @@ -3,7 +3,7 @@ PANIC: PanicInfo { message: I am an example panic, location: Location { file: "src/bin/hello.rs", - line: 18, + line: 19, column: 5, }, can_unwind: true, diff --git a/examples/versatileab/reference/hello-armv7r-none-eabi.out b/examples/versatileab/reference/hello-armv7r-none-eabi.out index 0d377af..59aae22 100644 --- a/examples/versatileab/reference/hello-armv7r-none-eabi.out +++ b/examples/versatileab/reference/hello-armv7r-none-eabi.out @@ -3,7 +3,7 @@ PANIC: PanicInfo { message: I am an example panic, location: Location { file: "src/bin/hello.rs", - line: 18, + line: 19, column: 5, }, can_unwind: true, diff --git a/examples/versatileab/reference/hello-armv7r-none-eabihf.out b/examples/versatileab/reference/hello-armv7r-none-eabihf.out index 0d377af..59aae22 100644 --- a/examples/versatileab/reference/hello-armv7r-none-eabihf.out +++ b/examples/versatileab/reference/hello-armv7r-none-eabihf.out @@ -3,7 +3,7 @@ PANIC: PanicInfo { message: I am an example panic, location: Location { file: "src/bin/hello.rs", - line: 18, + line: 19, column: 5, }, can_unwind: true, diff --git a/examples/versatileab/reference/hello-thumbv4t-none-eabi.out b/examples/versatileab/reference/hello-thumbv4t-none-eabi.out index 0d377af..59aae22 100644 --- a/examples/versatileab/reference/hello-thumbv4t-none-eabi.out +++ b/examples/versatileab/reference/hello-thumbv4t-none-eabi.out @@ -3,7 +3,7 @@ PANIC: PanicInfo { message: I am an example panic, location: Location { file: "src/bin/hello.rs", - line: 18, + line: 19, column: 5, }, can_unwind: true, diff --git a/examples/versatileab/reference/hello-thumbv5te-none-eabi.out b/examples/versatileab/reference/hello-thumbv5te-none-eabi.out index 0d377af..59aae22 100644 --- a/examples/versatileab/reference/hello-thumbv5te-none-eabi.out +++ b/examples/versatileab/reference/hello-thumbv5te-none-eabi.out @@ -3,7 +3,7 @@ PANIC: PanicInfo { message: I am an example panic, location: Location { file: "src/bin/hello.rs", - line: 18, + line: 19, column: 5, }, can_unwind: true, diff --git a/examples/versatileab/reference/svc-a32-armv4t-none-eabi.out b/examples/versatileab/reference/svc-a32-armv4t-none-eabi.out index aa7cc28..fe4deb8 100644 --- a/examples/versatileab/reference/svc-a32-armv4t-none-eabi.out +++ b/examples/versatileab/reference/svc-a32-armv4t-none-eabi.out @@ -2,13 +2,3 @@ x = 1, y = 2, z = 3.000 In svc_handler, with arg=0xabcdef In svc_handler, with arg=0x456789 x = 1, y = 2, z = 3.000 -PANIC: PanicInfo { - message: I am an example panic, - location: Location { - file: "src/bin/svc-a32.rs", - line: 22, - column: 5, - }, - can_unwind: true, - force_no_backtrace: false, -} diff --git a/examples/versatileab/reference/svc-a32-armv5te-none-eabi.out b/examples/versatileab/reference/svc-a32-armv5te-none-eabi.out index aa7cc28..fe4deb8 100644 --- a/examples/versatileab/reference/svc-a32-armv5te-none-eabi.out +++ b/examples/versatileab/reference/svc-a32-armv5te-none-eabi.out @@ -2,13 +2,3 @@ x = 1, y = 2, z = 3.000 In svc_handler, with arg=0xabcdef In svc_handler, with arg=0x456789 x = 1, y = 2, z = 3.000 -PANIC: PanicInfo { - message: I am an example panic, - location: Location { - file: "src/bin/svc-a32.rs", - line: 22, - column: 5, - }, - can_unwind: true, - force_no_backtrace: false, -} diff --git a/examples/versatileab/reference/svc-a32-armv7a-none-eabi.out b/examples/versatileab/reference/svc-a32-armv7a-none-eabi.out index aa7cc28..fe4deb8 100644 --- a/examples/versatileab/reference/svc-a32-armv7a-none-eabi.out +++ b/examples/versatileab/reference/svc-a32-armv7a-none-eabi.out @@ -2,13 +2,3 @@ x = 1, y = 2, z = 3.000 In svc_handler, with arg=0xabcdef In svc_handler, with arg=0x456789 x = 1, y = 2, z = 3.000 -PANIC: PanicInfo { - message: I am an example panic, - location: Location { - file: "src/bin/svc-a32.rs", - line: 22, - column: 5, - }, - can_unwind: true, - force_no_backtrace: false, -} diff --git a/examples/versatileab/reference/svc-a32-armv7a-none-eabihf.out b/examples/versatileab/reference/svc-a32-armv7a-none-eabihf.out index aa7cc28..fe4deb8 100644 --- a/examples/versatileab/reference/svc-a32-armv7a-none-eabihf.out +++ b/examples/versatileab/reference/svc-a32-armv7a-none-eabihf.out @@ -2,13 +2,3 @@ x = 1, y = 2, z = 3.000 In svc_handler, with arg=0xabcdef In svc_handler, with arg=0x456789 x = 1, y = 2, z = 3.000 -PANIC: PanicInfo { - message: I am an example panic, - location: Location { - file: "src/bin/svc-a32.rs", - line: 22, - column: 5, - }, - can_unwind: true, - force_no_backtrace: false, -} diff --git a/examples/versatileab/reference/svc-a32-armv7r-none-eabi.out b/examples/versatileab/reference/svc-a32-armv7r-none-eabi.out index aa7cc28..fe4deb8 100644 --- a/examples/versatileab/reference/svc-a32-armv7r-none-eabi.out +++ b/examples/versatileab/reference/svc-a32-armv7r-none-eabi.out @@ -2,13 +2,3 @@ x = 1, y = 2, z = 3.000 In svc_handler, with arg=0xabcdef In svc_handler, with arg=0x456789 x = 1, y = 2, z = 3.000 -PANIC: PanicInfo { - message: I am an example panic, - location: Location { - file: "src/bin/svc-a32.rs", - line: 22, - column: 5, - }, - can_unwind: true, - force_no_backtrace: false, -} diff --git a/examples/versatileab/reference/svc-a32-armv7r-none-eabihf.out b/examples/versatileab/reference/svc-a32-armv7r-none-eabihf.out index aa7cc28..fe4deb8 100644 --- a/examples/versatileab/reference/svc-a32-armv7r-none-eabihf.out +++ b/examples/versatileab/reference/svc-a32-armv7r-none-eabihf.out @@ -2,13 +2,3 @@ x = 1, y = 2, z = 3.000 In svc_handler, with arg=0xabcdef In svc_handler, with arg=0x456789 x = 1, y = 2, z = 3.000 -PANIC: PanicInfo { - message: I am an example panic, - location: Location { - file: "src/bin/svc-a32.rs", - line: 22, - column: 5, - }, - can_unwind: true, - force_no_backtrace: false, -} diff --git a/examples/versatileab/reference/svc-a32-thumbv4t-none-eabi.out b/examples/versatileab/reference/svc-a32-thumbv4t-none-eabi.out index aa7cc28..fe4deb8 100644 --- a/examples/versatileab/reference/svc-a32-thumbv4t-none-eabi.out +++ b/examples/versatileab/reference/svc-a32-thumbv4t-none-eabi.out @@ -2,13 +2,3 @@ x = 1, y = 2, z = 3.000 In svc_handler, with arg=0xabcdef In svc_handler, with arg=0x456789 x = 1, y = 2, z = 3.000 -PANIC: PanicInfo { - message: I am an example panic, - location: Location { - file: "src/bin/svc-a32.rs", - line: 22, - column: 5, - }, - can_unwind: true, - force_no_backtrace: false, -} diff --git a/examples/versatileab/reference/svc-a32-thumbv5te-none-eabi.out b/examples/versatileab/reference/svc-a32-thumbv5te-none-eabi.out index aa7cc28..fe4deb8 100644 --- a/examples/versatileab/reference/svc-a32-thumbv5te-none-eabi.out +++ b/examples/versatileab/reference/svc-a32-thumbv5te-none-eabi.out @@ -2,13 +2,3 @@ x = 1, y = 2, z = 3.000 In svc_handler, with arg=0xabcdef In svc_handler, with arg=0x456789 x = 1, y = 2, z = 3.000 -PANIC: PanicInfo { - message: I am an example panic, - location: Location { - file: "src/bin/svc-a32.rs", - line: 22, - column: 5, - }, - can_unwind: true, - force_no_backtrace: false, -} diff --git a/examples/versatileab/reference/svc-t32-armv4t-none-eabi.out b/examples/versatileab/reference/svc-t32-armv4t-none-eabi.out index 3476848..c9edfeb 100644 --- a/examples/versatileab/reference/svc-t32-armv4t-none-eabi.out +++ b/examples/versatileab/reference/svc-t32-armv4t-none-eabi.out @@ -2,13 +2,3 @@ x = 1, y = 2, z = 3.000 In svc_handler, with arg=0x000012 In svc_handler, with arg=0x000034 x = 1, y = 2, z = 3.000 -PANIC: PanicInfo { - message: I am an example panic, - location: Location { - file: "src/bin/svc-t32.rs", - line: 23, - column: 5, - }, - can_unwind: true, - force_no_backtrace: false, -} diff --git a/examples/versatileab/reference/svc-t32-armv5te-none-eabi.out b/examples/versatileab/reference/svc-t32-armv5te-none-eabi.out index 3476848..c9edfeb 100644 --- a/examples/versatileab/reference/svc-t32-armv5te-none-eabi.out +++ b/examples/versatileab/reference/svc-t32-armv5te-none-eabi.out @@ -2,13 +2,3 @@ x = 1, y = 2, z = 3.000 In svc_handler, with arg=0x000012 In svc_handler, with arg=0x000034 x = 1, y = 2, z = 3.000 -PANIC: PanicInfo { - message: I am an example panic, - location: Location { - file: "src/bin/svc-t32.rs", - line: 23, - column: 5, - }, - can_unwind: true, - force_no_backtrace: false, -} diff --git a/examples/versatileab/reference/svc-t32-armv7a-none-eabi.out b/examples/versatileab/reference/svc-t32-armv7a-none-eabi.out index 3476848..c9edfeb 100644 --- a/examples/versatileab/reference/svc-t32-armv7a-none-eabi.out +++ b/examples/versatileab/reference/svc-t32-armv7a-none-eabi.out @@ -2,13 +2,3 @@ x = 1, y = 2, z = 3.000 In svc_handler, with arg=0x000012 In svc_handler, with arg=0x000034 x = 1, y = 2, z = 3.000 -PANIC: PanicInfo { - message: I am an example panic, - location: Location { - file: "src/bin/svc-t32.rs", - line: 23, - column: 5, - }, - can_unwind: true, - force_no_backtrace: false, -} diff --git a/examples/versatileab/reference/svc-t32-armv7a-none-eabihf.out b/examples/versatileab/reference/svc-t32-armv7a-none-eabihf.out index 3476848..c9edfeb 100644 --- a/examples/versatileab/reference/svc-t32-armv7a-none-eabihf.out +++ b/examples/versatileab/reference/svc-t32-armv7a-none-eabihf.out @@ -2,13 +2,3 @@ x = 1, y = 2, z = 3.000 In svc_handler, with arg=0x000012 In svc_handler, with arg=0x000034 x = 1, y = 2, z = 3.000 -PANIC: PanicInfo { - message: I am an example panic, - location: Location { - file: "src/bin/svc-t32.rs", - line: 23, - column: 5, - }, - can_unwind: true, - force_no_backtrace: false, -} diff --git a/examples/versatileab/reference/svc-t32-armv7r-none-eabi.out b/examples/versatileab/reference/svc-t32-armv7r-none-eabi.out index 3476848..c9edfeb 100644 --- a/examples/versatileab/reference/svc-t32-armv7r-none-eabi.out +++ b/examples/versatileab/reference/svc-t32-armv7r-none-eabi.out @@ -2,13 +2,3 @@ x = 1, y = 2, z = 3.000 In svc_handler, with arg=0x000012 In svc_handler, with arg=0x000034 x = 1, y = 2, z = 3.000 -PANIC: PanicInfo { - message: I am an example panic, - location: Location { - file: "src/bin/svc-t32.rs", - line: 23, - column: 5, - }, - can_unwind: true, - force_no_backtrace: false, -} diff --git a/examples/versatileab/reference/svc-t32-armv7r-none-eabihf.out b/examples/versatileab/reference/svc-t32-armv7r-none-eabihf.out index 3476848..c9edfeb 100644 --- a/examples/versatileab/reference/svc-t32-armv7r-none-eabihf.out +++ b/examples/versatileab/reference/svc-t32-armv7r-none-eabihf.out @@ -2,13 +2,3 @@ x = 1, y = 2, z = 3.000 In svc_handler, with arg=0x000012 In svc_handler, with arg=0x000034 x = 1, y = 2, z = 3.000 -PANIC: PanicInfo { - message: I am an example panic, - location: Location { - file: "src/bin/svc-t32.rs", - line: 23, - column: 5, - }, - can_unwind: true, - force_no_backtrace: false, -} diff --git a/examples/versatileab/reference/svc-t32-thumbv4t-none-eabi.out b/examples/versatileab/reference/svc-t32-thumbv4t-none-eabi.out index 3476848..c9edfeb 100644 --- a/examples/versatileab/reference/svc-t32-thumbv4t-none-eabi.out +++ b/examples/versatileab/reference/svc-t32-thumbv4t-none-eabi.out @@ -2,13 +2,3 @@ x = 1, y = 2, z = 3.000 In svc_handler, with arg=0x000012 In svc_handler, with arg=0x000034 x = 1, y = 2, z = 3.000 -PANIC: PanicInfo { - message: I am an example panic, - location: Location { - file: "src/bin/svc-t32.rs", - line: 23, - column: 5, - }, - can_unwind: true, - force_no_backtrace: false, -} diff --git a/examples/versatileab/reference/svc-t32-thumbv5te-none-eabi.out b/examples/versatileab/reference/svc-t32-thumbv5te-none-eabi.out index 3476848..c9edfeb 100644 --- a/examples/versatileab/reference/svc-t32-thumbv5te-none-eabi.out +++ b/examples/versatileab/reference/svc-t32-thumbv5te-none-eabi.out @@ -2,13 +2,3 @@ x = 1, y = 2, z = 3.000 In svc_handler, with arg=0x000012 In svc_handler, with arg=0x000034 x = 1, y = 2, z = 3.000 -PANIC: PanicInfo { - message: I am an example panic, - location: Location { - file: "src/bin/svc-t32.rs", - line: 23, - column: 5, - }, - can_unwind: true, - force_no_backtrace: false, -} diff --git a/examples/versatileab/src/bin/hello.rs b/examples/versatileab/src/bin/hello.rs index e1afe55..aa0412d 100644 --- a/examples/versatileab/src/bin/hello.rs +++ b/examples/versatileab/src/bin/hello.rs @@ -15,5 +15,6 @@ fn my_main() -> ! { let x = 1.0f64; let y = x * 2.0; println!("Hello, this is semihosting! x = {:0.3}, y = {:0.3}", x, y); + versatileab::want_panic(); panic!("I am an example panic"); } diff --git a/examples/versatileab/src/bin/svc-a32.rs b/examples/versatileab/src/bin/svc-a32.rs index 48eac26..b660067 100644 --- a/examples/versatileab/src/bin/svc-a32.rs +++ b/examples/versatileab/src/bin/svc-a32.rs @@ -18,8 +18,7 @@ fn main() -> ! { println!("x = {}, y = {}, z = {:0.3}", x, y, z); do_svc1(); println!("x = {}, y = {}, z = {:0.3}", x, y, z); - - panic!("I am an example panic"); + semihosting::process::exit(0); } /// This is our SVC exception handler diff --git a/examples/versatileab/src/bin/svc-t32.rs b/examples/versatileab/src/bin/svc-t32.rs index 762abd2..6b22c17 100644 --- a/examples/versatileab/src/bin/svc-t32.rs +++ b/examples/versatileab/src/bin/svc-t32.rs @@ -20,7 +20,7 @@ fn main() -> ! { svc12_from_t32(); } println!("x = {}, y = {}, z = {:0.3}", x, y, z); - panic!("I am an example panic"); + semihosting::process::exit(0); } /// This is our SVC exception handler diff --git a/examples/versatileab/src/lib.rs b/examples/versatileab/src/lib.rs index 15b797e..037c2c4 100644 --- a/examples/versatileab/src/lib.rs +++ b/examples/versatileab/src/lib.rs @@ -8,6 +8,8 @@ pub const PL190_BASE_ADDRESS: usize = 0x1014_0000; #[cfg(arm_architecture = "v8-r")] compile_error!("This example/board is not compatible with the ARMv8-R architecture"); +static WANT_PANIC: portable_atomic::AtomicBool = portable_atomic::AtomicBool::new(false); + /// Called when the application raises an unrecoverable `panic!`. /// /// Prints the panic to the console and then exits QEMU using a semihosting @@ -16,5 +18,14 @@ compile_error!("This example/board is not compatible with the ARMv8-R architectu #[cfg(target_os = "none")] fn panic(info: &core::panic::PanicInfo) -> ! { semihosting::println!("PANIC: {:#?}", info); - semihosting::process::abort(); + if WANT_PANIC.load(portable_atomic::Ordering::Relaxed) { + semihosting::process::exit(0); + } else { + semihosting::process::abort(); + } +} + +/// Set the panic function as no longer returning a failure code via semihosting +pub fn want_panic() { + WANT_PANIC.store(true, portable_atomic::Ordering::Relaxed); } diff --git a/justfile b/justfile index faedb26..4191597 100644 --- a/justfile +++ b/justfile @@ -23,7 +23,9 @@ clean: cd arm-targets && cargo clean # The cross-compiled examples cd examples/versatileab && cargo clean + rm -rf examples/versatileab/target-d32 cd examples/mps3-an536 && cargo clean + rm -rf examples/mps3-an536/target-d32 # Builds our workspace for all targets build-all: \ diff --git a/tests.sh b/tests.sh index eb92aa9..2e947c4 100755 --- a/tests.sh +++ b/tests.sh @@ -8,9 +8,20 @@ EXIT_FAST=0 FAILURE=0 -fail() { +fail_build() { + echo "***************************************************" + echo "test.sh FAIL: Binary $1 for target $2 returned non-zero" + echo "***************************************************" + FAILURE=1 + if [ $EXIT_FAST == "1" ]; then + exit 1 + fi +} + +fail_diff() { echo "***************************************************" echo "test.sh MISMATCH: Binary $1 for target $2 mismatched" + echo "(You can re-run with UPDATE_OUT=1 to replace the reference file)" echo "***************************************************" FAILURE=1 if [ $EXIT_FAST == "1" ]; then @@ -35,6 +46,11 @@ my_diff() { return 1 else diff <(cat $file_a | tr -d '\r') <(cat $file_b | sed 's~\\\\~/~g') + result=$? + if [ "${UPDATE_OUT}" == "1" ]; then + cp $file_b $file_a + fi + return $result fi } @@ -49,8 +65,8 @@ cargo build --target=$target $flags || exit 1 for bin_path in src/bin/*.rs; do filename=$(basename $bin_path) binary=${filename%.rs} - cargo run --target=$target --bin $binary $flags > ./target/$binary-$target.out - my_diff ./reference/$binary-$target.out ./target/$binary-$target.out || fail $binary $target + cargo run --target=$target --bin $binary $flags > ./target/$binary-$target.out || fail_build $binary $target + my_diff ./reference/$binary-$target.out ./target/$binary-$target.out || fail_diff $binary $target done popd