我正在设置一个很小的操作系统,按照本教程在 Ubuntu18.04 http://www.jamesmolloy.co.uk/tutorial_html/下进行操作。
到目前为止,我能够在QEMU中编译和运行这个小内核。 并且还能够使用命令行 GDB 连接 gdb 服务器。
qemu -S -s -fda floppy.img -boot a &
sleep 1
cgdb -x scripts/gdbinit
但是我想使用 Vscode gdb GUI 而不是命令行 gdb,所以我 https://wiki.osdev.org/User:TheCool1Kevin/VSCode_Debug 搜索此页面以设置 json 文件。 这是我的launch.json文件:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch with GDB",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/boot/boot.o",
"cwd": "${workspaceRoot}",
"args": [],
"targetArchitecture": "x86",
"MIMode": "gdb",
"miDebuggerPath": "",
"miDebuggerArgs": "",
"customLaunchSetupCommands": [],
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"text": "file ${workspaceRoot}/cmy_kernel",
"description": "Load binary."
},
{
"text": "target remote :1234",
"description": "connect the port"
},
{
"text": "break kern_entry",
"description": "Break on exception handler."
},
],
"preLaunchTask": "Launch QEMU"
}
]
}
我的任务.json是
{
"version": "2.0.0",
"tasks": [
{
"label": "Launch QEMU",
"type": "shell",
"windows": {
"command": ""
},
"linux": {
"command": "qemu -S -s -fda floppy.img -boot a &sleep 1 &"
}
}
]
}
我希望能够调试VScode下的代码,但是当我开始调试时,VScode显示无法连接服务器:1234超时。
我不知道如何修改文件.任何使用扩展的建议都值得赞赏。
你有没有试过这个与扩展 https://github.com/WebFreak001/code-debug
由于 -s 命令部署了服务器或端口:1234 您可以使用此配置来附加它。
{
"name": "Debug",
"type": "gdb",
"request": "attach",
"target": "localhost:1234",
"remote": true,
"gdbpath": "gdb",
"cwd": "${workspaceRoot}",
"valuesFormatting": "parseText",
}