Skip to content

Commit 7f835f0

Browse files
committed
Finalize multithreaded sample with cross-platform support:
- Restored original launch.json debugging config - Optimized tasks.json for Windows/Unix builds - Updated README with clear documentation - Verified all test cases pass
1 parent d9335fa commit 7f835f0

File tree

3 files changed

+100
-10
lines changed

3 files changed

+100
-10
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "(gdb) Launch",
6+
"type": "cppdbg",
7+
"request": "launch",
8+
"program": "${workspaceFolder}/fib.out",
9+
"args": [],
10+
"stopAtEntry": false,
11+
"cwd": "${workspaceFolder}",
12+
"environment": [],
13+
"externalConsole": false,
14+
"MIMode": "gdb",
15+
"setupCommands": [
16+
{
17+
"description": "Enable pretty-printing",
18+
"text": "-enable-pretty-printing",
19+
"ignoreFailures": true
20+
}
21+
],
22+
"windows": {
23+
"program": "${workspaceFolder}/fib.exe",
24+
"miDebuggerPath": "<Path/To/GDB>" // Path to gdb on windows
25+
},
26+
"linux": {
27+
"program": "${workspaceRoot}/fib.out"
28+
}
29+
}
30+
]
31+
}
Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
2-
// See https://go.microsoft.com/fwlink/?LinkId=733558
2+
// See https://go.microsoft.com/fwlink/?LinkId=733558
33
// for the documentation about the tasks.json format
44
"version": "2.0.0",
55
"tasks": [
66
{
7-
"label": "build",
7+
"label": "build (Unix)",
88
"type": "shell",
99
"command": "make",
1010
"group": {
@@ -13,18 +13,52 @@
1313
},
1414
"problemMatcher": ["$gcc"],
1515
"options": {
16-
"cwd": "${workspaceFolder}/Code Samples/Fib"
16+
"cwd": "${workspaceFolder}"
1717
},
18-
"detail": "Build C++ Fibonacci sample using Makefile"
18+
"detail": "Build using Makefile (Linux/macOS)"
1919
},
2020
{
21-
"label": "clean",
21+
"label": "build (Windows)",
22+
"type": "shell",
23+
"command": "g++ -std=c++11 -pthread -o fib.exe main.cpp thread.cpp",
24+
"group": "build",
25+
"problemMatcher": ["$gcc"],
26+
"options": {
27+
"cwd": "${workspaceFolder}"
28+
},
29+
"detail": "Build using g++ (Windows/MinGW)",
30+
"windows": {
31+
"options": {
32+
"shell": {
33+
"executable": "cmd.exe",
34+
"args": ["/C"]
35+
}
36+
}
37+
}
38+
},
39+
{
40+
"label": "clean (Unix)",
2241
"type": "shell",
2342
"command": "make clean",
2443
"options": {
25-
"cwd": "${workspaceFolder}/Code Samples/Fib"
44+
"cwd": "${workspaceFolder}"
45+
}
46+
},
47+
{
48+
"label": "clean (Windows)",
49+
"type": "shell",
50+
"command": "del /Q fib.exe",
51+
"options": {
52+
"cwd": "${workspaceFolder}"
53+
},
54+
"windows": {
55+
"options": {
56+
"shell": {
57+
"executable": "cmd.exe",
58+
"args": ["/C"]
59+
}
60+
}
2661
}
2762
}
2863
]
29-
}
30-
64+
}

Code Samples/Fib/README.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1-
# Fib
1+
# Fibonacci Debugging Sample
22

3-
This code sample is to show debugging. Update `launch.json` and `tasks.json` in the `.vscode` folder to use your setup to build and debug.
3+
This sample demonstrates C++ debugging capabilities in VS Code using a multithreaded Fibonacci number generator.
4+
5+
## Features
6+
- Modern C++ implementation using `std::thread`
7+
- Cross-platform debugging configuration
8+
- Multiple debugging scenarios:
9+
- Breakpoint debugging
10+
- Conditional breakpoints
11+
- Watch expressions
12+
- Crash investigation
13+
- Debugger attachment
14+
15+
## Getting Started
16+
17+
### Prerequisites
18+
- C++ compiler (g++/clang/MSVC)
19+
- VS Code with C++ extension
20+
- Debugger (gdb/lldb/MSVC debugger)
21+
22+
### Building
23+
```bash
24+
# Linux/macOS
25+
make
26+
27+
# Windows (MinGW)
28+
g++ -std=c++11 -pthread -o fib.exe main.cpp thread.cpp

0 commit comments

Comments
 (0)