Main Content

Identify Function Call with Run-Time Error

This tutorial shows how to identify the function call that causes a run-time error in the function body.

If a function contains two different colors on the same operation for two different calls, the software combines the call contexts and displays an orange check on the operation. For example, when some function calls cause a red or orange check on an operation in the function body and other calls cause a green check, in your verification results, the operation is orange.

You have to distinguish orange checks that arise from combination of call contexts because an orange check can arise from other causes. Using the option Sensitivity context, make this distinction by storing individual call contexts for a function.

In this tutorial, a function is called twice. You identify which function call causes a run-time error in the function body.

  1. Run analysis on this code and open the results.

    void func(int arg) {
        int loc_var = 0;
        loc_var = 1/arg;  
    }
    
    void main(void) {
        int num = 1;
        func(num + 10);
        func(num - 1);
    }

    A red Non-terminating call check appears on the second call to func. In the body of func, there is an orange Division by zero check on the / operation.

  2. Specify that you want to store individual call context information for the function func.

    1. In your project configuration, navigate to the Static Analysis tab. Under Run Time Errors select Precision.

    2. Set Sensitivity context to custom.

    3. Add the function you want to store call context for. To do so, you can either:

      • Click Add function from predefined list button to add a new function from a predefined list. Select func from the list of functions on the left then add it to the table by clicking Button with arrow pointing right and OK.

      • Click Add empty row button to add a new row. Type func into the empty row.

  3. Run verification and open the results.

    This time, a dark orange Division by zero check appears in the body of func. In the Results List, this dark orange check is denoted by a Dark orange question mark icon mark. Instead of a red Non-terminating call check on the second call to func, a dashed, red line appears.

  4. Select the dark orange check in the Results List.

    The Result Details pane shows the calling context for the check. You can see that one call produces a red check on the / operation and the other call produces a green check. You can click each call to navigate to it in your source code.

    Polyspace results showing a dark orange check

See Also

|

Topics