lab 1 中 primes.c 写了一个递归,make qemu的时候会报error,error: infinite recursion detected [-Werror=infinite-recursion],导致编译无法通过。
解决办法:
在Makefile中,找到CFLAGS,找到 -Werror
选项并将其删除,这样编译器警告将不再被视为错误就能通过了。
调试内核: 运行gdb: 打开一个终端 进入xv文件夹
键入make CPUS=1 qemu-gdb
打开新的终端 键入
gdb-multiarch
如果给warning:
ile "/root/xv6-labs-2020/.gdbinit" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".
To enable execution of this file add
add-auto-load-safe-path /root/xv6-labs-2020/.gdbinit
line to your configuration file "/root/.config/gdb/gdbinit".
To completely disable this security protection add
set auto-load safe-path /
line to your configuration file "/root/.config/gdb/gdbinit".
那么你就在按照他给目录逐步创建 最终创建一个gdbinit文件,里面填进去add-auto-load-safe-path /root/xv6-labs-2020/.gdbinit
就可以了(后续补充,先git fetch,git checkout 到system call分支,就能有对应的依赖文件了)
target remote localhost: (填入上一个终端生成的数字)
之后就可以开始调试了。
加一个之前忘了写的内容,lab 2当中添加sysnames的时候,一定要是22个系统调用,最好直接复制上面的syscalls的定义方法定义sysnames,永远不会错,对应的字母也要写对,这是要注意的,样例本身比较少,如果样例变多,sysnames不对就不能ac了。
PTE2PA函数 PTE低10位是FLAGS,54到11位是PPN,先把这些FLAGS去掉 >>10,再进十二位,得到PPN,PPN
表示的是页面的编号,它可以直接映射到物理内存的某个 4KB 的块的开始位置,将 PPN
与 Offset
组合起来,形成物理地址,Offset
用于在这个 4KB 的块内部定位到具体的字节。这样通过PTE2PA函数就得到了实际的物理地址。
持续更新。。。