# Linux Kernel Module Cheat
The perfect emulation setup to study and develop the <<linux-kernel>> v5.9.2, kernel modules, <<qemu-buildroot-setup,QEMU>>, <<gem5-buildroot-setup,gem5>> and x86_64, ARMv7 and ARMv8 <<userland-assembly,userland>> and <<baremetal-setup,baremetal>> assembly, <<c,ANSI C>>, <<cpp,C++>> and <<posix,POSIX>>. <<gdb>> and <<kgdb>> just work. Powered by <<about-the-qemu-buildroot-setup,Buildroot>> and <<about-the-baremetal-setup,crosstool-NG>>. Highly automated. Thoroughly documented. Automated <<test-this-repo,tests>>.

#### 3.6.2. GDB step debug userland BusyBox init

BusyBox custom init process:

- Shell 1:

      ./run --gdb-wait --kernel-cli 'init=/bin/ls'

- Shell 2:

      ./run-gdb --userland "$(./getvar buildroot_build_build_dir)"/busybox-*/busybox ls_main

This follows BusyBox' convention of calling the main for each executable as `<exec>_main` since the `busybox` executable has many "mains".

BusyBox default init process:

- Shell 1:

      ./run --gdb-wait

- Shell 2:

      ./run-gdb --userland "$(./getvar buildroot_build_build_dir)"/busybox-*/busybox init_main

`init` cannot be debugged with gdbserver without modifying the source, or else `/sbin/init` exits early with:

    "must be run as PID 1"