Graphics.VSCodeSupport - lordmundi/wikidoctest GitHub Wiki
VS Code Support
The purpose of this document is to show DOUG core devs or plugin developers how to debug EDGE from within VS Code. This is not a detailed document about what VS Code is or how to use it - please see the VS Code online docs for general usage information.
What is VS Code?
Visual Studio Code is a cross-platform Integrated Development Environment w/ many useful features. While it runs on Windows, Mac & Linux, versions of Linux with too old a version of glibc will be unable to run VS Code. For more information about this IDE, check out the web site:
https://code.visualstudio.com/
Configuring Visual Studio Code for DOUG Development
VS Code provides a graphical user interface for debugging applications written in various languages. In C/C++, VS Code provides a convenient mechanism for debugging applications compiled w/ applications compiled w/ gdb debug symbols. Some features include setting breakpoints in code directly from source files (even prior to application start), pausing execution of specific threads, context-sensitive tools for peeking at what's in memory and automatic evaluation of multiple dynamically injected expressions / functions at runtime, etc.
In order to debug DOUG, the build process doesn't change. Just start VS Code from a terminal by navigating to the DOUG root-level directory and typing code . from there. VS Code will start in it's own process and you can safely kill the terminal you started it from. The directory you start VS Code from will be where the "project"-specific config files will live (in this case, it's just our DOUG repo's root-level directory and that's perfect). Once VS code is running you can open a terminal (running in VS Code) with the hotkey combo Ctrl+`. From the terminal, build DOUG as usual by navigating to the src/ directory and executing make.
Once it's built, you'll have to add this launch configuration to your launch.json file (under your hidden .vscode/) directory. To do so, click the 'debug' icon on the left-most panel (picture of a bug with a slash through it). Click the "gear" icon in the top-left panel to create a new launch configuration and choose C/C++. If you didn't have a launch.json already, this will automatically generate one for you. You'll want your launch configuration to look like the following (note that this is only 1 launch configuration, but your launch.json may contain many of these configurations):
Launch Configuration:
{
"name": "DOUG DEBUG Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/bin_Linux_x86_64/doug",
"args": ["-double","-mode","standalone","-display","ENG_GRAPHICS","-config","cev.cfg","-DEDGE_SETTINGS_FILE=\"edge_settings.cfg\"","-tcldebug","-quiet"],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [
{"name":"USERDATA", "value":"./userdata"},
{"name":"__GL_FSAA_MODE", "value":"5"},
{"name":"__GL_LOG_MAX_ANISO", "value":"4"},
{"name":"__GL_SYNC_TO_VBLANK", "value":"0"},
{"name":"MC_TAG", "value":"cev_comm_dspray1"},
{"name":"MC_PORT", "value":"12349"},
{"name":"MC_GROUP", "value":"225.0.0.48"},
{"name":"TCP_PORT", "value":"8200"},
{"name":"UDS_NODE", "value":"/tmp/cev_comm_dspray1"},
{"name":"SERVER_PORT", "value":"8200"},
{"name":"VR_HOST_CPU", "value":"Linux_x86_64"},
{"name":"DOUG_HOST_CPU", "value":"Linux_x86_64"},
{"name":"MISSION", "value":"CEV"},
{"name":"VERSION", "value":"EDGE_v2.4"},
{"name":"DYLD_LIBRARY_PATH", "value":"./lib_Linux_x86_64"},
{"name":"LD_LIBRARY_PATH", "value":"./lib_Linux_x86_64"},
{"name":"LD_LIBRARY32_PATH", "value":"./lib_Linux_x86_64"}
],
"externalConsole": true,
"linux": {
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
"osx": {
"MIMode": "lldb"
},
"windows": {
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
The main thing is to set the environment variables appropriately. If you have userdata/ specific configuration that needs to be added, you can just append to the json array for the "environment" key.
From here, all that's left to do is to hit the green arrow button on the top left or "F5" to start debugging. You'll see all the familiar debugging controls at the top of the VS Code window (Pause, Step Over, Step Into, Restart, Stop) and the "Variables", "Watch", and "Call Stack" on the left. You are now debugging DOUG from VS Code :)
Feel free to contact Danrae Pray ([email protected]) if you have any issues.