# Linux Kernel Module Cheat

##### 3.4.2.1. GDB module_init step into it

This is the best method we’ve found so far.

The kernel calls `module_init` synchronously, therefore it is not hard to step into that call.

As of 4.16, the call happens in `do_one_initcall`, so we can do in shell 1:

    ./run

shell 2 after boot finishes (because there are other calls to `do_init_module` at boot, presumably for the built-in modules):

    ./run-gdb do_one_initcall

then step until the line:

    833         ret = fn();

which does the actual call, and then step into it.

For the next time, you can also put a breakpoint there directly:

    ./run-gdb init/main.c:833

How we found this out: first we got GDB module_init calculate entry address working, and then we did a `bt`. AKA cheating :-)