-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into watch-elf-file
- Loading branch information
Showing
6 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ mod cell; | |
mod net; | ||
mod num; | ||
mod ops; | ||
mod panic; | ||
mod ptr; | ||
mod slice; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use core::panic; | ||
|
||
use super::*; | ||
|
||
impl<'a> Format for panic::PanicInfo<'a> { | ||
fn format(&self, f: Formatter) { | ||
if let Some(location) = self.location() { | ||
crate::write!(f, "panicked at {}", location); | ||
} else { | ||
crate::write!(f, "panicked"); | ||
} | ||
// TODO: consider supporting self.message() once stabilized, or add a crate feature for | ||
// conditional support | ||
} | ||
} | ||
|
||
impl<'a> Format for panic::Location<'a> { | ||
fn format(&self, f: Formatter) { | ||
crate::write!( | ||
f, | ||
"{=str}:{=u32}:{=u32}", | ||
self.file(), | ||
self.line(), | ||
self.column() | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
INFO PanicInfo: panicked at qemu/src/bin/panic_info.rs:14:5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#![no_std] | ||
#![no_main] | ||
|
||
use core::panic; | ||
use cortex_m_semihosting::debug; | ||
|
||
use defmt_semihosting as _; // global logger | ||
|
||
#[cortex_m_rt::entry] | ||
fn main() -> ! { | ||
// Note: this test is a bit brittle in that the line/column number of the following panic is | ||
// included in the test snapshot. Hence, be mindful to update the snapshot if you want to | ||
// add any additional code to this file above the following line! | ||
panic!("aaah!") | ||
} | ||
|
||
#[panic_handler] | ||
fn panic(panic_info: &panic::PanicInfo) -> ! { | ||
defmt::info!("PanicInfo: {=?}", panic_info); | ||
loop { | ||
debug::exit(debug::EXIT_SUCCESS) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters