/Teaching/Operating Systems/Tutorials/Configuring your IDE

Configuring your IDE

Here you find information on how to set up VSCode, Eclipse, and CLion.

VSCode setup

For VSCode to work with SWEB, you want to install the “C/C++” and the “Cmake Tools” extensions.

To install an extension: Open VSCode, select the extension tab on the left side, search for the extension name.

When some popup appears, ignore it, since we want to change some settings first, before CMake Tools does anything.

If CMake Tools ever asks you for a compiler, use “GCC-9.3.0” or similar. You may have to select “[scan for kits]” first.

If you want to use the built-in VSCode debugger:

At this point, you can go straight to the debug setup (scroll down to VSCode): https://www.iaik.tugraz.at/teaching/materials/os/tutorials/sweb-kernel-debuggen-mit-cgdb/

If you don’t want to use the built-in debugger:

After installing these two extensions, make sure you have your sweb folder open, then go to File->Preferences->Settings, switch from “User” to “Workspace” settings.

Search for “build dir“, change “Cmake: Build Directory” from “{workspaceFolder}/build” to “/tmp/sweb“.

Press ctrl+shift+p (aka “Show All Commands“), type “CMake: Build” and hit enter.

Your syntax highlighting, IntelliSense, etc. should be working now, and sweb is ready to be booted from /tmp/sweb.


Additional Tips:

  • If you want, you can enable the “Cmake: Configure on open” setting, so it automatically configures SWEB after a restart.
  • VSCode has built-in terminals, you can open a new one from the menu: Terminal->New Terminal.
    • Enter “cd /tmp/sweb” and “make qemu” and your sweb should be running!
  • Use ctrl+p to open a file in the current working dir by name (so you can start typing “Schedul…” and it will show you all files where that word appears in the title). This is very useful for sweb, where you have a lot of files spread over lots of folders.
  • Use ctrl+leftclick to go to the definition of a function.
  • You can use the built-in GUI for GIT, including switching branches, staging and committing, stashing, etc.
  • You can now add whatever extensions fit your working style. Some recommendations that I can highly recommend:
    • GitLens” – Adds additional functionality for git, always see who wrote what line when, compare lines/files with specific revisions etc (VSCode has built-in git support, GitLens just extends that).
    • Live Share Extension Pack” – Allows your entire group to work on the same pc at the same time, including comments on lines, seeing where someone is working right now etc.
      • Warning: If you use this extension you need to keep an eye on your unlocked points, since the points go towards the person that commits the changes, which will be the person hosting Live Share. You can take turns hosting the Live Share session or change the mail/name for the commits.
    • Back & Forth”  – adds buttons for going back and forth, for when you don’t have those buttons on your mouse (useful if you go jump to the definition of some function and want to return for example).

Eclipse setup

Disclaimer: Eclipse for C++ is a bit more work but it goes as follows:

Definition of Arch Constant

Eclipse should actually detect the definition of CMAKE_X86_64 by itself. But sometimes it does not. In this case go to Project → Properties → C/C++ General → Paths and Symbols → Symbols → Add: CMAKE_X86_64 with value 1 and add it to all configurations and all languages.

Filtering unused architecture resources

In order to filter architecture resources you don’t need:

    1. Open your SWEB project in Eclipse
    2. Open the project properties
    3. Choose Resource → Resource Filters in the list on the left
    4. You have to add filters with
      1. Filter type: Exclude all
      2. Applies to: Folders, All children (recursive)
    5. Add 4 filters with the following values for “Name matches”:
      1. arm
      2. pae
      3. xen
      4. 32

After you have added the filters, the “Resource Filters” list should show the following:

    1. Include only:
    2. Exclude all:
      1. Name matches arm (recursive)
      2. Name matches pae (recursive)
      3. Name matches xen (recursive)
      4. Name matches 32 (recursive)

Code completion or unresolved symbol problems

If it does not work to just create a new C/C++ Makefile project you can try to create the project files using cmake -G “Eclipse CDT4 - Unix Makefiles” .in the source directory.

Then backup the eclipse project files out of your source directory and remove the additional CMake files (and all untracked files) using

git clean -d -n # check whether there is something you still need 
git clean -d -f # delete the files listed before

Then copy the eclipse project files back into the source directory and create the C/C++ project as before.

Also try Index → Rebuild, sometimes that helps.


Configuring the Indexer

I configured Preferences → C/C++ indexer as follows:

    • [x] Enable indexer
    • [x] Index source files not included in the build
    • [x] Index unused headers
    • [x] Index all header variants
    • [x] Index source and header files opened in editor
    • [x] Allow heuristic resolution of includes
    • Skip files larger than: 8 MB (!)
    • [ ] Skip all references
    • [ ] Skip implicit references
    • [ ] Skip type and macro references
    • [x] Automatically update the index
    • [x] Update index immediately after every file-save
    • Index database cache – Limit relative to the maximum heap size: 15%
    • Index database cache – Absolute Limit: 256MB
    • Header file cache – Absolute Limit: 256MB

CLion setup

Just open the project folder, everything should work out of the box. You should delete unused architecture files to avoid confusions (see previous section).

The code completion and analysis usually works much faster and is more reliable than Eclipse.

Some keyboaord shortcuts may be conflicting with your Window Manager. Have a look in the Settings to change any important shortcuts (“Forwards” and “Backwards” are very helpful IMHO)

Be careful when for example adding new files, you do not want to modify the cmake files, as that could lead to SWEB being unable to build (read through all options when a popup appears).