To begin debugging using the GDB server of the KasperskyOS kernel on the hardware platform, you must complete the following steps:
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
Execution of the solution code stops when the GDB debugger connects.
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.
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.
Page top