From 48864bd79b63fa9dee195b3540a3da69d2433975 Mon Sep 17 00:00:00 2001 From: Harry Chen Date: Sat, 6 Apr 2019 14:43:10 +0800 Subject: [PATCH] Add more output to backtrace, revert fs change, update rust-mips Signed-off-by: Harry Chen --- kernel/Cargo.lock | 2 +- kernel/Makefile | 2 +- kernel/src/backtrace.rs | 8 ++++++-- kernel/src/fs/mod.rs | 8 +------- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/kernel/Cargo.lock b/kernel/Cargo.lock index 15929e7..a98db90 100644 --- a/kernel/Cargo.lock +++ b/kernel/Cargo.lock @@ -230,7 +230,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "mips" version = "0.1.0" -source = "git+https://github.com/Harry-Chen/rust-mips#8b8cbacb08aaaef93837d46599ce21759ef481de" +source = "git+https://github.com/Harry-Chen/rust-mips#ec0c31e18a904536ffa19bbd1f5d0d0fd19b2cd1" dependencies = [ "bit_field 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/kernel/Makefile b/kernel/Makefile index ec23b36..31ff5eb 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -298,7 +298,7 @@ else ifeq ($(arch), riscv64) else ifeq ($(arch), aarch64) @$(objcopy) $(bootloader) --strip-all -O binary $@ else ifeq ($(arch), mipsel) - # qemu-system-mipsel accepts ELF file only, so don't use objcopy +# qemu-system-mipsel accepts ELF file only, so objcopy is not needed @$(strip) $(kernel) -o $@ endif diff --git a/kernel/src/backtrace.rs b/kernel/src/backtrace.rs index 337cfc8..4262d53 100644 --- a/kernel/src/backtrace.rs +++ b/kernel/src/backtrace.rs @@ -73,6 +73,8 @@ pub fn backtrace() { current_fp = ((current_fp as isize) - sp_offset) as usize; } + println!("=== BEGIN rCore stack trace ==="); + while current_pc >= stext as usize && current_pc <= etext as usize && current_fp as usize != 0 @@ -81,7 +83,7 @@ pub fn backtrace() { match size_of::() { 4 => { println!( - "Stack #{:02} PC: {:#010X} FP: {:#010X}", + "#{:02} PC: {:#010X} FP: {:#010X}", stack_num, current_pc - size_of::(), current_fp @@ -89,7 +91,7 @@ pub fn backtrace() { }, _ => { println!( - "Stack #{:02} PC: {:#018X} FP: {:#018X}", + "#{:02} PC: {:#018X} FP: {:#018X}", stack_num, current_pc - size_of::(), current_fp @@ -143,6 +145,7 @@ pub fn backtrace() { trace!("New PC {:08X} FP {:08X}", current_pc, current_fp); continue; } else { + trace!("No sw ra found, probably due to optimizations."); break; } } @@ -159,5 +162,6 @@ pub fn backtrace() { current_pc = *(current_fp as *const usize).offset(1); } } + println!("=== END rCore stack trace ==="); } } diff --git a/kernel/src/fs/mod.rs b/kernel/src/fs/mod.rs index a045552..51e3298 100644 --- a/kernel/src/fs/mod.rs +++ b/kernel/src/fs/mod.rs @@ -54,7 +54,7 @@ lazy_static! { fn _user_img_start(); fn _user_img_end(); } - println!("Sfs start {:x}, end {:x}", _user_img_start as usize, _user_img_end as usize); + info!("SFS linked to kernel, from {:08x} to {:08x}", _user_img_start as usize, _user_img_end as usize); Arc::new(unsafe { device::MemBuf::new(_user_img_start, _user_img_end) }) }; @@ -66,13 +66,7 @@ lazy_static! { Arc::new(unsafe { device::MemBuf::new(_user_img_start, _user_img_end) }) }; - let super_block = SimpleFileSystem::read(device2); - println!("Superblock: magic = {:x}, freemap_blocks = {:x}", super_block.magic, super_block.freemap_blocks); - println!("blocks = {:}", super_block.blocks); - println!("unused_blocks = {:}", super_block.unused_blocks); - let sfs = SimpleFileSystem::open(device).expect("failed to open SFS"); - // println!("{:}", sfs.free_map.read()); sfs.root_inode() }; }