Debug utilities for various data types and arrays. More...
#include <stdbool.h>#include <stdio.h>Macros | |
| #define | DBG_OUTSTREAM stderr |
| Macro for the debug output stream. | |
| #define | SOURCE_PATH_SIZE 0 |
| Macro to truncate the root file path. | |
| #define | __FILENAME__ ((__FILE__) + (SOURCE_PATH_SIZE)) |
| Macro to adjust the file path based on SOURCE_PATH_SIZE. | |
| #define | dbg(value) |
| Macro to print a debug message for a variable. | |
| #define | dbg_array(value, length) |
| Macro to print a debug message for an array. | |
| #define | CALL_DBG(dbg_func_name, value) |
| Macro to call a debug function for a variable. | |
| #define | CALL_DBG_ARRAY(dbg_func_name, value, length) |
| Macro to call a debug function for an array. | |
| #define | RESET "\033[0m" |
| #define | DBG_FUNC_DECL(type, name, fmt) |
| Macro to declare a debug function for a variable. | |
| #define | DBG_ARRAY_FUNC_DECL(type, name, fmt) |
| Macro to declare a debug function for an array. | |
Functions | |
| void | set_breakpoint (void) |
| Function to set a breakpoint for debugging. | |
Debug utilities for various data types and arrays.
This header provides macros and functions to facilitate debugging by printing values of various data types and arrays, along with their expressions, file names, line numbers, and function names. The dbg() macro aims to be similar to the rust dbg!() one.
Usage example:
| #define __FILENAME__ ((__FILE__) + (SOURCE_PATH_SIZE)) |
Macro to adjust the file path based on SOURCE_PATH_SIZE.
This macro modifies the __FILE__ macro to remove a specified number of characters from the beginning, making the logged file paths more readable.
| #define CALL_DBG | ( | dbg_func_name, | |
| value ) |
Macro to call a debug function for a variable.
This macro calls a debug function for the specified variable.
| dbg_func_name | The name of the debug function. |
| value | The variable to debug. |
Example usage:
| #define CALL_DBG_ARRAY | ( | dbg_func_name, | |
| value, | |||
| length ) |
Macro to call a debug function for an array.
This macro calls a debug function for the specified array.
| dbg_func_name | The name of the debug function. |
| value | The array to debug. |
| length | The length of the array. |
Example usage:
| #define dbg | ( | value | ) |
Macro to print a debug message for a variable.
This macro prints a debug message for the specified variable, including its name and value. It aims to be the same as the rust dbg!() macro.
| value | The variable to debug. |
Example usage:
| #define dbg_array | ( | value, | |
| length ) |
Macro to print a debug message for an array.
This macro prints a debug message for the specified array, including its name and elements. It aims to be the same as the rust dbg!() macro but for arrays.
| value | The array to debug. |
| length | The length of the array. |
Example usage:
| #define DBG_ARRAY_FUNC_DECL | ( | type, | |
| name, | |||
| fmt ) |
Macro to declare a debug function for an array.
This macro declares a debug function for the specified array type.
| type | The type of the array elements. |
| name | The name of the debug function. |
| fmt | The format string for the array elements. |
Example usage:
| #define DBG_FUNC_DECL | ( | type, | |
| name, | |||
| fmt ) |
Macro to declare a debug function for a variable.
This macro declares a debug function for the specified variable type.
| type | The type of the variable. |
| name | The name of the debug function. |
| fmt | The format string for the variable value. |
Example usage:
| #define DBG_OUTSTREAM stderr |
Macro for the debug output stream.
This macro allow you to set the debuf output stream as you want (file/stdio/stderr). By default, if undefined, it is an alias of the stderr standard stream.
| #define RESET "\033[0m" |
| #define SOURCE_PATH_SIZE 0 |
Macro to truncate the root file path.
This macro is useful when the project is compiled with CMake, allowing for a cleaner file path in logs by removing a fixed number of characters from the start of the __FILE__ macro. The default value if the macro wasn't defined earlier is 0.
| void set_breakpoint | ( | void | ) |
Function to set a breakpoint for debugging.
This function raises a SIGTRAP signal, which causes the program to stop and enter a state where a debugger can be attached. It is useful for setting breakpoints in code.