# Linux Kernel Module Cheat

#### 17.22.1. dump_regs

The following kernel modules and Baremetal executables dump and disassemble various registers which cannot be observed from userland (usually "system registers", "control registers"):

- kernel_modules/dump_regs.c

- userland/arch/arm/dump_regs.c

- userland/arch/aarch64/dump_regs.c

- baremetal/arch/arm/dump_regs.c

- baremetal/arch/aarch64/dump_regs.c

Some of those programs are using:

- lkmc/aarch64_dump_regs.h

Alternatively, you can also get their value from inside GDB step debug with:

    info registers all

or the short version:

    i r a

or to get just specific registers, e.g. just ARMv8’s SCTLR:

    i r SCTLR

but it is sometimes just more convenient to run an executable to get the registers at the point of interest.

See also:

- https://stackoverflow.com/questions/5429137/how-to-print-register-values-in-gdb/31340294#31340294

- https://stackoverflow.com/questions/24169614/how-to-show-all-x86-control-registers-when-debugging-the-linux-kernel-in-gdb-thr/59311764#59311764