Here is a short guide on setting up and using the debugger in VS Codium / VS Code. The following example pictures show a C++ program, but everything works the same for C programs too. :)

Install CodeLLDB

For debugging, we need the extension “CodeLLDB”. At the virtual machine, all needed extensions are already installed. If you don't use the virtual machine it might be that you have to install the extension “CodeLLDB” first. Search for the “Extension” Tab at the left and click Install.

Start the debugging environment

  1. At the “Run” Tab on the left side, click on “Run and Debug” (see picture below)

  2. Select “LLDB” as the environment. If “LLDB” is not listed, you have to install it, as described above.

    Untitled

  3. A message will appear stating that no launch file is present. This file will be automatically created in a hidden folder '.vscode'. Now the debugger is created.

Compile Program and edit launch.json

  1. Under 'View' - 'Terminal', you can display the integrated terminal in VSCodium.

  2. Compile your program using for instance 'clang -Wall a1.c -o a1 -g'. Important: The '-g' flag indicates that you can debug the program. The compiled program is now named 'a1'.

  3. Afterward, in the 'launch.json' file in the subfolder ‘.vscode’, change the program path to your compiled file (for instance 'a1'). Note: in the following picture “oop1” is used as the name of the program.

    Untitled

  4. If you want to run your program with command line parameters, you can specify them under 'args'. For example, if you would run the program as './a1 cool 2', you would write the array '["cool", "2"]' into the 'args' value.

Execute the Program

  1. Now, you can set a breakpoint in the source file next to the line number - a red dot will appear there.
  2. In the 'Run' tab, there is now a green button at the top to start debugging.

Untitled

The program will run and stop at your set breakpoint. In the left sidebar, the current value of variables is displayed. In the debug menu (or using shortcuts), you can step through the program line by line.