# Linux Kernel Module Cheat

##### 38.16.1.4. GDB tests

We have some pexpect automated tests for GDB for both userland and baremetal programs!

Run the userland tests:

    ./build --all-archs test-gdb && \
    ./test-gdb --all-archs --all-emulators

Run the baremetal tests instead:

    ./test-gdb --all-archs --all-emulators --mode baremetal

Sources:

- test-gdb

- userland/gdb_tests/

- userland/arch/arm/gdb_tests/

- userland/arch/aarch64/gdb_tests/

If a test fails, re-run the test commands manually and use `--verbose` to understand what happened:

    ./run --arch arm --background --baremetal baremetal/c/add.c --gdb-wait &
    ./run-gdb --arch arm --baremetal baremetal/c/add.c --verbose -- main

and possibly repeat the GDB steps manually with the usual:

    ./run-gdb --arch arm --baremetal baremetal/c/add.c --no-continue --verbose

To debug GDB problems on gem5, you might want to enable the following tracing options:

    ./run \
      --arch arm \
      --baremetal baremetal/c/add.c \
      --gdb-wait \
      --trace GDBRecv,GDBSend \
      --trace-stdout \
    ;