UI: MemPlumber: Use CppTrace

This commit is contained in:
Nodir Temirkhodjaev 2024-07-17 13:32:02 +05:00
parent feb9731fc5
commit 994bc43ee6

View File

@ -5,6 +5,10 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#ifdef USE_CPPTRACE
#include <cpptrace/cpptrace.hpp>
#endif
#ifndef MEMPLUMBER_FILENAME_LEN #ifndef MEMPLUMBER_FILENAME_LEN
#define MEMPLUMBER_FILENAME_LEN 100 #define MEMPLUMBER_FILENAME_LEN 100
#endif #endif
@ -355,6 +359,16 @@ class MemPlumberInternal {
// TODO: backtrace() is not supported on Windows. // TODO: backtrace() is not supported on Windows.
// We can use dbghelp but it's not supported on MinGW. Need to figure out a way to solve it on all platforms // We can use dbghelp but it's not supported on MinGW. Need to figure out a way to solve it on all platforms
const char* getCaller() { const char* getCaller() {
#ifdef USE_CPPTRACE
const auto objTrace = cpptrace::generate_object_trace(/*skip=*/3, /*max_depth=*/1);
const auto trace = objTrace.resolve();
const auto line = trace.to_string();
if (!line.empty()) {
return line.c_str();
}
#endif
return "Unknown"; return "Unknown";
} }
#else #else