C/C++教程

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!
这篇关于Debug Xv6 Kernel with GDB, QEMU and VScode的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!