xous: hosted: attach to debugger on panic

When a `panic!()` is hit and we're running in a hosted environment,
attach a debugger using `debug-here`.

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2020-10-29 19:38:27 +08:00
parent 0bce0eeb53
commit 67adccf16a
2 changed files with 15 additions and 0 deletions

View file

@ -24,3 +24,4 @@ default = []
[target.'cfg(any(windows,unix))'.dependencies] [target.'cfg(any(windows,unix))'.dependencies]
lazy_static = "1.4" lazy_static = "1.4"
hex = "0.4" hex = "0.4"
debug-here = "*"

View file

@ -22,6 +22,19 @@ pub use syscall::*;
#[cfg(not(target_os = "none"))] #[cfg(not(target_os = "none"))]
pub use arch::ProcessArgsAsThread; pub use arch::ProcessArgsAsThread;
#[cfg(target_os = "none")]
pub fn init() {}
#[cfg(not(target_os = "none"))]
pub fn init() {
use std::panic;
panic::set_hook(Box::new(|arg| {
println!("PANIC!");
println!("Details: {:?}", arg);
debug_here::debug_here!();
}));
}
/// Convert a four-letter string into a 32-bit int. /// Convert a four-letter string into a 32-bit int.
#[macro_export] #[macro_export]
macro_rules! make_name { macro_rules! make_name {
@ -39,6 +52,7 @@ macro_rules! maybe_main {
extern "Rust" { extern "Rust" {
fn xous_entry() -> !; fn xous_entry() -> !;
} }
fn main() { fn main() {
xous::arch::ensure_connection().unwrap(); xous::arch::ensure_connection().unwrap();
unsafe { xous_entry() }; unsafe { xous_entry() };