# Linux Kernel Module Cheat

#### 24.22.1. gem5 Eclipse configuration

https://stackoverflow.com/questions/61656709/how-to-setup-eclipse-ide-for-gem5-development

In order to develop complex C++ software such as gem5, a good IDE setup is fundamental.

The best setup I’ve reached is with Eclipse. It is not perfect, and there is a learning curve, but is worth it.

Notably, it is very hard to get perfect due to: Why are all C++ symlinked into the gem5 build dir?.

I recommend the following settings, tested in Eclipse 2019.09, Ubuntu 18.04:

- fix all missing stdlib headers: https://stackoverflow.com/questions/10373788/how-to-solve-unresolved-inclusion-iostream-in-a-c-file-in-eclipse-cdt/51099533#51099533

- use spaces instead of tabs: Window, Preferences, Code Style, C/C++, Formatter, New, Edit, Tab Policy, Spaces Only

- either

  - create the project in the gem5 build directory! Files are moved around there and symlinked, and this gives the best chances of success

  - add to the include search path:

    - ./src/ in the source tree

    - the ISA specific build directory which contains some self-generated stuff, e.g.: out/gem5/default/build/ARM

To run and GDB step debug the executable, just copy the full command line without newlines from your run command (Eclipse does not like newlines for the arguments), e.g.:

    ./run --emulator gem5 --print-cmd-oneline

and configure it into Eclipse as usual.

One downside of this setup is that if you want to nuke your build directory to get a clean build, then the Eclipse configuration files present in it might get deleted. Maybe it is possible to store configuration files outside of the directory, but we are now mitigating that by making a backup copy of those configuration files before removing the directory, and restoring it when you do `./build-gem --clean`.