# Linux Kernel Module Cheat

## 5. gdbserver

Step debug userland processes to understand how they are talking to the kernel.

First build `gdbserver` into the root filesystem:

    ./build-buildroot --config 'BR2_PACKAGE_GDB=y'

Then on guest, to debug userland/linux/rand_check.c:

    ./gdbserver.sh ./c/command_line_arguments.out asdf qwer

Source: rootfs_overlay/lkmc/gdbserver.sh.

And on host:

    ./run-gdb --gdbserver --userland userland/c/command_line_arguments.c main

or alternatively with the path to the executable itself:

    ./run --gdbserver --userland "$(./getvar userland_build_dir)/c/command_line_arguments.out"

Bibliography: https://reverseengineering.stackexchange.com/questions/8829/cross-debugging-for-arm-mips-elf-with-qemu-toolchain/16214#16214

- gdbserver BusyBox

- gdbserver libc

- gdbserver dynamic loader