MATLAB Coder Interface for Visual Studio Code Debugging
The MATLAB® Coder™ Interface for Visual Studio® Code™ Debugging support package allows you to use Visual Studio Code to view and debug C and C++ code. For example, code that you generate from MATLAB code and Simulink® models or code that you import from external libraries.
How to Install
You will need to install an extension in Visual Studio Code, by following the steps below:
- Download and install support package
- Open Visual Studio Code and navigate to the Extensions pane
- In the top right corner of the pane select "..." and "Install from VSIX..."
- Retrieve path of support package installation: matlabshared.supportpkg.getSupportPackageRoot()
- Navigate to the support package installation folder (from step 4) and select the VSIX file in "toolbox > targetframework > supportpackage > vscodedebug > extension > matlab-coder-interface-vscode-debugging.vsix"
Alternatively, if the code command is on your system path, you can install the extension by running this command in the MATLAB Command Window:
system("code --install-extension " + fullfile(matlabshared.supportpkg.getSupportPackageRoot(), "toolbox", "targetframework", "supportpackage", "vscodedebug", "extension", "matlab-coder-interface-vscode-debugging.vsix"))
The following workflows are supported with Visual Studio Code:
- Debug Generated Code During SIL Simulation (Simulink Coder™ and Embedded Coder®)
- Debug Generated Code During SIL Execution (MATLAB Coder)
- From R2022b, Debug Custom C/C++ Code (Simulink) using Simulate custom code in a separate process
How to Uninstall
To disable Visual Studio Code as debugger for the workflows listed above, uninstall this support package.
- Visual Studio Code version 1.59.0 or above
- Visual Studio Code command line (see documentation)
- C/C++ extension by Microsoft®
- For SIL debugging, MATLAB must be started from a terminal running a bash shell.
- Xcode® or Command Line Tools are in default locations (/Applications/Xcode.app or /Library/Developer/CommandLineTools).
- For SIL debugging, a version of MinGW® newer than 8.0 must also be installed. To configure the path to the newer GDB version, run the command: target.mingw.OverrideDebuggerPathForMinGWGDB.set(pathToGDB)
Compilers and Debuggers
- macOS®: Xcode & LLDB
- Linux: GCC & GDB
- Windows: MinGW GCC & MinGW GDB *
* MinGW needs to be installed separately. See MATLAB Support for MinGW-w64 C/C++ Compiler support package.
If you have download or installation problems, please contact Technical Support - www.mathworks.com/contact_ts
MATLAB Release Compatibility
Created with R2022a
Compatible with R2022a to R2022b
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!