Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a debug utility header #14

Open
LevyMatan opened this issue Nov 29, 2022 · 0 comments
Open

Create a debug utility header #14

LevyMatan opened this issue Nov 29, 2022 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@LevyMatan
Copy link
Owner

Debug Utilities

Lets distinguish three cases of debug logs:

  • Development Debug: This is the most verbose debug log level. In development phase we usually want as much information as possible to follow. The informative logs should enable the developer follow the execution flow of the program with ease.
  • Maintenance Debug Mode: After a module/function is developed and tested, sometime there is a need to change/add/modify a dependency or change the code to allow new features. CI will run all tests made available by the developer, if a test fails, we would like to have some information to understand what is going on and help solve the bug.
  • Release Runtime Mode: Here we want to keep the debug information to the minimum. The debug information has its cost of memory and CPU clocks consumption, we would like to reduce it to be minimal.

Design Proposal

An header macros library with the three above level controlled by a preprocessor defines.
Development Debug we require build type to be Debug and define of an extra parameter
For example: cmake --build build --target all -D__DEV_DEBUG_ON__
Maintenance Debug Mode will be on in Debug mode.
Release Runtime Mode Will be without any debug info.

Debug Information

The debug information can be: Function start and End, function arguments values.
Flow indications in the programs.
Example:

void main()
{
    DEBUG_PRINT_FUNCTION_START()
    int x;
    printf("Dear user, please enter a number\n");
    scanf("%d", &x);

    if(x > GREEDY_THRESHOLD)
    {
        DEBUG_PRINT("Greedy user flow");
        greedy_user_function()
    }
    else
    {
        normal_flow()
    }
    DEBUG_PRINT_FUNCTION_END()
}

Embedded World

In the embedded business there is a need for neat debug mechanism.
Normally long and high bandwidth requiring logs are an issue.
We would like to be able to control the debug information without a huge impact on:

  • Memory consumption
  • Runtime execution performance
  • Correctability - need to have a separate (sometime it is duplicate) set of variables, never count on debug variable for program flow.

A great bonus is to be able to adjust the debug log levels at runtime!

@LevyMatan LevyMatan added the enhancement New feature or request label Nov 29, 2022
@LevyMatan LevyMatan self-assigned this Nov 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant