Block-Structured AMR Software Framework
AMReX_BLBackTrace.H
Go to the documentation of this file.
1 #ifndef AMREX_BL_BACKTRACE_H_
2 #define AMREX_BL_BACKTRACE_H_
3 #include <AMReX_Config.H>
4 
5 #ifdef AMREX_USE_OMP
6 #include <omp.h>
7 #endif
8 
9 #include <stack>
10 #include <string>
11 #include <utility>
12 #include <cstdlib>
13 
14 #define BL_PASTE2(x, y) x##y
15 #define BL_PASTE(x, y) BL_PASTE2(x, y)
16 #define BL_BACKTRACE_PUSH( S ) amrex::BLBTer BL_PASTE( bl_bter, __COUNTER__ )( S, __FILE__, __LINE__ )
17 #define BL_BACKTRACE_POP() amrex::BLBackTrace::bt_stack.pop()
18 
19 namespace amrex {
20 
22 {
23  static void handler(int s);
25  static void print_backtrace_info (FILE* f);
27  static void print_backtrace_info (const std::string& filename);
28 
29  static std::stack<std::pair<std::string, std::string> > bt_stack;
30 // threadprivate here doesn't work with Cray, Intel, and Fujitsu
31 #if defined(AMREX_USE_OMP) && !defined(_CRAYC) && !defined(__INTEL_COMPILER) && !defined(__PGI) && !defined(__NVCOMPILER) && !defined(__FUJITSU)
32 #pragma omp threadprivate(bt_stack)
33 #endif
34 };
35 
36 class BLBTer
37 {
38 public:
39  BLBTer(const std::string& s, const char* file, int line);
40  BLBTer (BLBTer const&) = delete;
41  BLBTer (BLBTer &&) = delete;
42  BLBTer& operator= (BLBTer const&) = delete;
43  BLBTer& operator= (BLBTer &&) = delete;
44  ~BLBTer();
45 private:
46  std::string line_file;
47  void pop_bt_stack();
48 };
49 
50 }
51 
52 #endif
Definition: AMReX_BLBackTrace.H:37
std::string line_file
Definition: AMReX_BLBackTrace.H:46
~BLBTer()
Definition: AMReX_BLBackTrace.cpp:405
BLBTer & operator=(BLBTer const &)=delete
BLBTer(BLBTer const &)=delete
void pop_bt_stack()
Definition: AMReX_BLBackTrace.cpp:423
BLBTer(const std::string &s, const char *file, int line)
Definition: AMReX_BLBackTrace.cpp:373
BLBTer(BLBTer &&)=delete
static int f(amrex::Real t, N_Vector y_data, N_Vector y_rhs, void *user_data)
Definition: AMReX_SundialsIntegrator.H:44
Definition: AMReX_Amr.cpp:49
Definition: AMReX_BLBackTrace.H:22
static void handler(int s)
Definition: AMReX_BLBackTrace.cpp:48
static void print_backtrace_info(FILE *f)
Abort backtrace. Used automatically.
Definition: AMReX_BLBackTrace.cpp:197
static std::stack< std::pair< std::string, std::string > > bt_stack
Definition: AMReX_BLBackTrace.H:29