[ox/std] Cleanup stacktrace code
This commit is contained in:
parent
ceb876b6ae
commit
708d7382d8
6
deps/ox/src/ox/std/stacktrace.cpp
vendored
6
deps/ox/src/ox/std/stacktrace.cpp
vendored
@ -33,7 +33,7 @@ static Vector<String> symbolicate([[maybe_unused]]const char **frames, [[maybe_u
|
||||
Dl_info info;
|
||||
if (dladdr(frames[i], &info) && info.dli_sname) {
|
||||
int status = -1;
|
||||
const auto name = abi::__cxa_demangle(info.dli_sname, nullptr, 0, &status);
|
||||
const auto name = abi::__cxa_demangle(info.dli_sname, nullptr, nullptr, &status);
|
||||
if (status == 0) {
|
||||
out.emplace_back(sfmt("{}: {}", i, name));
|
||||
continue;
|
||||
@ -51,9 +51,9 @@ static Vector<String> symbolicate([[maybe_unused]]const char **frames, [[maybe_u
|
||||
void printStackTrace([[maybe_unused]]unsigned shave) noexcept {
|
||||
#if defined(OX_USE_STDLIB) && __has_include(<unistd.h>)
|
||||
Vector<void*> frames(1000);
|
||||
frames.resize(static_cast<std::size_t>(backtrace(frames.data(), frames.size())));
|
||||
frames.resize(static_cast<std::size_t>(backtrace(frames.data(), static_cast<int>(frames.size()))));
|
||||
if (frames.size() - shave > 2) {
|
||||
const auto symbols = backtrace_symbols(frames.data() + shave, frames.size() - shave);
|
||||
const auto symbols = backtrace_symbols(frames.data() + shave, static_cast<int>(frames.size() - shave));
|
||||
const auto symbolicatedStacktrace = symbolicate(bit_cast<const char**>(frames.data() + shave), frames.size() - shave, "\t");
|
||||
free(symbols);
|
||||
oxErr("Stacktrace:\n");
|
||||
|
Loading…
Reference in New Issue
Block a user