add vscode debug support

This commit is contained in:
Yu Chen 2022-07-24 16:00:49 +08:00
parent 3cbaae1b29
commit 1e160d0a21
9 changed files with 36 additions and 7 deletions

View File

@ -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()

View File

@ -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

View File

@ -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;

View File

@ -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<Arc<TaskControlBlock>>,
pub upper_border:usize,
pub ready_queue: VecDeque<Arc<TaskControlBlock>>,
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<Arc<TaskControlBlock>> {
self.ready_queue.pop_front()
}
pub fn get_ready_queue_pointer(&mut self) -> &VecDeque<Arc<TaskControlBlock>> {
&self.ready_queue
}
}
lazy_static! {
@ -34,6 +45,10 @@ lazy_static! {
///Interface offered to add task
pub fn add_task(task: Arc<TaskControlBlock>) {
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<Arc<TaskControlBlock>> {

View File

@ -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",
]

View File

@ -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 = []

View File

@ -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 {

View File

@ -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];

View File

@ -27,6 +27,5 @@ SECTIONS
}
/DISCARD/ : {
*(.eh_frame)
*(.debug*)
}
}