I want to use the IDE to debug the kernel.
As far as I understand, it is more correct to use cross-compiler gdb, but I do not know how to make visual studio code work with it. I compile .c files with debugging information (i386-elf-gcc -g) and copy characters to kernel.sym
Code: Select all
./i386-elf-4.9.1-Linux-x86_64/bin/i386-elf-objcopy --only-keep-debug kernel-0 kernel.sym
qemu-system-i386 -serial file:serial.log -s bootable.iso &
I don't know how in launch.json to specify the path to the cross-compiler gdb and that it should start and work.
I expect that visual studio code can work with it normally.
Because debugging via the console is extremely inconvenient.
Thanks.
UPD:
I came across this question
Installed Native Debugger, created launch.json and tasks.json
launch.json
Code: Select all
{
"version": "0.2.0",
"configurations": [
{
"type": "gdb",
"request": "attach",
"name": "Attach to QEMU",
"preLaunchTask": "(Debug) Build the kernel and run qemu",
"executable": "${workspaceFolder}/kernel-0",
"target": ":1234",
"remote": true,
"cwd": "${workspaceRoot}",
"gdbpath": "${workspaceRoot}/i386-elf-4.9.1-Linux-x86_64/bin/i386-elf-gdb"
}
]
}
Code: Select all
{
"tasks": [
{
"type": "shell",
"label": "(Debug) Build the kernel and run qemu",
"command": "bash",
"args": [
"${workspaceRoot}/build_all_crosscompile.sh",
"-d"
],
"options": {
"cwd": "${workspaceRoot}",
}
}
],
"version": "2.0.0"
}
./i386-elf-4.9.1-Linux-x86_64/bin/i386-elf-objcopy --only-keep-debug kernel-0 kernel.sym
qemu-system-i386 -serial file:serial.log -s bootable.iso &
Thus, before starting the debugger, qemu should start and wait for connection from gdb.
But qemu doesn't start, it just doesn't exist.
However, if I run ./build_all_crosscompile.sh -d from the terminal, then qemu is started.
The problem is that if I run qemu from the terminal, it doesn't wait for the debugger to connect to it, because I don't have time to start it.
If in build_all_crosscompile.sh I will do this and run it through the terminal:
Code: Select all
./i386-elf-4.9.1-Linux-x86_64/bin/i386-elf-objcopy --only-keep-debug kernel-0 kernel.sym
qemu-system-i386 -serial file:serial.log -s bootable.iso &
./i386-elf-4.9.1-Linux-x86_64/bin/i386-elf-gdb
In general. The problem is that qemu doesn't start if called from the task IDE.