diff --git a/Code Samples/Fib/a.out b/Code Samples/Fib/a.out new file mode 100755 index 0000000000..41e706acf9 Binary files /dev/null and b/Code Samples/Fib/a.out differ diff --git a/Code Samples/Fib/a.out.dSYM/Contents/Info.plist b/Code Samples/Fib/a.out.dSYM/Contents/Info.plist new file mode 100644 index 0000000000..3679a65b99 --- /dev/null +++ b/Code Samples/Fib/a.out.dSYM/Contents/Info.plist @@ -0,0 +1,20 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleIdentifier + com.apple.xcode.dsym.a.out + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + dSYM + CFBundleSignature + ???? + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/Code Samples/Fib/a.out.dSYM/Contents/Resources/DWARF/a.out b/Code Samples/Fib/a.out.dSYM/Contents/Resources/DWARF/a.out new file mode 100644 index 0000000000..77c0883f7d Binary files /dev/null and b/Code Samples/Fib/a.out.dSYM/Contents/Resources/DWARF/a.out differ diff --git a/Code Samples/Fib/a.out.dSYM/Contents/Resources/Relocations/aarch64/a.out.yml b/Code Samples/Fib/a.out.dSYM/Contents/Resources/Relocations/aarch64/a.out.yml new file mode 100644 index 0000000000..9c81f13df5 --- /dev/null +++ b/Code Samples/Fib/a.out.dSYM/Contents/Resources/Relocations/aarch64/a.out.yml @@ -0,0 +1,5 @@ +--- +triple: 'arm64-apple-darwin' +binary-path: a.out +relocations: [] +... diff --git a/Code Samples/Fib/main.cpp b/Code Samples/Fib/main.cpp index e7ab0c4c95..b605f85d2d 100644 --- a/Code Samples/Fib/main.cpp +++ b/Code Samples/Fib/main.cpp @@ -54,5 +54,5 @@ int main(int argc, char **argv) std::cout << "All threads exited!" << std::endl; - return 1; + return 0; } diff --git a/Code Samples/Fib/thread.cpp b/Code Samples/Fib/thread.cpp index bef34e9c78..84a4f2dfd9 100644 --- a/Code Samples/Fib/thread.cpp +++ b/Code Samples/Fib/thread.cpp @@ -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 @@ -45,4 +46,6 @@ void * thread_proc(void* ctx) } std::cout << thread_name << " exited!" << std::endl; -} \ No newline at end of file + + return nullptr; // ✅ fixed missing return +} diff --git a/Code Samples/Fib/thread.h b/Code Samples/Fib/thread.h index 6af19e6514..3b91456615 100644 --- a/Code Samples/Fib/thread.h +++ b/Code Samples/Fib/thread.h @@ -1 +1,6 @@ -void * thread_proc(void* ctx); +#ifndef THREAD_H +#define THREAD_H + +void* thread_proc(void* ctx); + +#endif // THREAD_H diff --git a/Extension/.vscode/launch.json b/Extension/.vscode/launch.json index 4323f133dd..1c11a78a05 100644 --- a/Extension/.vscode/launch.json +++ b/Extension/.vscode/launch.json @@ -1,143 +1,26 @@ -// A launch configuration that compiles the extension and then opens it inside a new window { - "version": "0.1.0", - "configurations": [ - { - // debugs the extension - "name": "Run Extension", - "type": "extensionHost", - "request": "launch", - "args": [ - "--no-sandbox", - "--disable-updates", - "--skip-welcome", - "--skip-release-notes", - "--disable-workspace-trust", - "--extensionDevelopmentPath=${workspaceFolder}", - ], - "sourceMaps": true, - "outFiles": [ - "${workspaceFolder}/dist/**" - ], - // you can use a watch task as a prelaunch task and it works like you'd want it to. - "preLaunchTask": "watch" - }, - { - // debugs the extension (selecting the workspace) - "name": "Run Extension-Select Workspace", - "type": "extensionHost", - "request": "launch", - "args": [ - "--no-sandbox", - "--disable-updates", - "--skip-welcome", - "--skip-release-notes", - "--disable-workspace-trust", - "--extensionDevelopmentPath=${workspaceFolder}", - "${input:pickWorkspace}" - ], - "sourceMaps": true, - "outFiles": [ - "${workspaceFolder}/dist/**" - ], - // you can use a watch task as a prelaunch task and it works like you'd want it to. - "preLaunchTask": "watch" - }, - { - // debug scenario tests (selecting the workspace) - "name": "VSCode Tests", - "type": "extensionHost", - "request": "launch", - "runtimeExecutable": "${execPath}", - "env": { - "SCENARIO": "${input:pickScenario}" - }, - "args": [ - "--no-sandbox", - "--disable-updates", - "--skip-welcome", - "--skip-release-notes", - "--disable-extensions", - "--extensionDevelopmentPath=${workspaceFolder}", - "--extensionTestsPath=${workspaceFolder}/dist/test/common/selectTests", - "--scenario=${input:pickScenario}", - "${input:pickScenario}" - ], - "sourceMaps": true, - "outFiles": [ - "${workspaceFolder}/dist/**" - ], - // you can use a watch task as a prelaunch task and it works like you'd want it to. - "preLaunchTask": "watch" - }, - { - // used for debugging unit tests - "name": "MochaTest", - "type": "node", - "request": "attach", - "port": 9229, - "continueOnAttach": true, - "autoAttachChildProcesses": false, - "skipFiles": [ - "/**" - ], - "outFiles": [ - "${workspaceFolder}/dist/**", - "!**/node_modules/**" - ] - } - ], - "inputs": [ - { - "type": "pickString", - "id": "pickScenario", - "description": "Select which scenario to debug VSCode tests.", - "options": [ - { - "label": "MultirootDeadlockTest ", - "value": "${workspaceFolder}/test/scenarios/MultirootDeadlockTest/assets/test.code-workspace" - }, - { - "label": "SimpleCppProject ", - "value": "${workspaceFolder}/test/scenarios/SimpleCppProject/assets/simpleCppProject.code-workspace" - }, - { - "label": "SingleRootProject ", - "value": "${workspaceFolder}/test/scenarios/SingleRootProject/assets/" - }, - { - "label": "CompilerDetection ", - "value": "${workspaceFolder}/test/scenarios/CompilerDetection/assets" - } - ] - }, - { - "type": "pickString", - "id": "pickWorkspace", - "description": "Select which workspace scenario to debug VSCode.", - "default": "-n", - "options": [ - { - "label": "(Debug with new window) ", - "value": "-n" - }, - { - "label": "MultirootDeadlockTest ", - "value": "${workspaceFolder}/test/scenarios/MultirootDeadlockTest/assets/test.code-workspace" - }, - { - "label": "SimpleCppProject ", - "value": "${workspaceFolder}/test/scenarios/SimpleCppProject/assets/simpleCppProject.code-workspace" - }, - { - "label": "SingleRootProject ", - "value": "${workspaceFolder}/test/scenarios/SingleRootProject/assets/" - }, - { - "label": "CompilerDetection ", - "value": "${workspaceFolder}/test/scenarios/CompilerDetection/assets" - } - ] - } - ] + "version": "0.2.0", + "configurations": [ + { + "name": "Debug", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/a.out", + "args": [], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": false, + "MIMode": "lldb" + }, + { + "name": "Attach to a.out", + "type": "cppdbg", + "request": "attach", + "program": "${workspaceFolder}/Code Samples/Fib/a.out", + "processId": "${command:pickProcess}", + "MIMode": "lldb", + "stopAtEntry": false + } + ] } diff --git a/Extension/src/Debugger/debugAdapterDescriptorFactory.ts b/Extension/src/Debugger/debugAdapterDescriptorFactory.ts index d43d71bc3c..51056dcbff 100644 --- a/Extension/src/Debugger/debugAdapterDescriptorFactory.ts +++ b/Extension/src/Debugger/debugAdapterDescriptorFactory.ts @@ -28,11 +28,13 @@ abstract class AbstractDebugAdapterDescriptorFactory implements vscode.DebugAdap export class CppdbgDebugAdapterDescriptorFactory extends AbstractDebugAdapterDescriptorFactory { async createDebugAdapterDescriptor(_session: vscode.DebugSession, _executable?: vscode.DebugAdapterExecutable): Promise { - 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']); } } @@ -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'] diff --git a/README.md b/README.md index f45d123a21..1d554bb2bc 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,19 @@ File questions, issues, or feature requests for the extension.
**[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. +
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.
@@ -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. \ No newline at end of file +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. + diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000000..c08a3dda95 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "vscode-cpptools", + "lockfileVersion": 3, + "requires": true, + "packages": {} +}