KasperskyOS Community Edition 1.3

Initial steps of debugging on the hardware platform

To begin debugging using the GDB server of the KasperskyOS kernel on the hardware platform, you must complete the following steps:

  1. Build debug versions of executable files and libraries and create a solution image for the hardware platform.

    To do so, call the cmake shell commands and specify the -D CMAKE_BUILD_TYPE:STRING=Debug and --target <tgt> parameters, where tgt is the value of the NAME parameter in the CMake command build_kos_hw_image().

    Example:

    #!/bin/bash ... cmake -G "Unix Makefiles" \ -D CMAKE_BUILD_TYPE:STRING=Debug \ -D CMAKE_TOOLCHAIN_FILE=$SDK_PREFIX/toolchain/share/toolchain-$TARGET.cmake \ -B build \ && cmake --build build --target kos-image
  2. Load the solution image to the hardware platform and start the solution.

    Execution of the solution code stops when the GDB debugger connects.

  3. Run the GDB debugger and connect to the GDB server of the kernel.

    To do so, run the executable file toolchain/bin/aarch64-kos-gdb from KasperskyOS Community Edition. It must be run in the directory where the manually created .gdbinit file was saved.

  4. Create inferiors, attach them to processes, and load debug symbols.

    To load debug symbols, you need to switch to the inferior associated with the process and use the following GDB commands:

    • add-symbol-file <path to file> — for executable files with static or dynamic linking.
    • file <path to file> – for executable files with dynamic linking.

    The GDB command file must be used so that the GDB debugger can load debug symbols of an executable file and the dynamic libraries required by this executable file. Use the GDB command add-symbol-file for the GDB debugger to load the debug symbols only for an executable file with dynamic linking.

    If debug symbols are saved in separate files instead of in the executable files, links to the files containing the debug symbols are added to the executable files. When the GDB command add-symbol-file or file is called, you can specify the executable file or the file containing debug symbols.

When performing a repeat build (step 1), you need to terminate the debug session (exit the GDB debugger) and repeat steps 2–4.