- Ensure all necessary components for C/C++ development are installed in Visual Studio.
- Make sure that Visual Studio is correctly set up as the compiler in MATLAB. You can do this by running “mex -setup” in MATLAB and selecting Visual Studio.
- Attach Debugger Manually: If the automatic attachment is not working, you can manually attach the debugger to the MATLAB process: Open Visual Studio -> Go to Debug -> Attach to Process. -> Select the MATLAB process (matlab.exe) from the list and click Attach.
- Once attached, open your C source file in Visual Studio and set breakpoints manually. Sometimes, breakpoints might not be hit if the code is optimized away or if the exact execution path doesn't include the breakpoint.
- Ensure that the module containing your C code is loaded. You can check this in the Modules window in Visual Studio (Debug -> Windows -> Modules).
- Enable verbose logging in Simulink to get more detailed information about the simulation and any issues that arise.
- You can also use the Simulink debugger to step through your model and check if the custom code is being called correctly. In Simulink, go to Debug -> Simulink Debugger.
Simulink Debug brings up two Visual studio sessions
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I ran into issues when trying to debug c caller code in simulink. environment: Matlab 2022a, Visual Studio Community 2019.
When Debug-> Add Breakpoint -> set breakpoint in custom code , two sessions of Visual Studio were brough up. The code I was debugging did not show in the module view in one of the sessions, so the breakpoint did not work. The other session has the module loaded , but looks like the thread was not attached to the actual simulation ( even though it showed as attached. )
Update: I tried uncheck Simulate custom code in a separate process. This time, Simulink brought up one session without the module loaded .
Anybody has a solution or suggestion ?
0 comentarios
Respuestas (1)
Kothuri
el 13 de Sept. de 2024
I understand that you are facing an issue while trying to debug C caller code in Simulink.
You can try the below steps to resolve the issue
You can refer the below documentation link for more info:
Hope this helps!
Ver también
Categorías
Más información sobre Naming Conventions en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!