Skip to content

Add VS Code / IDE helpers

Tadej Novak requested to merge tadej/athena:vscode into master

Motivated by the discussion at today's tutorial, I went forward and created a proof-of-concept VS Code helpers prototype. This is mainly to be used via SSH so we may as well change some of the defaults, but the way I made it should work in any build of Athena.

First of all I abuse the fact that if .vscode is checked-out, I automatically load the setup. As everything is contained in the build folder (a few extra symlinks and scripts) it should not matter, but we can make it cleaner.

Then the following things are done:

  • symlink current C++ compiler in the build folder as vsc_compiler (the default ${env:CXX} stopped working for me at some point)
  • symlink current python executable in the build folder as vsc_python (I guess there's no globally accessible variable already set so I used find_program here)
  • make a flake8 wrapper in the build folder as vsc_flake8 (basically loads the env.txt and uses python -m flake8)
  • make a gdb wrapper in the build folder as vsc_gdb_wrapper (this one calls setupATLAS, asetup and sources setup.sh)
  • make a gdb runner in the build folder as vsc_gdb_runner (this is really just necessary if we want to support singularity)
  • settings are updated to reflect that

This should technically work on any linux distro newer than CentOS 7 (I used it on Gentoo in the past), but I only tested the cleaned-up setup on CentOS 7 (where singularity is probably not needed, but it still works).

Then on running the actual tests: The test setup needs to be done like the script is run with python (like we usually run gdb). For OverlayTest.py (a CA-based standalone script) the launch command looks something like

{
  "name": "(gdb) OverlayTest",
  "type": "cppdbg",
  "request": "launch",
  "cwd": "${workspaceFolder}/../run",
  "program": "${workspaceFolder}/../build/vsc_python",
  "args": [
    "${workspaceFolder}/../build/x86_64-centos7-gcc11-opt/share/OverlayTest.py",
    "-t", "1", "-n", "5", "Truth"
  ],
  "MIMode": "gdb",
  "miDebuggerPath": "${workspaceFolder}/../build/vsc_gdb_runner"
}

Then all breakpoints and VS Code debugging functionality seems to work. This is nice for us lazy people who never learned how to set breakpoints in gdb 😉

Probably I made too many assumptions here and I am happy to cleanup the things if we want to include it in the repository.

Tagging people who may be interested: @akraszna, @fwinkl, @emoyse, @elmsheus

Edited by Tadej Novak

Merge request reports