Vscode qemu GDB远程调试linux内核
一、qemu(server端)启动Linux内核,带上-S -s选项
qemu-system-x86_64 -m 1024\
-nographic $SMP -kernel arch/x86/boot/bzImage \
-append "noinintrd console=ttyS0 crashkernel=256M root=/dev/vda
rootfstype=ext4 rw loglevel=8" \
-drive if=none,file=rootfs_debian_x86_64.ext4,id=hd0 \
-device virtio-blk-pci,drive=hd0 \
-netdev user,id=mynet\
-device virtio-net-pci,netdev=mynet\
--fsdev local,id=kmod_dev,path=./kmodules,security_model=none \
-device virtio-9p-pci,fsdev=kmod_dev,mount_tag=kmod_mount\
-S -s
二、vscode端(client端)的json文件配置(qemu运行x86)
{
"version": "0.2.0",
"configurations": [
{
"name": "kernel-debug",
"type": "cppdbg",
"request": "launch",
"miDebuggerServerAddress": "127.0.0.1:1234",
"program": "${workspaceFolder}/vmlinux",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"logging": {
"engineLogging": false
},
"MIMode": "gdb",
}
]
}
三、vscode端(client端)的json文件配置(qemu运行arm)
{
"version": "0.2.0",
"configurations": [
{
"name": "kernel-debug",
"type": "cppdbg",
"request": "launch",
"miDebuggerServerAddress": "127.0.0.1:1234",
"program": "${workspaceFolder}/vmlinux",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"logging": {
"engineLogging": false
},
"MIMode": "gdb",
"miDebuggerPath": "/opt/gcc-arm-none-eabi-10.3-2021.07/bin/arm-none-eabi-gdb"
}
]
}