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, select the Precision node.

    2. Select custom for Sensitivity context.

    3. Click to add a new field. Enter func.

  3. Run verification and open the results.

    An orange Division by zero check still appears in the body of func. However, this orange check is marked on the Results List pane as a dark orange check and is denoted by a mark. Instead of a red Non-terminating call check, a dashed, red line appears on the second call to func.

  4. Select the orange check.

    The Result Details pane shows the call contexts 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.

See Also

Related Examples

More About