KasperskyOS Community Edition 1.3
Connecting a debugger while a program is running from a basic image
To connect a debugger to the GDB server of the kernel while the program is running in QEMU using the Visual Studio Code extension:
- Add an infinite loop to the
main
function of the program. This enables the debugger to connect to the running program. - Set a breakpoint in the program source code before the fragment to be debugged.
- Build the program. You must use the
CMake
commands of the kpa library to pack a program into a KPA package. - Run a basic KasperskyOS image from KasperskyOS Community Edition.
- On the side bar of Visual Studio Code, click Run and debug > create a launch.json file and then select KasperskyOS Debugger.
This will create a debug configuration file named
launch.json
. - In the
launch.json
file, in the field of the configuration named(kos/gdb) Attach to process
, specify the path to the binary file of your program resulting from the build. - Start the program in the basic image.
- Start debugging by clicking the
(kos/gdb) Attach to process
button on the lower pane. - In the drop-down list, select the configuration named
(kos/gdb) Attach to process
and select the name of the program to debug. - The debug console will show a message stating that the program is ready for debugging. Click Continue, and program execution will be stopped at the breakpoint that you selected at step 2.