GithubHelp home page GithubHelp logo

xv6-riscv's Introduction

Configure of Vscode debug

Build tool chain

# install tool chain
sudo apt-get install git build-essential gdb-multiarch qemu-system-misc gcc-riscv64-linux-gnu binutils-riscv64-linux-gnu 
# newer qemu
sudo apt-get remove qemu-system-misc
sudo apt-get install qemu-system-misc=1:4.2-3ubuntu6

GDB

make qemu-gdb
# based on hint, add .gdbinit under /home/dg
vim .gdbinit
# add below config to .gdbinit
add-auto-load-safe-path /home/dg/xv6-riscv/.gdbinit

gdb-multiarch kernel/kernel

Combine Vscode with GDB

实现vscode调试xv6,配置时需要注意.vscode和要编译项目不在一个目录下,因此要调整tasks中cwd和launch中program。 launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "xv6debug",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/xv6-riscv/kernel/kernel",
            "stopAtEntry": true,
            "cwd": "${workspaceFolder}",
            "miDebuggerServerAddress": "127.0.0.1:26000", 
            "miDebuggerPath": "/usr/bin/gdb-multiarch", 
            "MIMode": "gdb",
            "preLaunchTask": "xv6build"
        }
    ]
}

tasks.json: problemMatcher中指定了从Now run 'gdb' in another window这个位置开始追踪(有时间可以学一下problemMatcher)

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "xv6build",
            "type": "shell",
            "isBackground": true,
            "command": "make qemu-gdb",
            "options": {
                "cwd":"${workspaceFolder}/xv6-riscv"
            },
            "problemMatcher": [
                {
                    "pattern": [
                        {
                            "regexp": ".",
                            "file": 1,
                            "location": 2,
                            "message": 3
                        }
                    ],
                    "background": {
                        "beginsPattern": ".*Now run 'gdb' in another window.",
                        "endsPattern": "."
                    }
                }
            ]
        }
    ]
}

实现各个文件之间正确的跳转

# bear for project dependency
sudo apt-get install bear
make clean&&bear -- make qemu
# move compile_commands.json to .vscode
mv compile_commands.json ../.vscode/
vim c_cpp_properties.json

c_cpp_properties.json:

{
    "configurations": [
        {
            "name": "Linux",
            "compileCommands": "${workspaceFolder}/.vscode/compile_commands.json"
        }
    ],
    "version": 4
}

xv6-riscv's People

Contributors

4ge32 avatar aclements avatar amane-uehara avatar anishathalye avatar d0iasm avatar flespark avatar jjolly avatar jrrk2 avatar k-mrm avatar kaashoek avatar kehao95 avatar kimjungwow avatar kolontsov avatar l0stman avatar matt-har-vey avatar mikecat avatar olf0 avatar phf avatar pmaddams avatar rabbitdong-on avatar ravss avatar rsc avatar rui314 avatar saarett avatar takahirox avatar tchajed avatar waheedhafez avatar xiw avatar zeldovich avatar zhuyu1997 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.