Skip to content

Instantly share code, notes, and snippets.

@DraTeots
Last active October 29, 2018 03:35
Show Gist options
  • Save DraTeots/830596fe2d34c0c44a1555e10d1a8669 to your computer and use it in GitHub Desktop.
Save DraTeots/830596fe2d34c0c44a1555e10d1a8669 to your computer and use it in GitHub Desktop.
VsCode debug EIC JANA

Why vscode

Debugging capabilities

...

Working example:

Working debugger

The image shows features:

    • debugger is paused when condition is met
    • stepping
    • callstack
    • variables + imediate window shows content of an item of a vector
    • pretty printing
    • foreign code step trhough

C/C++ ms-vscode.cpptools Preview

Prerequesties

For vscode is better to have clang, lldb but it can work without them. C/C++ vscode plugin is mandatory.

Configuration

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${env:JANA_HOME}/bin/janadump",
            "args": ["-PPLUGINS=jleic_root_reader,vtx_fit", "hits.root", "-DMCGenerated", "-DVertexTrackerTrack"],
            "stopAtEntry": false,
            "cwd": "/home/romanov/jleic/work",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

Things to highlight:

    • ${env:JANA_HOME} uses environment variable 'JANA_HOME'. That is the way any other environment variable can be used.
    • cwd is the directory where the program is running. In the above example it is where hits.root and other required stuff is placed.

Otherwise it is pretty standard gcc debugging configuration found on internet

Life hacks:

    • If you intend to close vscode, change environment variables and open it again (like JANA_HOME in the above example), all other working vscode processes should be killed (in order for changes to make effect). Why? TL;DR; - because vscode doesn't block your terminal when you run "vscode "

Links

Launch configurations in general

Debugging launch.md description

Configuring includePath for better IntelliSense results

Pipe Transport (debug a process in a Docker container)

Variables (and how to use envifornment variables)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment