Visual Studio Code is a powerful text editor which can be expanded to a full featured integrated development environment (IDE) with plugins. To debug a program make sure to install the C/C++ Extension Pack which includes support for CMake and debugging with gdb
.
Then in the editor:
ogs.cpp
.main()
-function (around line 58) by clicking on the left gutter in the editor window (a red dot marks the enabled breakpoint).CMake
-sidebar.debug
is the active configure and build preset.Build
-button in the status bar.
After some seconds the debugger starts and halts at the specified breakpoint indicated y the yellow marker around the breakpoint and line. You can now step into or over statements with debugger controls at the top of the window:
To debug with specific arguments to ogs
, e.g. for setting a .prj
-file:
Debug
-sidebar.create a launch.json file
.Add Configuration
.C/C++: (gdb) Launch
Edit the file e.g. like this:
"program": "${workspaceFolder}/../build/debug/bin/ogs",
"args": ["${workspaceFolder}/Tests/Data/Parabolic/ComponentTransport/ReactiveTransport/CO2Injection/cl.prj"],
"cwd": "${workspaceFolder}/../build/debug/_out",
This sets the program to debug to the ogs
-binary in the debug build folder, sets a specific .prj
-file to run and sets the working directory (output folder) to some _out
-subfolder in the build directory.
You can also give the debug configuration some meaningful name, e.g. "name": "Debug cl.prj",
which results in a new button in the status bar:
Click on it to start the debug session.
This article was written by Lars Bilke. If you are missing something or you find an error please let us know.
Generated with Hugo 0.122.0
in CI job 493443
|
Last revision: September 23, 2024
Commit: [MeL/IO/XDMF] Return also computed parent data type 09baf91
| Edit this page on