mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-02 13:01:27 +12:00
util: Provide stack-trace utilities
This commit is contained in:
parent
b960ce1426
commit
1244044647
5 changed files with 174 additions and 2 deletions
20
Utilities/stack_trace.h
Normal file
20
Utilities/stack_trace.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
#pragma once
|
||||
#include <util/types.hpp>
|
||||
#include <util/logs.hpp>
|
||||
|
||||
namespace utils
|
||||
{
|
||||
std::vector<void*> backtrace(int max_depth = 255);
|
||||
std::vector<std::string> backtrace_symbols(const std::vector<void*>& stack);
|
||||
|
||||
FORCE_INLINE void print_trace(logs::channel& logger, int max_depth = 255)
|
||||
{
|
||||
const auto trace = backtrace(max_depth);
|
||||
const auto lines = backtrace_symbols(trace);
|
||||
|
||||
for (const auto& line : lines)
|
||||
{
|
||||
logger.error("%s", line);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue