---
# System prepended metadata

title: VSCode + QEMU-gdb
tags: ['6.1810']

---

VSCode + QEMU-gdb
===
###### tags: `6.1810`

# 使用 VSCode 搭配 xv6 qemu-gdb
## VSCode launch.json
首先在 VSCode 新增一個 launch.json

    "configurations": [
        {
            "name": "(lldb) Attach",
            "type": "cppdbg",
            "request": "launch",
            "MIMode": "gdb",
            "program": "${workspaceFolder}/kernel/kernel",
            "args": [],
            "miDebuggerServerAddress": "127.0.0.1:25501",
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "miDebuggerPath": "/opt/homebrew/bin/riscv64-unknown-elf-gdb",
        },
    ]
    
`program` 填入 kernel 路徑
`MIMode` 選擇 `gdb`
`miDebuggerServerAddress` 根據 .gdbinit.tmpl-riscv 填入地址
`miDebuggerPath` 填入 riscv 版本 gdb 路徑，可用 `whereis` 尋找

# Modify .gdbinit.tmpl-riscv
接著刪除 

    target remote 127.0.0.1:1234

否則會重複連線兩次
