added a way to show the call stack of the functions

This commit is contained in:
Karma Riuk
2025-07-11 19:48:55 +02:00
parent c9ffeafd5f
commit 6cd99c22fe
3 changed files with 35 additions and 0 deletions

22
src/utils/tracer.hpp Normal file
View File

@@ -0,0 +1,22 @@
#include <iostream>
#include <string>
namespace {
struct FunctionTracer {
std::string name;
inline static int tab_counter = 0;
FunctionTracer(const std::string& func): name(func) {
std::cout << std::string(tab_counter++, '\t') << "BEGIN " << name
<< std::endl;
}
~FunctionTracer() {
std::cout << std::string(--tab_counter, '\t') << "Exiting " << name
<< std::endl;
}
};
} // namespace
#define TRACE_FUNCTION FunctionTracer tracer(__FUNCTION__);