BEEP-8 Helper Lib 1.0.0
Loading...
Searching...
No Matches
trace.h File Reference

Debug tracing macros for logging and monitoring program execution. More...

#include <tostr.h>

Go to the source code of this file.

Macros

#define PASS()
 Logs a simple passage message.
 
#define TRACE(x)
 Logs a trace message with a variable or expression.
 
#define WATCH(x)
 Logs a watch message with the name and value of a variable.
 

Detailed Description

Debug tracing macros for logging and monitoring program execution.

This header file provides macros for tracing and debugging purposes. The macros allow you to log function calls, variable values, and checkpoints in the code, which can help in diagnosing issues and understanding program flow.

The primary macros are:

  • PASS(): Logs a simple message indicating the passage of code execution through this point.
  • TRACE(x): Logs a message with the string representation of the variable or expression x.
  • WATCH(x): Logs a message with the name and string representation of the variable x.

Example usage:

void exampleFunction(int value) {
PASS(); // Logs the passage through this function
TRACE(value); // Logs the value of the variable `value`
int result = value * 2;
WATCH(result); // Logs the name and value of the variable `result`
}
#define TRACE(x)
Logs a trace message with a variable or expression.
Definition trace.h:47
#define WATCH(x)
Logs a watch message with the name and value of a variable.
Definition trace.h:58
#define PASS()
Logs a simple passage message.
Definition trace.h:36

Macro Definition Documentation

◆ PASS

#define PASS ( )
Value:
printf( "[PASS] %s(%d) %s()\n",__FILE__,__LINE__, __func__ );

Logs a simple passage message.

This macro logs a message indicating the passage of code execution through this point. It includes the file name, line number, and function name.

◆ TRACE

#define TRACE ( x)
Value:
printf( "[TRACE] %s(%d) %s() %s\n",__FILE__,__LINE__, __func__ , tostr((x)).c_str() );

Logs a trace message with a variable or expression.

This macro logs a message with the string representation of the variable or expression x. It includes the file name, line number, function name, and the value of x.

Parameters
xThe variable or expression to trace.

◆ WATCH

#define WATCH ( x)
Value:
printf( "[WATCH] %s(%d) %s() %s = %s\n",__FILE__,__LINE__, __func__ ,#x, tostr((x)).c_str() );

Logs a watch message with the name and value of a variable.

This macro logs a message with the name and string representation of the variable x. It includes the file name, line number, function name, the name of x, and its value.

Parameters
xThe variable to watch.