From 1e160d0a21df871ce390badc38efc992ee46ba0b Mon Sep 17 00:00:00 2001 From: Yu Chen Date: Sun, 24 Jul 2022 16:00:49 +0800 Subject: [PATCH] add vscode debug support --- easy-fs-fuse/src/main.rs | 4 ++-- os/Cargo.toml | 5 +++++ os/src/config.rs | 2 +- os/src/task/manager.rs | 17 ++++++++++++++++- user/.cargo/config | 2 +- user/Cargo.toml | 6 ++++++ user/src/bin/initproc.rs | 4 ++++ user/src/lib.rs | 2 +- user/src/linker.ld | 1 - 9 files changed, 36 insertions(+), 7 deletions(-) diff --git a/easy-fs-fuse/src/main.rs b/easy-fs-fuse/src/main.rs index cac1b797..fbc9ebed 100644 --- a/easy-fs-fuse/src/main.rs +++ b/easy-fs-fuse/src/main.rs @@ -55,11 +55,11 @@ fn easy_fs_pack() -> std::io::Result<()> { .write(true) .create(true) .open(format!("{}{}", target_path, "fs.img"))?; - f.set_len(16 * 2048 * 512).unwrap(); + f.set_len(64 * 2048 * 512).unwrap(); f }))); // 16MiB, at most 4095 files - let efs = EasyFileSystem::create(block_file, 16 * 2048, 1); + let efs = EasyFileSystem::create(block_file, 64 * 2048, 1); let root_inode = Arc::new(EasyFileSystem::root_inode(&efs)); let apps: Vec<_> = read_dir(src_path) .unwrap() diff --git a/os/Cargo.toml b/os/Cargo.toml index 660456c6..cf4c24af 100644 --- a/os/Cargo.toml +++ b/os/Cargo.toml @@ -24,3 +24,8 @@ board_k210 = [] [profile.release] debug = true +opt-level=0 +# debuginfo-level = 1 + +# Debuginfo level for the compiler. +# debuginfo-level-rustc = 2 \ No newline at end of file diff --git a/os/src/config.rs b/os/src/config.rs index f9a2b7fc..0bbec933 100644 --- a/os/src/config.rs +++ b/os/src/config.rs @@ -2,7 +2,7 @@ #[allow(unused)] pub const USER_STACK_SIZE: usize = 4096 * 2; -pub const KERNEL_STACK_SIZE: usize = 4096 * 2; +pub const KERNEL_STACK_SIZE: usize = 4096 * 20; pub const KERNEL_HEAP_SIZE: usize = 0x20_0000; pub const PAGE_SIZE: usize = 0x1000; diff --git a/os/src/task/manager.rs b/os/src/task/manager.rs index 315cd224..817bd861 100644 --- a/os/src/task/manager.rs +++ b/os/src/task/manager.rs @@ -1,12 +1,17 @@ //!Implementation of [`TaskManager`] +use core::borrow::Borrow; use super::TaskControlBlock; use crate::sync::UPSafeCell; use alloc::collections::VecDeque; use alloc::sync::Arc; use lazy_static::*; + ///A array of `TaskControlBlock` that is thread-safe +#[repr(C)] pub struct TaskManager { - ready_queue: VecDeque>, + pub upper_border:usize, + pub ready_queue: VecDeque>, + pub lower_border:usize, } /// A simple FIFO scheduler. @@ -14,7 +19,9 @@ impl TaskManager { ///Creat an empty TaskManager pub fn new() -> Self { Self { + upper_border:0xAAAAAAAA, ready_queue: VecDeque::new(), + lower_border:0xBBBBBBBB } } ///Add a task to `TaskManager` @@ -25,6 +32,10 @@ impl TaskManager { pub fn fetch(&mut self) -> Option> { self.ready_queue.pop_front() } + + pub fn get_ready_queue_pointer(&mut self) -> &VecDeque> { + &self.ready_queue + } } lazy_static! { @@ -34,6 +45,10 @@ lazy_static! { ///Interface offered to add task pub fn add_task(task: Arc) { TASK_MANAGER.exclusive_access().add(task); + //println!("TASK_MANAGER in {:p}\n",&TASK_MANAGER); + unsafe{ + TM_RQ=&TASK_MANAGER.exclusive_access().ready_queue as *const _ as usize; + } } ///Interface offered to pop the first task pub fn fetch_task() -> Option> { diff --git a/user/.cargo/config b/user/.cargo/config index e5ded8a1..16db5139 100644 --- a/user/.cargo/config +++ b/user/.cargo/config @@ -3,5 +3,5 @@ target = "riscv64gc-unknown-none-elf" [target.riscv64gc-unknown-none-elf] rustflags = [ - "-Clink-args=-Tsrc/linker.ld", + "-Clink-args=-Tsrc/linker.ld", "-Zunstable-options", ] diff --git a/user/Cargo.toml b/user/Cargo.toml index fe4fc563..ebb21f7e 100644 --- a/user/Cargo.toml +++ b/user/Cargo.toml @@ -12,6 +12,12 @@ bitflags = "1.2.1" [profile.release] debug = true +# opt-level=0 +# split-debuginfo="unpacked" +debuginfo-level = 1 + +# Debuginfo level for the compiler. +debuginfo-level-rustc = 2 [features] board_qemu = [] diff --git a/user/src/bin/initproc.rs b/user/src/bin/initproc.rs index 71bed27e..833d9072 100644 --- a/user/src/bin/initproc.rs +++ b/user/src/bin/initproc.rs @@ -8,6 +8,10 @@ use user_lib::{exec, fork, wait, yield_}; #[no_mangle] fn main() -> i32 { + println!("aaaaaaaaaaaaaa"); + let a = getpid(); + println!("{}",a); + if fork() == 0 { exec("user_shell\0"); } else { diff --git a/user/src/lib.rs b/user/src/lib.rs index c3b2cb90..9db18c9b 100644 --- a/user/src/lib.rs +++ b/user/src/lib.rs @@ -15,7 +15,7 @@ extern crate bitflags; use buddy_system_allocator::LockedHeap; use syscall::*; -const USER_HEAP_SIZE: usize = 32768; +const USER_HEAP_SIZE: usize = 32768*4; static mut HEAP_SPACE: [u8; USER_HEAP_SIZE] = [0; USER_HEAP_SIZE]; diff --git a/user/src/linker.ld b/user/src/linker.ld index 02f7b6bf..1df4e67e 100644 --- a/user/src/linker.ld +++ b/user/src/linker.ld @@ -27,6 +27,5 @@ SECTIONS } /DISCARD/ : { *(.eh_frame) - *(.debug*) } }