Skip to content

Commit

Permalink
Merge branch 'development' into fix_interpface
Browse files Browse the repository at this point in the history
  • Loading branch information
asalmgren authored Aug 22, 2023
2 parents 632d503 + 0f59c07 commit 4106c9b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 22 deletions.
44 changes: 23 additions & 21 deletions Src/Base/AMReX_BLBackTrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ BLBackTrace::print_backtrace_info (FILE* f)
try_addr2line = true;
}
if (try_addr2line && amrex::system::call_addr2line && have_addr2line &&
!amrex::system::exename.empty() && stack_ptr_not_null)
!amrex::system::exename.empty())
{
addr2line_result.clear();
const std::string line = strings[i];
Expand All @@ -282,7 +282,7 @@ BLBackTrace::print_backtrace_info (FILE* f)
addr2line_result.clear();
}
}
if (addr2line_result.empty()) {
if (addr2line_result.empty() && stack_ptr_not_null) {
char print_buff[32];
std::snprintf(print_buff,sizeof(print_buff),"%p",bt_buffer[i]);
std::string full_cmd = cmd;
Expand All @@ -309,28 +309,30 @@ BLBackTrace::print_backtrace_info (FILE* f)

for (int i = 0; i < nentries; ++i) {
Dl_info info;
const bool stack_ptr_not_null = (bt_buffer[i] != nullptr);
if (dladdr(bt_buffer[i], &info))
if (bt_buffer[i] != nullptr)
{
std::string line;
if (amrex::system::call_addr2line && have_atos && stack_ptr_not_null) {
char print_buff[32];
std::snprintf(print_buff,sizeof(print_buff),"%p",bt_buffer[i]);
const std::string full_cmd = cmd + " " + print_buff;
line = run_command(full_cmd);
}
if (line.empty()) {
int status;
char * demangled_name = abi::__cxa_demangle(info.dli_sname, nullptr, 0, &status);
if (status == 0) {
line += demangled_name;
} else {
line += info.dli_fname;
if (dladdr(bt_buffer[i], &info))
{
std::string line;
if (amrex::system::call_addr2line && have_atos) {
char print_buff[32];
std::snprintf(print_buff,sizeof(print_buff),"%p",bt_buffer[i]);
const std::string full_cmd = cmd + " " + print_buff;
line = run_command(full_cmd);
}
if (line.empty()) {
int status;
char * demangled_name = abi::__cxa_demangle(info.dli_sname, nullptr, 0, &status);
if (status == 0) {
line += demangled_name;
} else {
line += info.dli_fname;
}
line += '\n';
std::free(demangled_name);
}
line += '\n';
std::free(demangled_name);
std::fprintf(f, "%2d: %s\n", i, line.c_str());
}
std::fprintf(f, "%2d: %s\n", i, line.c_str());
}
}

Expand Down
4 changes: 3 additions & 1 deletion Tools/GNUMake/comps/llvm.mak
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,7 @@ endif
endif

ifeq ($(FSANITIZER),TRUE)
override XTRALIBS += -lubsan
ifneq ($(shell uname),Darwin)
override XTRALIBS += -lubsan
endif
endif

0 comments on commit 4106c9b

Please sign in to comment.