Connecting a debugger when starting a program in a basic image
To connect a debugger to the GDB server of the kernel while starting a program in QEMU using the Visual Studio Code extension:
Set a breakpoint in the program source code before the fragment to be debugged.
Build the program after preparing it for debugging. To do so, you need to open the advanced build options using the build options selection button in the lower panel, indicate the debug build type from the drop-down list, and select the gdbstub check box. By default, this button displays type=debug. To pack an application into a KPA package, you must use the CMake commands of the kpa library. To package an application into a KPA package, you must use the CMake commands of the kpa library.
Wait for the basic image to finish loading and install the program by running the command KOS: Install package.
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) Launch & debug application, specify the path to the binary file of your program resulting from the build, and the program name. In the eiid field, you need to specify the kl.Kds value.
Start debugging by clicking the (kos/gdb) Launch & debug application button on the lower pane.
In the drop-down list, select the configuration named (kos/gdb) Launch & debug application.
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 1.