KasperskyOS Community Edition 1.3
Preparations for debugging in QEMU
Preparations for debugging in QEMU
To prepare the conditions for debugging with the GDB server of the KasperskyOS kernel in QEMU, you must complete the following steps:
- Verify that KasperskyOS Community Edition contains a kernel version with the GDB server.
To do so, make sure that the
libexec/aarch64-kos/kos-qemu-gdbstub
file is included in KasperskyOS Community Edition. - Add the
GDBSTUB_KERNEL
parameter to the list of parameters of theCMake
commandbuild_kos_qemu_image()
.This parameter includes a kernel with the GDB server in the solution.
Example:
build_kos_qemu_image(kos-qemu-image GDBSTUB_KERNEL ... QEMU_FLAGS "${QEMU_FLAGS}") - Create a
.gdbinit
file so that you do not need to manually call the initial GDB commands every time the GDB debugger is started. (The.gdbinit
file must be saved in the directory where the GDB debugger will be run.)Example:
# Define a path to search for dynamic libraries containing debug symbols from # KasperskyOS Community Edition set sysroot /opt/KasperskyOS-Community-Edition-<version>/sysroot-aarch64-kos # Define additional paths to search for dynamic libraries containing debug # symbols set solib-search-path /home/user/example/build/lib1:/home/user/example/build/lib2 # Configure thread management (optional) # The GDB debugger can operate in all-stop or non-stop mode.In the first mode, # when the GDB debugger sees the stoppage of the thread whose context # is in the debug focus, it assumes that all other threads # known to the GDB debugger also stop. In the second mode, the GDB debugger assumes that # all threads except the stopped thread continue to run. All-stop mode # applied by the GDB debugger by default, and the GDB server of the kernel provides the capability to use # only this mode. To edit the default settings # for managing threads in all-stop mode, use GDB commands # set scheduler-locking and set schedule-multiple. # In this example, the first GDB command indicates that, when resuming # execution of a thread whose context is in the debug focus (for example, # the following GDB commands: continue, step, next), the GDB debugger must resume execution of all other threads. # The second GDB command indicates that the GDB debugger, when resuming execution of a thread # whose context is in the debugging focus, must resume execution of all # threads included in the processes of all programs that are being debugged. set scheduler-locking off set schedule-multiple on # Connect the GDB debugger to the GDB server of the kernel # The GDB server of the kernel interacts with the GDB debugger via an extended protocol, # and QEMU provides access to the kernel GDB server via the TCP socket. target extended-remote localhost:1234
Article ID: debugging_kernelstub_qemu_preparing, Last review: Feb 20, 2025