This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM2634-Q1: What's the function for DebugP_assert

Part Number: AM2634-Q1

Tool/software:

Hi experts,

Our DebugP_assert will judge if the input parameter is a reasonable value, if it not, it will jump into an infinite loop, So my customer ask this question:

1. Why DebugP_assert design to an infinite loop? They think if the input parameter greater than reasonable value, it can limit to the largest value, then code will not stuck in this loop.

2. Is DebugP_assert will change in the future?

BRs

Shuqing

  • Hi Shuqing,

    1. The DebugP_assert function is designed to identify incorrect parameters being passed to functions or values being returned from functions,  If expresion evaluates to 0 then the function disables interrupt and loops forever. While for some modules limiting the parameter values to largest/smallest can be a possible solution but overall this logic might not work for all the modules. In some cases the driver or Application functionality might break. The expectation from the user if DebugP_assert is hit is to fix the code. The user can modify the design based on their requirements (log some information, modify the invalid values, etc). Generally, the assert functions are meant to abort the code instead of fixing and continuing the execution of the program. The assert functions are more of a preventive "check" to avoid inconsistent behavior rather than "code correction" to avoid an inconsistency.

    2. Since this is a common DPL layer API used across SDKs, the behavior might not change in near future. I see two options here, Either the customer can have these checks enabled in the application for parameters being valid (if invalid, restrict their values to some minimum or maximum) then call the DebugP_assert checks, else modify the existing DebugP_assert() function in the implementation in source/kernel/dpl/DebugP.h and source/kernel/{OS}/common/DebugP_log.c files and rebuild the libraries. I would not recommend the latter as it might break other driver/module/application functionality.

    Regards,
    Shaunak