Debug Generated Code During SIL Execution
If a SIL execution fails or you notice differences between the outputs of your original functions and the generated code, you can rerun the SIL execution with a debugger enabled. By inserting breakpoints, you can observe the behavior of code sections, which might help you to understand the cause of the problem.
For a SIL execution failure, you can also view information from the standard output and standard error streams in the MATLAB® Command Window. For example:
printfstatements in your code.
If you enable run-time error detection, messages sent to
Some low-level system messages.
During a SIL execution, the SIL application redirects the
When the application terminates, the MATLAB Command Window displays
the information from the redirected streams. The SIL application also
provides a basic signal handler, which captures the POSIX® signals
SIGSEV. For this signal handler, the SIL application
includes the file
A SIL execution supports the following debuggers:
On Windows®, Microsoft® Visual Studio® debugger.
On macOS, LLDB Debugger (LLDB).
On Linux®, GNU® Data Display Debugger (DDD).
You can perform SIL debugging only if the MATLAB product family supports your Microsoft Visual C++®, Xcode, or GNU GCC compiler. For more information, see supported compilers.
To run a SIL execution with debugging enabled:
On the Generate Code page, click Verify Code.
Select the Enable source-level debugging for SIL check box.
Click Run Generated Code.
On a Windows computer, your
opens in the Microsoft
Visual Studio IDE with debugger breakpoints
at the start of the
You can now use the debugger features to observe code behavior. For example, you can step through code and examine variables.
To end the debugging session:
Remove all breakpoints.
Click the Continue button (F5).
The SIL execution runs to completion.
To terminate the SIL execution process, on the Test Output tab, click the link that follows
To terminate execution, for example,
The Microsoft Visual Studio IDE closes automatically.
If you select Debug > Stop Debugging, the SIL execution times out with the following error message:
Communications error: failed to send data to the target. There might be multiple reasons for this failure. ... ...