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

##### 23.9.5.1. QEMU reverse debugging

QEMU replays support checkpointing, and this allows for a simplistic "reverse debugging" implementation since v5.2.0:

    ./run --eval-after './linux/rand_check.out;./linux/poweroff.out;' --record
    ./run --eval-after './linux/rand_check.out;./linux/poweroff.out;' --replay --gdb-wait

On another shell:

    ./run-gdb start_kernel

In GDB:

    n
    n
    n
    n
    reverse-continue

and we are back at `start_kernel`

`reverse-continue` proceeds to the latest of the earlier breakpoints or to the very beginning if there were no breakpoints before.