- 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 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Kothuri
2024 年 9 月 13 日
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!
参考
カテゴリ
Help Center および File Exchange で Naming Conventions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!