mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-05 06:26:49 +00:00
split rpcs3 and hle libraries
merge rpcs3 utilities
This commit is contained in:
parent
b33e2662b6
commit
62ad27d1e2
1233 changed files with 7004 additions and 3819 deletions
46
rpcs3/util/stack_trace.h
Normal file
46
rpcs3/util/stack_trace.h
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
#pragma once
|
||||
#include <util/types.hpp>
|
||||
#include <util/logs.hpp>
|
||||
|
||||
namespace utils
|
||||
{
|
||||
namespace stack_trace
|
||||
{
|
||||
// Printing utilities
|
||||
|
||||
template <typename T>
|
||||
concept Logger = requires(T& t, const std::string& msg) {
|
||||
{ t.print(msg) };
|
||||
};
|
||||
|
||||
struct print_to_log
|
||||
{
|
||||
logs::channel& log;
|
||||
|
||||
public:
|
||||
print_to_log(logs::channel& chan)
|
||||
: log(chan)
|
||||
{
|
||||
}
|
||||
|
||||
void print(const std::string& s)
|
||||
{
|
||||
log.error("%s", s);
|
||||
}
|
||||
};
|
||||
} // namespace stack_trace
|
||||
|
||||
std::vector<void*> get_backtrace(int max_depth = 255);
|
||||
std::vector<std::string> get_backtrace_symbols(const std::vector<void*>& stack);
|
||||
|
||||
FORCE_INLINE void print_trace(stack_trace::Logger auto& logger, int max_depth = 255)
|
||||
{
|
||||
const auto trace = get_backtrace(max_depth);
|
||||
const auto lines = get_backtrace_symbols(trace);
|
||||
|
||||
for (const auto& line : lines)
|
||||
{
|
||||
logger.print(line);
|
||||
}
|
||||
}
|
||||
} // namespace utils
|
||||
Loading…
Add table
Add a link
Reference in a new issue