Link Search Menu Expand Document

Visual Studio Code

We recommend using Visual Studio Code for this class, since it is cross-platform, provides solid editing support for C++, CMake, and Docker files through various extensions, and supports remote debugging.

Table of contents

  1. Extensions
  2. Remote debugging
  3. Suggested reading


We recommend installing the following extensions to start:

  • C/C++ (by Microsoft)
  • CMake (by twxs)
  • CodeLLDB (by Vadim Chugunov)
  • Docker (by Microsoft)

Remote debugging

By enabling remote debugging port forwarding in the Development Environment and running the LLDB server, you will be able to debug a process running in the development environment from Visual Studio Code running natively on your machine. Note these instructions

To start, click the Debug icon in the blue bar at the bottom of the screen (looks like a play button with a bug on it) to open the debug configuration selector, then click Add Configuration. In the pop-up menu that appears, choose CodeLLDB: Custom Launch, which opens up a launch.json file for editing. Update the new "type": "lldb" configuration to match the one below, where PATH_TO_BIN_DIRECTORY is the path to the directory containing your binary (e.g. ${REPO}/build/bin), BINARY_NAME is the name of your binary (e.g. webserver), and ARGS are your command arguments (e.g. /usr/src/projects/${REPO}/path_to_config):

"configurations": [
    "type": "lldb",
    "request": "custom",
    "name": "Devel Env Debug",
    "sourceMap": {
      "/usr/src/projects/": "${workspaceFolder}/",
      "/usr/include/": "${workspaceFolder}/mirror/include/",
    "initCommands": [
      "platform select remote-linux",
      "platform connect connect://",
      "platform settings -w /usr/src/projects/PATH_TO_BIN_DIRECTORY",
    "targetCreateCommands": [
      "target create BINARY_NAME"
    "processCreateCommands": [
      "process launch ARGS"

This example assumes that you have opened Visual Studio Code to the same directory in which you are running the development environment, so that it is rooted in the same directory that /usr/src/projects is mapped to.

One critical setting is the sourceMap. These values are pairs of path mappings from the remote machine (development environment) to your local machine. These mappings allow the remote debugger and the local debugger/IDE to translate between different source file paths, since the paths of source files in the development environment are probably different than the paths on your local machine. Getting these right is crucial for getting breakpoints to work, and in getting the IDE to load the correct source when breakpoints are hit.

In this example we have:

  • /usr/src/projects/ mapping to ${workspaceFolder}/
    • This was the assumption we described above, with your editor open to your development environment directory.
  • /usr/include/ mapping to ${workspaceFolder}/mirror/include/
    • This allows your IDE to find the headers mirrored from your development environment.

Update the values in your new launch.json to reflect your project paths. Note that the server will be run from your build directory, so any file paths should be given with full absolute paths. Also note that ${workspaceFolder} is a Visual Studio Code variable and should not be replaced by you. Save the file to create the new Devel Env Debug configuration.

To debug, run in your development environment, and press the Play button next to the Devel Env Debug entry in the debug panel of Visual Studio Code. For more information, see debugging documentation for Visual Studio Code.

Suggested reading

Back to top

“You may think using Google’s great, but I still think it’s terrible.” —Larry Page

Page last modified: May 30, 2022.