搭建环境
使用 docker 准备 xv6 环境
wtakuo/xv6-env
使用 docker 方式,参见:https://github.com/wtakuo/xv6-env
cd {path-to-xv6-riscv}
docker run -it --rm -v $(pwd):/home/xv6/xv6-riscv wtakuo/xv6-env
jjolly/xv6 (推荐)
cd {path-to-xv6-riscv}
docker run --name=xv6 -h xv6 -ti -v $(pwd):/xv6-riscv jjolly/xv6
再次运行 docker:
docker run -it 900266e4df99 /bin/bash
# or
docker run -it --rm -v $(pwd):/xv6-riscv jjolly/xv6
运行 xv6
cd /xv6-riscv
make qemu
详见:https://www.youtube.com/watch?v=juA01R9PzTI
Debug
基本使用
make CPUS=1 qemu-gdb
再打开一个 terminal
gdb-multiarch -q kernel/kernel
问题
- docker 环境下,gdb no Source Available
使用 vscode Remote Containers 来连接 docker 环境
前提条件
- 安装 Remote-Containers 插件。
在原镜像基础上又安装了一些软件,比如:vim, bear, clangd(Extension) 等。
保存成新的镜像:
docker commit {container_id} bermaker/xv6:latest
基本使用
生成
compile_commands.json
bear make qemu
[
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"kernel/kalloc.o",
"kernel/kalloc.c"
],
"directory": "/xv6-riscv",
"file": "kernel/kalloc.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"kernel/fs.o",
"kernel/fs.c"
],
"directory": "/xv6-riscv",
"file": "kernel/fs.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"user/umalloc.o",
"user/umalloc.c"
],
"directory": "/xv6-riscv",
"file": "user/umalloc.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"user/rm.o",
"user/rm.c"
],
"directory": "/xv6-riscv",
"file": "user/rm.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"kernel/main.o",
"kernel/main.c"
],
"directory": "/xv6-riscv",
"file": "kernel/main.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"kernel/proc.o",
"kernel/proc.c"
],
"directory": "/xv6-riscv",
"file": "kernel/proc.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-march=rv64g",
"-nostdinc",
"-I.",
"-Ikernel",
"-o",
"user/initcode.o",
"user/initcode.S"
],
"directory": "/xv6-riscv",
"file": "user/initcode.S"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"user/mkdir.o",
"user/mkdir.c"
],
"directory": "/xv6-riscv",
"file": "user/mkdir.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"kernel/sysproc.o",
"kernel/sysproc.c"
],
"directory": "/xv6-riscv",
"file": "kernel/sysproc.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"user/grind.o",
"user/grind.c"
],
"directory": "/xv6-riscv",
"file": "user/grind.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-o",
"kernel/entry.o",
"kernel/entry.S"
],
"directory": "/xv6-riscv",
"file": "kernel/entry.S"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"kernel/console.o",
"kernel/console.c"
],
"directory": "/xv6-riscv",
"file": "kernel/console.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-o",
"kernel/kernelvec.o",
"kernel/kernelvec.S"
],
"directory": "/xv6-riscv",
"file": "kernel/kernelvec.S"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"kernel/vm.o",
"kernel/vm.c"
],
"directory": "/xv6-riscv",
"file": "kernel/vm.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"kernel/trap.o",
"kernel/trap.c"
],
"directory": "/xv6-riscv",
"file": "kernel/trap.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"kernel/exec.o",
"kernel/exec.c"
],
"directory": "/xv6-riscv",
"file": "kernel/exec.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"kernel/log.o",
"kernel/log.c"
],
"directory": "/xv6-riscv",
"file": "kernel/log.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"user/kill.o",
"user/kill.c"
],
"directory": "/xv6-riscv",
"file": "user/kill.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"kernel/uart.o",
"kernel/uart.c"
],
"directory": "/xv6-riscv",
"file": "kernel/uart.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-o",
"kernel/trampoline.o",
"kernel/trampoline.S"
],
"directory": "/xv6-riscv",
"file": "kernel/trampoline.S"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"kernel/spinlock.o",
"kernel/spinlock.c"
],
"directory": "/xv6-riscv",
"file": "kernel/spinlock.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"user/echo.o",
"user/echo.c"
],
"directory": "/xv6-riscv",
"file": "user/echo.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"kernel/string.o",
"kernel/string.c"
],
"directory": "/xv6-riscv",
"file": "kernel/string.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"user/usertests.o",
"user/usertests.c"
],
"directory": "/xv6-riscv",
"file": "user/usertests.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"user/stressfs.o",
"user/stressfs.c"
],
"directory": "/xv6-riscv",
"file": "user/stressfs.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"user/sh.o",
"user/sh.c"
],
"directory": "/xv6-riscv",
"file": "user/sh.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"user/cat.o",
"user/cat.c"
],
"directory": "/xv6-riscv",
"file": "user/cat.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"user/zombie.o",
"user/zombie.c"
],
"directory": "/xv6-riscv",
"file": "user/zombie.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"kernel/pipe.o",
"kernel/pipe.c"
],
"directory": "/xv6-riscv",
"file": "kernel/pipe.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"user/grep.o",
"user/grep.c"
],
"directory": "/xv6-riscv",
"file": "user/grep.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"kernel/sysfile.o",
"kernel/sysfile.c"
],
"directory": "/xv6-riscv",
"file": "kernel/sysfile.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"kernel/syscall.o",
"kernel/syscall.c"
],
"directory": "/xv6-riscv",
"file": "kernel/syscall.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"kernel/plic.o",
"kernel/plic.c"
],
"directory": "/xv6-riscv",
"file": "kernel/plic.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-o",
"kernel/swtch.o",
"kernel/swtch.S"
],
"directory": "/xv6-riscv",
"file": "kernel/swtch.S"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"user/usys.o",
"user/usys.S"
],
"directory": "/xv6-riscv",
"file": "user/usys.S"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"kernel/start.o",
"kernel/start.c"
],
"directory": "/xv6-riscv",
"file": "kernel/start.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"kernel/printf.o",
"kernel/printf.c"
],
"directory": "/xv6-riscv",
"file": "kernel/printf.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"user/forktest.o",
"user/forktest.c"
],
"directory": "/xv6-riscv",
"file": "user/forktest.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"kernel/virtio_disk.o",
"kernel/virtio_disk.c"
],
"directory": "/xv6-riscv",
"file": "kernel/virtio_disk.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"kernel/bio.o",
"kernel/bio.c"
],
"directory": "/xv6-riscv",
"file": "kernel/bio.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"user/ln.o",
"user/ln.c"
],
"directory": "/xv6-riscv",
"file": "user/ln.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"user/ls.o",
"user/ls.c"
],
"directory": "/xv6-riscv",
"file": "user/ls.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"kernel/file.o",
"kernel/file.c"
],
"directory": "/xv6-riscv",
"file": "kernel/file.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"user/ulib.o",
"user/ulib.c"
],
"directory": "/xv6-riscv",
"file": "user/ulib.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"user/printf.o",
"user/printf.c"
],
"directory": "/xv6-riscv",
"file": "user/printf.c"
},
{
"arguments": [
"gcc",
"-c",
"-Werror",
"-Wall",
"-I.",
"-o",
"mkfs/mkfs",
"mkfs/mkfs.c"
],
"directory": "/xv6-riscv",
"file": "mkfs/mkfs.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"user/wc.o",
"user/wc.c"
],
"directory": "/xv6-riscv",
"file": "user/wc.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"user/init.o",
"user/init.c"
],
"directory": "/xv6-riscv",
"file": "user/init.c"
},
{
"arguments": [
"riscv64-linux-gnu-gcc",
"-c",
"-Wall",
"-Werror",
"-O",
"-fno-omit-frame-pointer",
"-ggdb",
"-mcmodel=medany",
"-ffreestanding",
"-fno-common",
"-nostdlib",
"-mno-relax",
"-I.",
"-fno-stack-protector",
"-fno-pie",
"-no-pie",
"-o",
"kernel/sleeplock.o",
"kernel/sleeplock.c"
],
"directory": "/xv6-riscv",
"file": "kernel/sleeplock.c"
}
]
.vscode/tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "xv6 build",
"type": "shell",
"isBackground": true,
"command": "make qemu-gdb",
"problemMatcher": [
{
"pattern": [
{
"regexp": ".",
"file": 1,
"location": 2,
"message": 3
}
],
"background": {
"beginsPattern": ".*Now run 'gdb' in another window.",
"endsPattern": "."
}
}
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
.vscode/launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "xv6 debug",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/kernel/kernel",
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"miDebuggerServerAddress": "127.0.0.1:25000", //见.gdbinit 中 target remote xxxx:xx
"miDebuggerPath": "/usr/bin/gdb-multiarch", // which gdb-multiarch
"MIMode": "gdb",
"preLaunchTask": "xv6 build"
}
]
}
.vscode/c_cpp_properties.json
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu17",
"cppStandard": "gnu++14",
"intelliSenseMode": "linux-gcc-x64",
"compileCommands": "${workspaceFolder}/compile_commands.json"
}
],
"version": 4
}
参见: