NS3 -Configuring VS Code for IntelliSence, Building and Debugging
Environments
- Umbundu Linux 22.04
- gcc 11.2.0
- gdb 12.0.90
- vs code , with extension c/c++
- NS3.5 installed under ~/NS3, build completed following https://www.nsnam.org/docs/release/3.35/tutorial/html/getting-started.html#building-ns-3
Configuring Visual Studio Code for Auto-Completion & Syntax Highlighting
Lunch VS Code at the NS3 directory:
1 |
|
Press F1 or (Ctrl + Shift + P) to access VS Code Command Palette, run “C/C++: Edit Configurations(JSON) ” to create/open a c_cpp_properties.json file and modify it
1 |
|
The full file like
1 |
|
Save and close c_cpp_properties.json file. Auto-Completion & Syntax Highlighting function should work now.
Configuring Build
Click Menu→Terminal→Configure Default Build Task to edit tasks.jason file under .vscode folder
1 |
|
Save and exit tasks.jason. The click Menu→Terminal→ Run Build Task or shortcut key (Ctrl + Shift + B), you should see build works.
Config gdb Debugging
Open ./scratch/scratch-simulator.cc in the VS Code. Press F5, choose “C++(GDB/LLB)”, then select “Waf - build and debug active file …” a window pop out and hit Open ‘launch.json’
Replace the content of ‘launch.json’ with the following
1 |
|
Save and exit. Now set a breakpoint in scratch-simulator.cc source file and hit F5, you should see that the debugging works. Be patient, the pdb is generally slow.