This is a guide to help you set up a remote development environment for CPP programs on Pace. I've only tried this on a macOS High Sierra. You can loosely follow this guide if you have a different OS.
If you have GDB set up then skip this part.
I got LLDB to remote debug fine on the command line but haven't got it to work with VSCode yet. This seemed promissing though.
-
Install GDB 8.0.1 with Homebrew
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/9ec9fb27a33698fc7636afce5c1c16787e9ce3f3/Formula/gdb.rb --with-all-targets
Very important to add the
--with-all-targets
tag here so that GDB can attach to different systems (e.g. GNU linux for pace). This took ~11 min on my machine so be patient.Do not use the most recent GDB as it is still not compatiple with High Sierra as of the time of this post.
-
Codesign it. Instructions
-
Update
.gdbinit
echo "set startup-with-shell off" >> ~/.gdbinit
- Install extension
C/C++
- Mount your workspace(e.g. project1) on Pace locally somewhere(e.g. pace)
sshfs [email protected]:project1 ./pace
- Open the mounted folder locally using VSCode.
code pace
if you've added VSCode to your path - Create folders and files using VSCode. Follow the folder structure in this repo and write some code
- Put the
launch.json
andtasks.json
under you.vscode
folder. Changeexecutable
to the path of your shell (e.g.which bash
orwhich zsh
)
-
Once you've configured the build with Cmake, modify the
cmake.sh
to load the desired modules. Then hitshift-cmd-B
to generate a build.Put
set(CMAKE_BUILD_TYPE Debug)
in yourCMakeLists.txt
during debug. -
Set a break point. Start debugging(
F5
) and ignore the pop-up saying the task cannot be tracked and hit debug anyway. The debug console should start writing out messages. Wait for it to finish and voila!pace.sh
will use ssh to port forward 9091 on pace to your local 9091, compile your executable and start GDBServer. If you don't have ssh key set up, it will prompt for your password in the built-in terminal. Change to an external one by modifying"externalConsole": false
inlaunch.json
. Also you should make an ssh key. -
Don't forget to terminate the debug process at the end
This guide is largely based on the very detailed post by Spencer Elliot.