1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2024-11-20 00:46:34 +00:00

Add logging on panic to improve debugging experience

This commit is contained in:
jam1garner 2020-04-10 05:42:54 -04:00
parent dec9735a55
commit a4a24268f1
6 changed files with 56 additions and 11 deletions

View file

@ -0,0 +1,29 @@
use super::*;
impl TimeSpan {
pub fn nano(nanoseconds: u64) -> Self {
TimeSpan {
nanoseconds
}
}
pub fn milli(milliseconds: u64) -> Self {
TimeSpan {
nanoseconds: milliseconds * 1000000
}
}
pub fn secs(seconds: u64) -> Self {
TimeSpan {
nanoseconds: seconds * 1000000000u64
}
}
pub fn minutes(minutes: u64) -> Self {
TimeSpan::secs(minutes * 60)
}
pub fn hours(hours: u64) -> Self {
TimeSpan::minutes(hours * 60)
}
}

View file

@ -3,6 +3,8 @@
extern crate alloc;
pub mod extensions;
#[doc(inline)]
pub use root::nn::*;

View file

@ -9,7 +9,10 @@ pub struct Attrs {
impl Parse for Attrs {
fn parse(input: ParseStream) -> syn::Result<Self> {
let meta: syn::MetaNameValue = input.parse()?;
let meta: syn::MetaNameValue = match input.parse() {
Ok(x) => x,
Err(_) => return Ok(Attrs { name: "skyline_rust_plugin".into() })
};
if meta.path.get_ident().unwrap().to_string() == "name" {
match meta.lit {

View file

@ -1,13 +1,22 @@
#[lang = "eh_personality"]
extern fn eh_personality() {
}
extern fn eh_personality() {}
#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
#[macro_export] macro_rules! install_panic_handler {
($module_name:expr) => {
#[panic_handler]
fn panic(panic_info: &core::panic::PanicInfo) -> ! {
$crate::println!("{} panicked: {}", $module_name, panic_info);
crate::logging::log("Panic at the Rust lib!\n");
loop {}
loop {
unsafe {
$crate::nn::os::SleepThread(
$crate::nn::TimeSpan::milli(100)
)
}
}
}
};
}
global_asm!(include_str!("mod0.s"));
@ -17,6 +26,8 @@ global_asm!(include_str!("mod0.s"));
#[macro_export] macro_rules! set_module_name {
($lit:literal) => {
::skyline::install_panic_handler!($lit);
const __SKYLINE_INTERNAL_MODULE_LEN: usize = $lit.len() + 1;
#[link_section = ".rodata.module_name"]
pub static __MODULE_NAME: ::skyline::build::ModuleName<__SKYLINE_INTERNAL_MODULE_LEN> =

View file

@ -1,6 +1,6 @@
#![no_std]
#![allow(incomplete_features)]
#![feature(alloc_error_handler, lang_items, start, global_asm, const_generics, impl_trait_in_bindings, proc_macro_hygiene, alloc_prelude)]
#![feature(alloc_error_handler, lang_items, start, global_asm, const_generics, impl_trait_in_bindings, proc_macro_hygiene, alloc_prelude, panic_info_message)]
/// The rust core allocation and collections library
pub extern crate alloc;
@ -19,9 +19,7 @@ pub mod extern_alloc;
pub mod build;
// nnsdk API bindings
pub mod nn {
pub use nnsdk::root::nn::*;
}
pub mod nn;
#[doc(inline)]
pub use {

2
skyline/src/nn.rs Normal file
View file

@ -0,0 +1,2 @@
pub use nnsdk::root::nn::*;
pub use nnsdk::extensions::*;