# Linux Kernel Module Cheat

### 33.9. GDB builtin CPU simulator

It is incredible, but GDB also has a CPU simulator inside of it as documented at: https://sourceware.org/gdb/onlinedocs/gdb/Target-Commands.html

TODO: any advantage over QEMU? I doubt it, mostly using it as as toy for now:

Without running `./run`, do directly:

    ./run-gdb --arch arm --baremetal userland/c/hello.c --sim

Then inside GDB:

    load
    starti

and now you can debug normally.

Enabled with the crosstool-NG configuration:

    CT_GDB_CROSS_SIM=y

which by grepping crosstool-NG we can see does on GDB:

    ./configure --enable-sim

Those are not set by default on `gdb-multiarch` in Ubuntu 16.04.

Bibliography:

- https://stackoverflow.com/questions/49470659/arm-none-eabi-gdb-undefined-target-command-sim

- http://cs107e.github.io/guides/gdb/

- GDB builtin CPU simulator userland