Debugging C++ Code Imported - Error setting breakpoints

6 views (last 30 days)
Hello,
I'm trying to debug C++ code in a Simulink test. I've imported the code with "Code Importer" tool and generate the model in Library Browser. I've installed Matlab Coder Interface for Visual Studio Code Debugging too.
Finally, I've launched the simulation and some outputs are generated in this model (so it seems that is working fine).
The problem is that I want to debug the internal C++ code, set breakpoints and watch the internal variables, but I cant. When I select my model and "Set Breakpoints in Custom Code" the following error is showing up:
Error occurred when launching external debugger.
Caused by:
  • Call to service method "load" failed. Not enough input arguments.
Visual studio is oppened and I can see "Established connection with Matlab" but after this error, if "RUN" button is pressed in Simulink, Visual Studio Reports de Errors:
  • Execution of command "Attach" failed. Unable to attach debugger to application "${0}".
  • "Unable to attach debugger. Missing application, debugger and/or PID details."
Thank you in advance,
Juan

Answers (1)

Avadhoot
Avadhoot on 9 Nov 2023
Hi Adrian,
I understand that you have imported some code using the code importer tool and are facing an error trying to debug it in Visual Studio Code. I get that you have already confirmed that the model runs fine in Simulink and that you have also installed the MATLAB Coder Interface for debugging in Visual Studio.
The error you are facing could be due to a couple of reasons mentioned below:
1. Issue with MATLAB Coder interface:
The MATLAB Coder interface also requires the installation of some extensions in VSCode. Check whether you have fulfilled all the requirements mentioned in the installation instructions of MATLAB Coder interface.
Detailed information regarding this can be found at the following FileExchange link:
Verify that you have installed the C/C++ extension on VSCode and the appropriate compiler for your operating system.
2. Debugger Configuration:
This issue could be caused due to incorrect configuration of the debugger. Verify that you have configured the debugger correctly and that all the parameters are mentioned in the “launch.json” file in the “.vscode” folder of your project.
Ensure that the “program” field in “launch.jsoncontains the path to the executable and “processId” field contains the PID for the process. Usually the field is by default set to "${command:pickProcess}".
For more information on setting up the debugger in VSCode, refer the following documentation:
I hope this helps.

Categories

Find more on Dependency Analysis in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!