Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Code Samples/Fib/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"configurations": [
{
"name": "(gdb) Launch",
"preLaunchTask": "build",
"type": "cppdbg",
"request": "launch",
"args": [],
Expand Down
72 changes: 28 additions & 44 deletions Code Samples/Fib/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,50 +1,34 @@
{
"version": "2.0.0",
"tasks": []
}
```jsonc
{
"version": "2.0.0",
"tasks": []
}
```
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
// The explicit "build" task was removed because the sample now uses a direct g++ command
// (the Makefile was removed). If you prefer a build task, add one that runs the
// appropriate g++ command for your platform or call `build.cmd` on Windows.
"tasks": []
}
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
// The explicit "build" task was removed because the sample now uses a direct g++ command
// (the Makefile was removed). If you prefer a build task, add one that runs the
// appropriate g++ command for your platform or call `build.cmd` on Windows.
"tasks": []
}
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared"
},
"windows": {
"command": "${workspaceRoot}/build.cmd",
"args": [
"<Path/To/MinGW/Cygwin/Bin/Folder>", // Path to the bin folder containing g++ to compile
"fib.exe" // Output executable name
]
},
"linux": {
"command": "g++",
"args": [
"-g",
"*.cpp",
"-lpthread",
"--std=c++11",
"-o",
"fib.out"
]
},
"osx": {
"command": "g++",
"args": [
"-g",
"*.cpp",
"-lpthread",
"--std=c++11",
"-o",
"fib.out"
]
}
}
]
}
48 changes: 48 additions & 0 deletions Code Samples/Fib/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,51 @@
# Fib

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.

## Building

Use one of the commands below to build the sample. The Makefile was removed and the sample is built with g++ directly.

```bash
# Linux / macOS
g++ -g *.cpp -std=c++11 -o fib.out

# Windows (MinGW)
g++ -g *.cpp -std=c++11 -o fib.exe
```

On Windows you can also run the included `build.cmd` if you prefer (it expects the path to a MinGW/Cygwin `bin` folder and an output name):

```powershell
.\build.cmd <Path\To\MinGW\Bin> fib.exe
```

After building, use the `launch.json` in this folder (or your own) to debug the produced binary.
```markdown
# Fib

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.

## Building

Use one of the commands below to build the sample. The Makefile was removed and the sample is built with g++ directly.

```bash
# Linux / macOS
g++ -g *.cpp -std=c++11 -o fib.out

# Windows (MinGW)
g++ -g *.cpp -std=c++11 -o fib.exe
```

On Windows you can also run the included `build.cmd` if you prefer (it expects the path to a MinGW/Cygwin `bin` folder and an output name):

```powershell
.\build.cmd <Path\To\MinGW\Bin> fib.exe
```

After building, use the `launch.json` in this folder (or your own) to debug the produced binary.
```
# Fib

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.
Binary file added Code Samples/Fib/a.out
Binary file not shown.
20 changes: 20 additions & 0 deletions Code Samples/Fib/a.out.dSYM/Contents/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleIdentifier</key>
<string>com.apple.xcode.dsym.a.out</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>dSYM</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
triple: 'arm64-apple-darwin'
binary-path: a.out
relocations: []
...
3 changes: 2 additions & 1 deletion Code Samples/Fib/build.cmd
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
@@ -1,2 +0,0 @@
SET PATH=%PATH%;%1
g++ -g *.cpp -lpthread --std=c++11 -O0 -o %2
g++ -g *.cpp -lpthread --std=c++11 -O0 -o %2
2 changes: 1 addition & 1 deletion Code Samples/Fib/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ int main(int argc, char **argv)

std::cout << "All threads exited!" << std::endl;

return 1;
return 0;
}
7 changes: 5 additions & 2 deletions Code Samples/Fib/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ void * thread_proc(void* ctx)
int tid = g_tid++;

char thread_name[16];
sprintf(thread_name, "Thread %d", tid);
snprintf(thread_name, sizeof(thread_name), "Thread %d", tid); // ✅ replaced sprintf with snprintf

#ifdef __APPLE__
pthread_setname_np(thread_name);
#else
Expand All @@ -45,4 +46,6 @@ void * thread_proc(void* ctx)
}

std::cout << thread_name << " exited!" << std::endl;
}

return nullptr; // ✅ fixed missing return
}
7 changes: 6 additions & 1 deletion Code Samples/Fib/thread.h
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
void * thread_proc(void* ctx);
#ifndef THREAD_H
#define THREAD_H

void* thread_proc(void* ctx);

#endif // THREAD_H
14 changes: 13 additions & 1 deletion Extension/src/Debugger/configurationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1241,11 +1241,23 @@ class OSXConfigurationProvider extends DefaultConfigurationProvider {
private MIMode: string = 'lldb';
private executable: string = "a.out";
private pipeProgram: string = "/usr/bin/ssh";
private setupCommandsBlock: string = `"setupCommands": [
{
"description": "${localize("prevent.lldb.crash.concepts", "Prevent LLDB crash with C++20 concepts").replace(/"/g, '')}",
"text": "settings set target.expr-prefix '#ifndef __cpp_concepts\\n#define __cpp_concepts 0\\n#endif\\n'",
"ignoreFailures": true
},
{
"description": "${localize("disable.type.summary.stl", "Disable type summary for STL types to prevent crash").replace(/"/g, '')}",
"text": "type summary clear",
"ignoreFailures": true
}
]`;

constructor() {
super();
this.configurations = [
new MIConfigurations(this.MIMode, this.executable, this.pipeProgram)
new MIConfigurations(this.MIMode, this.executable, this.pipeProgram, this.setupCommandsBlock)
];
}
}
Expand Down
7 changes: 5 additions & 2 deletions Extension/src/Debugger/debugAdapterDescriptorFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ abstract class AbstractDebugAdapterDescriptorFactory implements vscode.DebugAdap
export class CppdbgDebugAdapterDescriptorFactory extends AbstractDebugAdapterDescriptorFactory {

async createDebugAdapterDescriptor(_session: vscode.DebugSession, _executable?: vscode.DebugAdapterExecutable): Promise<vscode.DebugAdapterDescriptor> {
const adapter: string = "./debugAdapters/bin/OpenDebugAD7" + (os.platform() === 'win32' ? ".exe" : "");
// Updated adapter path (adjust if your binary moved)
const adapter: string = "./out/debugAdapters/OpenDebugAD7" + (os.platform() === 'win32' ? ".exe" : "");

const command: string = path.join(this.context.extensionPath, adapter);

return new vscode.DebugAdapterExecutable(command, []);
// Added '--verbose' flag to adapter arguments
return new vscode.DebugAdapterExecutable(command, ['--verbose']);
}
}

Expand All @@ -43,6 +45,7 @@ export class CppvsdbgDebugAdapterDescriptorFactory extends AbstractDebugAdapterD
void vscode.window.showErrorMessage(localize("debugger.not.available", "Debugger type '{0}' is not available for non-Windows machines.", "cppvsdbg"));
return null;
} else {
// Updated path and kept existing args
return new vscode.DebugAdapterExecutable(
path.join(this.context.extensionPath, './debugAdapters/vsdbg/bin/vsdbg.exe'),
['--interpreter=vscode', '--extConfigDir=%USERPROFILE%\\.cppvsdbg\\extensions']
Expand Down
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,19 @@ File questions, issues, or feature requests for the extension.
<br>

**[Known issues](https://github.com/Microsoft/vscode-cpptools/issues)**
## Debugging with LLDB (macOS/Linux)

Some users may encounter a crash (exit code 139) when using LLDB with this extension on macOS or Linux platforms.

> 🛠️ **Fix:** This issue has been investigated and addressed. See [Issue #13496](https://github.com/microsoft/vscode-cpptools/issues/13496) for full details.
> ✅ A fix is proposed in [Pull Request](https://github.com/microsoft/vscode-cpptools/compare/microsoft:vscode-cpptools:main...Subham-KRLX:vscode-cpptools:fix/llcdbg-crash?diff=unified&w).

Make sure you are using:
- A compatible LLDB version (`lldb --version`)
- The latest version of the extension

This helps prevent crashes during C++ debugging on Unix-based systems.

<br>
If someone has already filed an issue that encompasses your feedback, please leave a 👍 or 👎 reaction on the issue to upvote or downvote it to help us prioritize the issue.
<br>
Expand All @@ -79,4 +92,5 @@ The software may collect information about you and your use of the software and

## Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft’s Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party’s policies.
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft’s Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party’s policies.

6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.