18 #ifdef MFEM_USE_LIBUNWIND
19 #define UNW_LOCAL_ONLY
20 #define UNW_NAME_LEN 512
21 #include <libunwind.h>
23 #if defined(__APPLE__) || defined(__linux__)
29 #endif // MFEM_USE_LIBUNWIND
40 #ifdef MFEM_USE_LIBUNWIND
41 char name[UNW_NAME_LEN];
46 int err = unw_getcontext(&uc);
47 err = err ? err : unw_init_local(&cursor, &uc);
50 while (unw_step(&cursor) > 0 && addrs.
Size() != depth)
52 err = err ? err : unw_get_proc_name(&cursor, name, UNW_NAME_LEN, &offp);
53 err = err ? err : unw_get_reg(&cursor, UNW_REG_IP, &ip);
60 abi::__cxa_demangle(name, NULL, NULL, &demangle_status);
61 if (demangle_status == 0)
63 name_p = name_demangle;
66 mfem::err << addrs.
Size() <<
") [0x" << std::hex << ip - 1 << std::dec
67 <<
"]: " << name_p << std::endl;
70 if (demangle_status == 0)
75 #if defined(__APPLE__) || defined(__linux__)
76 if (addrs.
Size() > 0 && (mode & 1))
78 mfem::err <<
"\nLookup backtrace source lines:";
79 const char *fname = NULL;
80 for (
int i = 0; i < addrs.
Size(); i++)
83 err = !dladdr((
void*)addrs[i], &info);
88 else if (fname != info.dli_fname)
90 fname = info.dli_fname;
95 mfem::err <<
"atos -o " << fname <<
" -l "
96 << (err ? 0 : info.dli_fbase);
99 mfem::err <<
" 0x" << std::hex << addrs[i] << std::dec;
104 #endif // MFEM_USE_LIBUNWIND
117 #ifdef MFEM_USE_LIBUNWIND
124 int init_flag, fin_flag;
125 MPI_Initialized(&init_flag);
126 MPI_Finalized(&fin_flag);
int Size() const
Logical size of the array.
void mfem_warning(const char *msg)
int Append(const T &el)
Append element to array, resize if necessary.
OutStream err(std::cerr)
Global stream used by the library for standard error output. Initially it uses the same std::streambu...
void mfem_error(const char *msg)
void mfem_backtrace(int mode, int depth)
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
MPI_Comm GetGlobalMPI_Comm()
Get MFEM's "global" MPI communicator.