We received numerous questions asking whether it is possible to debug the current project inside Visual Studio Code. With the correct configuration files, this is indeed possible. The following archive contains the necessary configuration files: vscode.zip (2.0 KB)
Extract the configuration folder into the root directory of the project by entering the command unzip vscode.zip -d <path/to/project/dir>. Now you can
Launch and debug the main program from inside VSCode.
Launch and debug single public tests from inside VSCode.
Build the project at any time by simply pressing Ctrl + Shift + B
Debugging in VSCode
To debug your project, switch to the βRun & Debugβ panel by clicking the icon on the left side bar which looks like a play button with a small bug. Alternatively, press Ctrl + Shift + D. At the top of the panel, you can see a dropdown menu which contains all relevant program launch configurations for the project, e.g. β(Debug) Print statisticsβ which corresponds to the command carve_debug -s <input file>. You can also debug the public tests with the configuration βDebug public testβ.
To launch the program with the specified configuration, press the play button next to the dropdown menu. Before launch, the project is automatically rebuilt such that you do not accidentally run an older version of the program that does not match with the source files. Upon launch, you will be prompted for the necessary program arguments, e.g. the path to the input file or the number of steps for the algorithm.
After launching, the program will run until it hits a breakpoint, allowing you to inspect the program state at that specific moment. You may then let the program continue from that breakpoint, execute the program step by step, or let the program run until it exits the current function. The debug session ends upon exit of the program or when the program is forcefully stopped (by pressing the stop button). Importantly, detecting memory leaks at runtime is not supported by the VSCode debugger, so keep that in mind.
Iβve extracted the files and see the debugger in the Code OSS GUI. I can also choose βDebug public testβ and choose from a number of tests in the dropdown menu which appears.
However, some tests do not show up in this dropdown menu, even if I start typing their names, e.g. βpublic.min_path.owlβ or βpublic.min_path.small1β.
What is causing this? These are both tests that Iβve failed so far, so debugging these in particular would be very helpful.
The tests which are not in the dropdown menu use the carve_debug binary directly with appropriate commands instead of starting from the main function in test_main.c. For those you can run the corresponding program configuration (-p for min_path) with the corresponding input file (owl.ppm etc.).