Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1495: check for libunwind errors
Browse files Browse the repository at this point in the history
cz4rs committed Feb 3, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 9bfc2fd commit a5508a2
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/vt/configs/error/stack_out.cc
Original file line number Diff line number Diff line change
@@ -43,6 +43,7 @@

#include "vt/configs/error/stack_out.h"

#include <fmt/core.h>
#define UNW_LOCAL_ONLY
#include <libunwind.h>
#include <cxxabi.h>
@@ -56,8 +57,12 @@ DumpStackType dumpStack(int skip) {
unw_context_t context;

// Initialize cursor to current frame for local unwinding.
unw_getcontext(&context);
unw_init_local(&cursor, &context);
if (unw_getcontext(&context) != 0) {
fmt::print("unw_getcontext failed");
}
if (unw_init_local(&cursor, &context) != 0) {
fmt::print("unw_init_local failed");
}

// Unwind frames one by one, going up the frame stack.
int i = 0;
@@ -67,7 +72,9 @@ DumpStackType dumpStack(int skip) {
}

unw_word_t offset, pc;
unw_get_reg(&cursor, UNW_REG_IP, &pc);
if (unw_get_reg(&cursor, UNW_REG_IP, &pc) != 0) {
fmt::print("unw_get_reg failed");
}
if (pc == 0) {
break;
}
@@ -89,7 +96,7 @@ DumpStackType dumpStack(int skip) {
std::free(demangled);
} else {
// FIXME!
std::printf(" -- error: unable to obtain symbol name for this frame\n");
fmt::print(" -- error: unable to obtain symbol name for this frame\n");
}
}
while (unw_step(&cursor) > 0);

0 comments on commit a5508a2

Please sign in to comment.