Debugging on VS Code (Mac)
Debugging on VS Code involves the following steps:
- Make sure “C/C++ IntelliSense, debugging, and code browsing” extension is installed in the SSH remote machine.
- Add a configuration: launch.json
- Set a breakpoint or set the “stopAtEntry” to true.
- Run the configuration.
Add a configuration: launch.json
![](https://sites.tufts.edu/comp15/files/2021/06/Screen-Shot-2021-06-07-at-9.38.36-PM.png)
While selecting the .vscode on the left-navigation pane of the Explorer (Command+shift+e), enter Command+shift+d to enter into the “run and debug” set-up. Click on “create a launch.json file” and select “C++(GDB/LLDB)” from the environment menu selection. This will create a launch.json file and open it up for editing.
Change “program” to the program you intend to debug. For example, in your lab1, that would be “Array”. Change and save.
![](https://sites.tufts.edu/comp15/files/2021/06/Screen-Shot-2021-06-07-at-9.57.10-PM-1024x768.png)
Setting the program field
Make sure to add the path to the executable as follows:
“program”: “${workspaceFolder}/Array”,
Set a breakpoint
Set a breakpoint by clicking next to a line where you want to set a breakpoint. Or, set “stopAtEntry” in the launch.json file to true to stop at the beginning of calling the main function.
![](https://sites.tufts.edu/comp15/files/2021/06/Screen-Shot-2021-06-07-at-10.07.49-PM-1024x373.png)
Run the configuration
Now, you are ready to run and debug.
![](https://sites.tufts.edu/comp15/files/2021/06/Screen-Shot-2021-06-07-at-10.02.07-PM.png)