From 1bb01220345e0a54f8b70fa7f6dd73c6a697e291 Mon Sep 17 00:00:00 2001 From: pca006132 Date: Fri, 17 Jul 2020 16:16:01 +0800 Subject: [PATCH] libsupport_zynq/ram: print heap usage on alloc error. --- libsupport_zynq/src/ram.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libsupport_zynq/src/ram.rs b/libsupport_zynq/src/ram.rs index 7a3a0af..a712374 100644 --- a/libsupport_zynq/src/ram.rs +++ b/libsupport_zynq/src/ram.rs @@ -90,5 +90,11 @@ pub fn init_alloc_core1() { #[alloc_error_handler] fn alloc_error(layout: core::alloc::Layout) -> ! { - panic!("Core {} alloc_error, layout: {:?}", MPIDR.read().cpu_id(), layout); + let id = MPIDR.read().cpu_id(); + let heap = if id == 0 { + ALLOCATOR.0.lock() + } else { + ALLOCATOR.1.lock() + }; + panic!("Core {} alloc_error, layout: {:?}, used memory: {}", id, layout, heap.used()); }