Browse Source

Show hart id on panic for QEMU platform

luojia65 4 years ago
parent
commit
d80fdf7958
2 changed files with 4 additions and 1 deletions
  1. 1 0
      CHANGELOG.md
  2. 3 1
      platform/qemu/src/main.rs

+ 1 - 0
CHANGELOG.md

@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 - Abstract support for HSM and SRST extensions
 - Support SRST extension using test device on QEMU
 - Count harts from device tree binary on QEMU platform
+- Show hart id on panic for QEMU platform
 - Small fixes on library documents
 
 ### Modified

+ 3 - 1
platform/qemu/src/main.rs

@@ -30,7 +30,9 @@ static ALLOCATOR: LockedHeap = LockedHeap::empty();
 #[cfg(not(test))]
 #[panic_handler]
 fn panic(info: &PanicInfo) -> ! {
-    println!("[rustsbi-panic] {}", info);
+    let hart_id = mhartid::read();
+    // 输出的信息大概是“[rustsbi-panic] hart 0 panicked at ...”
+    println!("[rustsbi-panic] hart {} {}", hart_id, info);
     println!("[rustsbi-panic] system shutdown scheduled due to RustSBI panic");
     use rustsbi::Reset;
     hal::Reset.system_reset(