1. Speed up system calls
  2. xv 6 的 vsc 调试
  3. lab 3

Speed up system calls

kernelbase 以上到 end 为 kernel 的空间,end 到 PHYSTOP 是 kmalloc 和 kfree 的空间。

xv 6 的 vsc 调试

四.使用vscode调试xv6内核 - All_just_for_fun - 博客园

launch. json 指定如何启动调试,task.json 制定了调试之前需要做的工作

-exec <要执行的gdb命令> 可以在 vsc 中执行 gdb 命令

-exec watch *(void/int/char...... *)(内存地址)/全局变量名 为表达式(变量)expr 设置一个观察点。一量表达式值有变化时,马上停住程序。

//lauch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "debug xv6",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/kernel/kernel",
            "args": [],
            "stopAtEntry": true,
            "cwd": "${workspaceFolder}",
            "miDebuggerServerAddress": "localhost:26000",
            "miDebuggerPath": "/usr/bin/gdb-multiarch",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "pretty printing",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "logging": {
                 "engineLogging": true,
                 "programOutput": true,
            },
            "preLaunchTask": "xv6build",
        }
    ]
}
// task.json
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "xv6build",
            "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.",
                        // 要对应编译成功后,一句echo的内容. 此处对应 Makefile Line:170
                        "endsPattern": "."
                    }
                }
            ]
        }
    ]
  }

lab 3

trampoline 用来处理 user 到 kernel 模式的转换(比如切换 pagetable 和寄存器这些)