# Linux Kernel Module Cheat

#### 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"