Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
trace.H File Reference

Simple RAII-based function tracing utility. More...

#include <stdio.h>
Include dependency graph for trace.H:

Go to the source code of this file.

Classes

class  Trace
 RAII helper for function entry/exit tracing. More...
 

Macros

#define TRACE(name)   Trace __trace__##__LINE__(__FILE__, __LINE__, name)
 Macro to create a Trace object with current file/line info.
 

Detailed Description

Simple RAII-based function tracing utility.

This file provides a lightweight mechanism for tracing function entry and exit points during debugging. It uses RAII to automatically print entry/exit messages without explicit logging calls.

Features

  • Automatic scope tracking: Entry logged on construction, exit on destruction
  • File and line information: Shows source location of trace point
  • Named traces: Custom names for identifying trace points
  • Zero configuration: Just include and use the macro

Usage Example

void myFunction() {
TRACE("myFunction"); // Prints: ****ENTER myFunction in file.cpp:123
// ... function body ...
} // Prints: ****LEAVE myFunction (on scope exit)
#define TRACE(name)
Macro to create a Trace object with current file/line info.
Definition trace.H:125

Output Format

****ENTER <name> in <file>:<line>
****LEAVE <name>

Implementation Notes

The TRACE macro creates a unique local variable using LINE to avoid naming conflicts when multiple TRACE calls appear in the same scope.

Note
Output goes to stdout via printf.
For production code, consider using a proper logging framework.
Author
Leandro Rabindranath León *

Definition in file trace.H.

Macro Definition Documentation

◆ TRACE

#define TRACE (   name)    Trace __trace__##__LINE__(__FILE__, __LINE__, name)

Macro to create a Trace object with current file/line info.

Parameters
nameString identifier for this trace point

Creates a uniquely-named Trace object that will print entry/exit messages for the current scope. *

Definition at line 125 of file trace.H.