前置说明:
git-v9版本:git clone https://github.com/mit-pdos/xv6-public/tree/xv6-rev9
bili:https://www.bilibili.com/video/BV15r4y1z75F
深圳大学罗秋明老师的课程
我自己用的wsl2的ubuntu18 无桌面版本 make qemu-nox
bug
起初在双系统的ubuntu20桌面版上运行,前面都很好,make qemu时load disk走不动了,但是运行2022版没问题,但和罗老师的视频不匹配,就回到了v9上,后来用阿里云的centos,因为不支持虚拟化,用不了。
然后就回到了wsl2的ubuntu18上
来来回回折腾环境一天,猫了个咪的!!
启动
启动,进入xv6-public的目录执行
justin@DESKTOP-NIK28BI:/mnt/d/code/vc6/xv6-public-xv6-rev9$ make qemu-nox
退出:ctrl+A 然后按 x退出
1+0 records out
512 bytes copied, 0.000731004 s, 700 kB/s
dd if=kernel of=xv6.img seek=1 conv=notrunc
350+1 records in
350+1 records out
179440 bytes (179 kB, 175 KiB) copied, 0.0676181 s, 2.7 MB/s
qemu-system-i386 -nographic -drive file=fs.img,index=1,media=disk,format=raw -drive file=xv6.img,index=0,media=disk,format=raw -smp 2 -m 512
xv6...
cpu1: starting
cpu0: starting
sb: size 1000 nblocks 941 ninodes 200 nlog 30 logstart 2 inodestart 32 bmap start 58
init: starting sh
$ QEMU: Terminated
文件类型:1目录 2普通文件 3设备文件
ctrl + p 可以看到当前已经启动的进程信息
$ 1 sleep init 80103ecf 80103f67 801047c8 80105739 801055db
2 sleep sh 80103e93 801002aa 80100f6c 80104ac2 801047c8 80105739 801055db
justin@DESKTOP-NIK28BI:/mnt/d/code/vc6/xv6-public-xv6-rev9$ addr2line -e kernel 80103e13
/mnt/d/code/vc6/xv6-public-xv6-rev9/proc.c:334
shell 进程 在读缓冲器,因为键盘没有输入,读不到,所以就sleep了。
调试xv6
启动gdb sever, 切记因为我没有桌面,所以用make qemu-nox-gdb, 有桌面的可以:make qemu-gdb
用的tcp协议26000端口
justin@DESKTOP-NIK28BI:/mnt/d/code/vc6/xv6-public-xv6-rev9$ make qemu-nox-gdb
*** Now run 'gdb'.
qemu-system-i386 -nographic -drive file=fs.img,index=1,media=disk,format=raw -drive file=xv6.img,index=0,media=disk,format=raw -smp 2 -m 512 -S -gdb tcp::26000
再来一个客户端
justin@DESKTOP-NIK28BI:/mnt/d/code/vc6/xv6-public-xv6-rev9$ gdb -silent kernel
Reading symbols from kernel...done.
warning: File "/mnt/d/code/vc6/xv6-public-xv6-rev9/.gdbinit" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".
To enable execution of this file addadd-auto-load-safe-path /mnt/d/code/vc6/xv6-public-xv6-rev9/.gdbinit
line to your configuration file "/home/justin/.gdbinit".
To completely disable this security protection addset auto-load safe-path /
line to your configuration file "/home/justin/.gdbinit".
For more information about this security protection see the
"Auto-loading safe path" section in the GDB manual. E.g., run from the shell:info "(gdb)Auto-loading safe path"
(gdb)
等待客户端输入命令了