|
11 | 11 | - [Install tools and build dependencies](install_tools_and_build_dependencies)
|
12 | 12 | - [Install Qt](install_qt)
|
13 | 13 | - [Build Open RV](build_openrv)
|
| 14 | +- [Setting up debugging in VSCode](debugging_openrv) |
14 | 15 |
|
15 | 16 | ````{note}
|
16 | 17 | OpenRV can be built for *x86_64* by changing the architecture of the terminal to *x86_64* using the following command:
|
@@ -160,3 +161,62 @@ Once the build is completed, the Open RV application can be found in the Open RV
|
160 | 161 | Once the build is completed, the Open RV application can be found in the Open RV directory under `_build_debug/stage/app/RV.app/Contents/MacOS/RV`.
|
161 | 162 | ```
|
162 | 163 | ````
|
| 164 | + |
| 165 | +(debugging_openrv)= |
| 166 | +## 9. Setting up debugging in VSCode |
| 167 | + |
| 168 | +For a general understanding on how to debug C++ code in VSCode, please refer to the [Microsoft documentation](https://code.visualstudio.com/docs/cpp/launch-json-reference). |
| 169 | + |
| 170 | +To set up the C++ debugger in VSCode for Open RV, use the following steps: |
| 171 | + |
| 172 | +1. **Install the [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb) extension** |
| 173 | +2. **Configure the debugger** |
| 174 | + Create a `.vscode` folder at the root of the project if it doesn't already exist. Inside this folder, create a `launch.json` file to configure the debugger with the following content: |
| 175 | +
|
| 176 | + ```json |
| 177 | + { |
| 178 | + "version": "0.2.0", |
| 179 | + "configurations": [ |
| 180 | + { |
| 181 | + "type": "lldb", |
| 182 | + "request": "launch", |
| 183 | + "name": "Debug Open RV (Debug Build)", |
| 184 | + "program": "${workspaceFolder}/_build_debug/stage/app/RV.app/Contents/MacOS/RV", |
| 185 | + "args": [], |
| 186 | + "cwd": "${workspaceFolder}", |
| 187 | + "preLaunchTask": "build" |
| 188 | + } |
| 189 | + ] |
| 190 | + } |
| 191 | + ``` |
| 192 | +
|
| 193 | + **NOTE:** `program` should point to the build of the Open RV executable you want to debug. `preLaunchTask` is only necessary if you decide to follow step 3. |
| 194 | +
|
| 195 | +3. **Set up automatic rebuild (Optional)** |
| 196 | + If you want to automatically rebuild Open RV before starting the debugger, add a `tasks.json` file in the `.vscode` folder created in the previous step: |
| 197 | +
|
| 198 | + ```json |
| 199 | + { |
| 200 | + "version": "2.0.0", |
| 201 | + "tasks": [ |
| 202 | + { |
| 203 | + "label": "build", |
| 204 | + "type": "shell", |
| 205 | + "command": "cmake", |
| 206 | + "args": [ |
| 207 | + "--build", |
| 208 | + "_build_debug", |
| 209 | + "--target", |
| 210 | + "main_executable" |
| 211 | + ], |
| 212 | + "group": { |
| 213 | + "kind": "build", |
| 214 | + "isDefault": true |
| 215 | + }, |
| 216 | + "presentation": { |
| 217 | + "reveal": "always" |
| 218 | + } |
| 219 | + } |
| 220 | + ] |
| 221 | + } |
| 222 | + ``` |
0 commit comments