其他分享
首页 > 其他分享> > Debug Xv6 Kernel with GDB, QEMU and VScode

Debug Xv6 Kernel with GDB, QEMU and VScode

作者:互联网

Debug Xv6 Kernel with GDB, QEMU and VScode

The launch.json is as follows:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "C/C++: gcc 生成和调试活动文件",
            "type": "cppdbg",
            "request": "launch",
            "miDebuggerPath": "/usr/bin/gdb-multiarch",
            "miDebuggerServerAddress": "127.0.0.1:25000",
            "program": "/root/xv6-labs-2021/kernel/kernel",
            "args": [],
            "stopAtEntry": false,
            "cwd": "/root/xv6-labs-2021",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "将反汇编风格设置为 Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                },
            ],
        }
    ]
}
  1. Run make CPUS=1 qemu-gdb in a seperate shell terminal.
  2. Modify .gdbinit generated in the xv6 root directory. Comment out target remote 127.0.0.1:25000. Remaining contents are
set confirm off
set architecture riscv:rv64
symbol-file kernel/kernel
set disassemble-next-line auto
set riscv use-compressed-breakpoints yes
  1. Press F5 in vscode and enjoy debugging!

标签:Kernel,set,kernel,VScode,text,Xv6,gdb,xv6,root
来源: https://www.cnblogs.com/linfengshu/p/16380103.html