11## 1. Overview
22** TL;DR**
33``` bash
4- ./r
4+ ./scripts/run.sh
55```
66
7- ** Project Structure **
7+ ** Project Hierarchy **
88```
99includes/ → Header files (.h, .hpp)
1010src/ → Source files (.cpp)
1111tests/ → GoogleTest test cases
1212```
13+
1314## 2. Dependencies
1415Make sure the following tools are installed before building the project:
1516- ** g++ / gcc**
@@ -36,40 +37,44 @@ Get-ChildItem -Recurse -Include *.cpp, *.h, *.hpp | ForEach-Object { clang-forma
3637# ## 3.1. Setup the Local Test Environment
3738- ** Ubuntu system**
3839 * Install ` gcc` , ` cmake` , ` git` , and ` pthread` (Skip this step if you already install)
39- ` ` `
40+ ` ` ` bash
4041 $ sudo apt-get update
4142 $ sudo apt-get install g++
4243 $ sudo apt-get install lcov
4344 $ sudo apt-get install cmake
4445 $ sudo apt-get install git
46+ $ sudo apt install valgrind
4547 $ sudo apt-get install cppcheck
48+ $ sudo apt-get install -y clang-tidy
49+ $ sudo apt install python3-gcovr
4650 ` ` `
4751 * Build the application and the tests
48- ` ` `
52+ ` ` ` bash
4953 $ cd build
5054 $ cmake ..
5155 $ cmake --build .
5256 ` ` `
5357 * Run the application and the test
54- ` ` `
55- $ ./cpp_lab_project
56- $ ./cpp_lab_project_test
58+ ` ` ` bash
59+ $ ./bin/ cpp_lab_project
60+ $ ./bin/ cpp_lab_project_test
5761 ` ` `
5862 * Detect Memory Leak Using [valgrind](https://valgrind.org/)
59- ` ` `
60- $ sudo apt install valgrind
63+ ` ` ` bash
6164 $ valgrind --leak-check=full -v ./cpp-lab
6265 ` ` `
6366 * (Optional) Run static analysis - cppcheck
64- ` ` `
65- $ sudo apt-get install cppcheck
67+ ` ` ` bash
6668 $ cppcheck " folder" / " file"
6769 ` ` `
6870 * (Optional) Run static analysis - clang-tidy
69- ` ` `
70- $ sudo apt-get install -y clang-tidy
71+ ` ` ` bash
7172 $ clang-tidy -p build -header-filter=' ^src/.*' $( find src -name " *.cpp" )
7273 ` ` `
74+ * (Optional) Run coverage - lcov
75+ ` ` ` bash
76+ $ ./scripts/gen_coverage_lcov.sh
77+ ` ` `
7378- ** Docker**
7479 * Update ` Dockerfile`
7580 * Build the Docker image
@@ -95,6 +100,140 @@ Get-ChildItem -Recurse -Include *.cpp, *.h, *.hpp | ForEach-Object { clang-forma
95100 * ` cpp-lab:latest` : the image you built earlier.
96101 * ` /bin/bash` : the command to execute inside the container (opens a Bash shell).
97102
103+ # ## 3.2 Config C/C++ Debugging (VS Code)
104+
105+ # ### 3.2.1. Launch Configuration
106+
107+ To debug C/C++ projects in VS Code, you must create a * launch configuration* that specifies:
108+
109+ - The application entry point (executable)
110+ - How to attach to a running process
111+ - Environment variables needed
112+ - Saved debugging setup details
113+
114+ All launch configs are stored in ` .vscode/launch.json` within your workspace.
115+ # #### a. Create `launch.json`
116+ - Go to ` Run` → ` Add Configuration...` or
117+ - Use VS Code chat command:
118+ ` ` `
119+ /startDebugging
120+ ` ` `
121+ to auto-generate a debug configuration.
122+
123+ # #### b. Start Debugging
124+
125+ You can start a debug session in several ways:
126+ - ** F5**
127+ - ** Ctrl + Shift + D** : Open Debug panel, select a config, press Start
128+ - ** Ctrl + Shift + P** → select `Debug: Select and Start Debugging`
129+
130+ # ### 3.2.2. Debug Configuration Example
131+
132+ The most important field is the executable that will run:
133+
134+ ` ` ` json
135+ // .vscode/launch.json
136+ {
137+ " version" : " 0.2.0" ,
138+ " configurations" : [
139+ {
140+ " name" : " (gdb) Launch" ,
141+ " type" : " cppdbg" ,
142+ " request" : " launch" ,
143+ " program" : " ${workspaceFolder} /build/debug/bin/cpp_lab_project" ,
144+ " args" : [],
145+ " stopAtEntry" : true,
146+ " cwd" : " ${workspaceFolder} " ,
147+ " environment" : [],
148+ " externalConsole" : false,
149+ " MIMode" : " gdb" ,
150+ " preLaunchTask" : " CMake Debug Build" ,
151+ " setupCommands" : [
152+ {
153+ " description" : " Enable pretty printing for gdb" ,
154+ " text" : " -enable-pretty-printing" ,
155+ " ignoreFailures" : true
156+ },
157+ {
158+ " description" : " Set disassembly flavor to Intel" ,
159+ " text" : " -gdb-set disassembly-flavor intel" ,
160+ " ignoreFailures" : true
161+ }
162+ ]
163+ }
164+ ]
165+ }
166+ ` ` `
167+
168+ # ### 3.2.3. Build Tasks (CMake)
169+
170+ An example ` tasks.json` for CMake builds:
171+
172+ ` ` ` json
173+ // .vscode/tasks.json
174+ {
175+ " version" : " 2.0.0" ,
176+ " tasks" : [
177+ {
178+ " label" : " CMake Debug Configure" ,
179+ " type" : " shell" ,
180+ " command" : " cmake" ,
181+ " args" : [
182+ " -S" ,
183+ " ." ,
184+ " -B" ,
185+ " build/debug" ,
186+ " -DCMAKE_BUILD_TYPE=Debug"
187+ ]
188+ },
189+ {
190+ " label" : " CMake Debug Build" ,
191+ " type" : " shell" ,
192+ " command" : " cmake" ,
193+ " args" : [
194+ " --build" ,
195+ " build/debug"
196+ ],
197+ " group" : {
198+ " kind" : " build" ,
199+ " isDefault" : true
200+ },
201+ " presentation" : {
202+ " reveal" : " always"
203+ },
204+ " dependsOn" : " CMake Debug Configure"
205+ }
206+ ]
207+ }
208+ ` ` `
209+ # ### 3.2.4. Run Steps
210+
211+ 1. ** Open** your project in VS Code
212+ 2. ** Install Extension:**
213+ - * C/C++ Extension Pack*
214+ 3. ** Install GDB:**
215+ ` ` ` bash
216+ sudo apt update
217+ sudo apt install gdb
218+ ` ` `
219+ 4. ** Start Debugging:**
220+ Press ` F5`
221+ 5. ** Run Without Debugging:**
222+ Press ` Ctrl + F5`
223+ 6. ** Build Project (Optional):**
224+ Press ` Ctrl + Shift + B`
225+
226+ Notes:
227+ | Shortcut | Action |
228+ | -----------------| -----------------------|
229+ | F5 | Start debugging |
230+ | Ctrl + F5 | Run without debugging |
231+ | Ctrl + Shift + D| Open Debug panel |
232+ | Ctrl + Shift + B| Build project |
233+
234+ # ## 3.3 Documentation with `doxygen`
235+ TBD - Refer to this [Documentation with doxygen](https://www.labri.fr/perso/fleury/posts/programming/using-cmake-googletests-and-gcovr-in-a-c-project.html#:~ :text=of%20the%C2%A0project.-,Documentation%20with%20doxygen,-Code%20embedded%20documentation)
236+
98237# # 5. Update Docker Image
99238` ` ` bash
100239# Navigate to the project that contain your Dockerfile
0 commit comments