Debugging Strategies - MATLAB & Simulink (original) (raw)
Main Content
Before you perform code verification, choose a debugging strategy for detecting and correcting noncompliant code in your MATLAB® applications, especially if they consist of many MATLAB files that call each other's functions. The following table describes two general strategies, each of which has advantages and disadvantages.
Debugging Strategy | What to Do | Pros | Cons |
---|---|---|---|
Bottom-up verification | Verify that your lowest-level (leaf) functions are compliant.Work your way up the function hierarchy incrementally to compile and verify each function, ending with the top-level function. | EfficientUnlikely to cause errorsEasy to isolate code generation syntax violations | Requires application tests that work from the bottom up |
Top-down verification | Declare functions called by the top-level function to be extrinsic so thatMATLAB Coderâ„¢ does not compile them. See Use the coder.extrinsic Construct.Verify that your top-level function is compliant.Work your way down the function hierarchy incrementally by removing extrinsic declarations one by one to compile and verify each function, ending with the leaf functions. | You retain your top-level tests | Introduces extraneous code that you must remove after code verification, including:Extrinsic declarationsAdditional assignment statements as required to convert opaque values returned by extrinsic functions to nonopaque values (see Working with mxArrays). |