# Linux Kernel Module Cheat

### 3.10. Linux kernel GDB scripts

We source the Linux kernel GDB scripts by default for `lx-symbols`, but they also contains some other goodies worth looking into.

Those scripts basically parse some in-kernel data structures to offer greater visibility with GDB.

All defined commands are prefixed by `lx-`, so to get a full list just try to tab complete that.

There aren’t as many as I’d like, and the ones that do exist are pretty self explanatory, but let’s give a few examples.

Show dmesg:

    lx-dmesg

Show the Kernel command line parameters:

    lx-cmdline

Dump the device tree to a `fdtdump.dtb` file in the current directory:

    lx-fdtdump
    pwd

List inserted kernel modules:

    lx-lsmod

Sample output:

    Address            Module                  Size  Used by
    0xffffff80006d0000 hello                  16384  0

Bibliography:

- https://events.static.linuxfound.org/sites/events/files/slides/Debugging%20the%20Linux%20Kernel%20with%20GDB.pdf

- https://wiki.linaro.org/LandingTeams/ST/GDB

- lx-ps