feat: log stacktrace implementation used (#1769)
This commit is contained in:
parent
b93fd523aa
commit
65dfd4da0f
@ -15,6 +15,11 @@ namespace hex::stacktrace {
|
||||
|
||||
void initialize();
|
||||
|
||||
std::vector<StackFrame> getStackTrace();
|
||||
struct StackTraceResult {
|
||||
std::vector<StackFrame> stackFrames;
|
||||
std::string implementationName;
|
||||
};
|
||||
|
||||
StackTraceResult getStackTrace();
|
||||
|
||||
}
|
@ -63,7 +63,9 @@ namespace hex::crash {
|
||||
}
|
||||
|
||||
static void printStackTrace() {
|
||||
for (const auto &stackFrame : stacktrace::getStackTrace()) {
|
||||
auto stackTraceResult = stacktrace::getStackTrace();
|
||||
log::fatal("Printing stacktrace using implementation '{}'", stackTraceResult.implementationName);
|
||||
for (const auto &stackFrame : stackTraceResult.stackFrames) {
|
||||
if (stackFrame.line == 0)
|
||||
log::fatal(" ({}) | {}", stackFrame.file, stackFrame.function);
|
||||
else
|
||||
|
@ -29,7 +29,7 @@ namespace {
|
||||
|
||||
}
|
||||
|
||||
std::vector<StackFrame> getStackTrace() {
|
||||
StackTraceResult getStackTrace() {
|
||||
std::vector<StackFrame> stackTrace;
|
||||
|
||||
HANDLE process = GetCurrentProcess();
|
||||
@ -100,7 +100,7 @@ namespace {
|
||||
|
||||
SymCleanup(process);
|
||||
|
||||
return stackTrace;
|
||||
return StackTraceResult{ stackTrace, "StackWalk" };
|
||||
}
|
||||
|
||||
}
|
||||
@ -119,7 +119,7 @@ namespace {
|
||||
|
||||
}
|
||||
|
||||
std::vector<StackFrame> getStackTrace() {
|
||||
StackTraceResult getStackTrace() {
|
||||
static std::vector<StackFrame> result;
|
||||
|
||||
std::array<void*, 128> addresses = {};
|
||||
@ -135,7 +135,7 @@ namespace {
|
||||
result.push_back(StackFrame { std::move(fileName), std::move(demangledName), 0 });
|
||||
}
|
||||
|
||||
return result;
|
||||
return StackTraceResult{ result, "execinfo" };
|
||||
}
|
||||
|
||||
}
|
||||
@ -162,7 +162,7 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<StackFrame> getStackTrace() {
|
||||
StackTraceResult getStackTrace() {
|
||||
static std::vector<StackFrame> result;
|
||||
|
||||
result.clear();
|
||||
@ -180,7 +180,7 @@ namespace {
|
||||
|
||||
}
|
||||
|
||||
return result;
|
||||
return StackTraceResult{ result, "backtrace" };
|
||||
}
|
||||
|
||||
}
|
||||
@ -192,8 +192,12 @@ namespace {
|
||||
namespace hex::stacktrace {
|
||||
|
||||
void initialize() { }
|
||||
std::vector<StackFrame> getStackTrace() { return { StackFrame { "??", "Stacktrace collecting not available!", 0 } }; }
|
||||
|
||||
StackTraceResult getStackTrace() {
|
||||
return StackTraceResult {
|
||||
{StackFrame { "??", "Stacktrace collecting not available!", 0 }},
|
||||
"none"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user