Skip to content

Commit

Permalink
Attempt to write panics to file instead of just console. Also abort w…
Browse files Browse the repository at this point in the history
…ith an 0x04 address on windows - deadbeef seems to make things sad
  • Loading branch information
tehsmeely committed Jan 22, 2024
1 parent 362f656 commit db5445b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub mod sound;
pub mod sprite;
pub mod system;

use alloc::format;
use {
crate::{
display::Display,
Expand Down Expand Up @@ -307,6 +308,15 @@ fn panic(#[allow(unused)] panic_info: &PanicInfo) -> ! {
location.line()
)
.expect("write");
#[cfg(debug_assertions)]
{
// Try and save panic to file if built in debug mode
let fs = FileSystem::get();
let panic_str = format!("{:?}", panic_info);
let file = fs.open("panic.txt", FileOptions::kFileWrite).unwrap();
let _num_bytes_written = file.write(panic_str.as_bytes()).unwrap();
file.flush().unwrap();
}
System::log_to_console(output.as_str());
} else {
System::log_to_console("panic\0");
Expand All @@ -320,11 +330,12 @@ fn panic(#[allow(unused)] panic_info: &PanicInfo) -> ! {
}
#[cfg(not(target_os = "macos"))]
{
abort_with_addr(0xdeadbeef);
abort_with_addr(0x04);
}
}

use core::alloc::{GlobalAlloc, Layout};
use crankstart_sys::FileOptions;

pub(crate) struct PlaydateAllocator;

Expand Down

0 comments on commit db5445b

Please sign in to comment.