2022-08-14 00:36:53 +00:00
|
|
|
#pragma once
|
|
|
|
#include <util/types.hpp>
|
|
|
|
#include <util/logs.hpp>
|
|
|
|
|
|
|
|
namespace utils
|
|
|
|
{
|
2022-08-14 17:25:52 +00:00
|
|
|
std::vector<void*> get_backtrace(int max_depth = 255);
|
|
|
|
std::vector<std::string> get_backtrace_symbols(const std::vector<void*>& stack);
|
2022-08-14 00:36:53 +00:00
|
|
|
|
|
|
|
FORCE_INLINE void print_trace(logs::channel& logger, int max_depth = 255)
|
|
|
|
{
|
2022-08-14 17:25:52 +00:00
|
|
|
const auto trace = get_backtrace(max_depth);
|
|
|
|
const auto lines = get_backtrace_symbols(trace);
|
2022-08-14 00:36:53 +00:00
|
|
|
|
|
|
|
for (const auto& line : lines)
|
|
|
|
{
|
|
|
|
logger.error("%s", line);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|