VS Code on attu

Visual Studio Code is a popular editor that can connect to attu over SSH so you can edit and build your CSE 333 code with a graphical interface while the files and tools live on the CSE Linux machines. This guide covers connecting VS Code to attu over Remote - SSH. It then shows how to set up VS Code's graphical debugger, which is optional.

Connect VS Code to attu (Remote - SSH)

  1. Download and install VS Code from code.visualstudio.com/Download.
  2. Open the Extensions view (the icon that looks like three blocks with a fourth being added, or Ctrl+Shift+X), search for Remote - SSH (ms-vscode-remote.remote-ssh), and click Install.
    The VS Code Extensions view with 'ssh' typed in the search
                box and the Remote - SSH extension by Microsoft selected. A
                callout points to the Install button, and another notes that
                the other SSH extensions in the list are not needed.
    Search for Remote - SSH and install it.
  3. Open the Command Palette (F1 or Ctrl+Shift+P / Cmd+Shift+P), type Connect to Host, and choose Remote-SSH: Connect to Host… (it may not be first in the list).
    The VS Code Command Palette showing the 'Remote SSH: Connect
                to Host...' command highlighted in the results list.
    Pick Remote-SSH: Connect to Host….
  4. Enter <netid>@attu.cs.washington.edu (substitute your UW NetID) and press Enter. If prompted to choose a platform, pick Linux.
    The VS Code host input box with
                NETID@attu.cs.washington.edu typed in.
    Connect to <netid>@attu.cs.washington.edu.
  5. Enter your UW password when prompted and press Enter.
    A VS Code prompt reading 'Enter Password for
                NETID@attu.cs.washington.edu' with the password field
                highlighted.
    Enter your password to authenticate.
  6. Click Open Folder and select the folder you want to work in (for the course project, choose your cse333-26su-hw-<netid> folder). Folders are nested, so you can click into them just like cd on attu.
    The VS Code welcome screen with the 'Open folder...' link
                circled.
    Click Open Folder
    The VS Code Open Folder picker listing directories under
                /homes/iws/NETID on attu.
    …then select your working folder.
  7. You're connected! The Explorer shows the contents of the folder you opened, and the bottom-left corner shows SSH: attu.cs.washington.edu.
    The VS Code Explorer populated with the contents of the
                opened folder on attu, connected over SSH.
    The Explorer now shows your files on attu.

Remote Debugging (optional)


Install the C/C++ extension on attu

In the remote window (still connected to attu), open the Extensions view again and install C/C++ (ms-vscode.cpptools). This extension provides the debugger.

VS Code Extensions view connected to attu over SSH. Remote - SSH
            is listed and highlighted under the LOCAL - INSTALLED group, and
            C/C++ is listed and highlighted under the SSH:
            ATTU.CS.WASHINGTON.EDU - INSTALLED group.
Remote - SSH under LOCAL - INSTALLED and C/C++ under SSH: ATTU.CS.WASHINGTON.EDU - INSTALLED.

Run the debugger

Debug configs live in .vscode/, and we add one per homework as it's released.

  1. Set a breakpoint by clicking the gutter left of a line number.
  2. Open Run and Debug (Ctrl+Shift+D), pick a config from the dropdown, press F5.
  3. VS Code builds first, then stops at your breakpoints. Step with F10 / F11 / Shift+F11, continue with F5.
VS Code Run and Debug view connected to attu. The configuration
            dropdown is open showing the hw1 configs, a breakpoint is set in
            example_program_ll.c, and the integrated terminal shows GoogleTest
            output.
Pick a config from the Run and Debug dropdown and press F5.

For test suites, the "pick test" config prompts for a GoogleTest filter, e.g., Test_HashTable.AllocFree or Test_LinkedList.*.


Writing your own config

Add an entry to configurations in launch.json:

{
  "name": "hw1: example_program_ll",
  "type": "cppdbg",
  "request": "launch",
  "program": "${workspaceFolder}/hw1/example_program_ll",
  "args": [],
  "cwd": "${workspaceFolder}/hw1",
  "console": "integratedTerminal",
  "MIMode": "gdb",
  "preLaunchTask": "build hw1",
  "setupCommands": [
    { "text": "-enable-pretty-printing", "ignoreFailures": true }
  ]
}
  • program: the binary to debug.
  • args: command-line arguments, e.g., ["--gtest_filter=Test_LinkedList.Pop"].
  • preLaunchTask: must match a label in tasks.json.

To be prompted at launch, use an ${input:...} variable and define it in a top-level inputs array:

"args": ["--gtest_filter=${input:gtestFilter}"],
"inputs": [
  { "id": "gtestFilter", "type": "promptString", "default": "*" }
]

If you run into trouble, post on the Ed discussion board. Some of the staff have set this up before and can help you troubleshoot.