Skip to content

Commit ff48905

Browse files
committed
Update
1 parent 3a844dc commit ff48905

2 files changed

Lines changed: 18 additions & 8 deletions

File tree

src/init/init.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,24 @@ pub fn init() -> Result<(), &'static str> {
1010

1111
let allocator_start = 0x1000000;
1212
let allocator_size = 0x1000000;
13+
println!("[init] Initializing shared allocator [0x{:x} - 0x{:x}]", allocator_start, allocator_start + allocator_size);
1314
init_shared_allocator(allocator_start, allocator_size);
15+
println!("[init] Shared allocator initalized");
1416

17+
println!("[init] Calling main procedure");
1518
if let Err(e) = main() {
16-
println!("error: main: {}", e);
19+
println!("[init] error: main: {}", e);
1720
}
1821

19-
println!("Checking for leaks on a shared allocator...");
22+
println!("[init] Checking for leaks on a shared allocator...");
2023

2124
{
2225
let x = alloc::<i32>();
2326
free(x);
2427
if x as usize != allocator_start {
25-
println!(
26-
"! Memory leaked, last allocated memory address ({:x}) != {:x} (allocator_start)",
27-
x as usize, allocator_start
28-
);
28+
panic!("Memory leaked, last allocated memory address ({:x}) != {:x} (allocator_start)", x as usize, allocator_start);
2929
} else {
30-
println!("No leaks, shi's fine");
30+
println!("[init] No leaks, shi's fine");
3131
}
3232
}
3333

src/main.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,17 @@ use core::panic::*;
1010

1111
#[panic_handler]
1212
fn panic_handler(info: &PanicInfo) -> ! {
13-
println!("{}", info);
13+
println!("[panic] -- panic begin --");
14+
match info.location(){
15+
Some(location) => {
16+
println!("[panic] location: {}[{}:{}]", location.file(), location.line(), location.column());
17+
}
18+
None => {
19+
println!("[panic] location: unavailable");
20+
}
21+
}
22+
println!("[panic] message: {}", info.message());
23+
println!("[panic] -- panic end --");
1424
loop {}
1525
}
1626

0 commit comments

Comments
 (0)