Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
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
14#include <stack>
15#include <string>
16#include <utility>
17#include <cstdlib>
18
20#define BL_PASTE2(x, y) x##y
21#define BL_PASTE(x, y) BL_PASTE2(x, y)
23
32#define BL_BACKTRACE_PUSH( S ) amrex::BLBTer BL_PASTE( bl_bter, __COUNTER__ )( S, __FILE__, __LINE__ )
40#define BL_BACKTRACE_POP() amrex::BLBackTrace::bt_stack.pop()
41
42namespace amrex {
43
45{
50 static void handler(int s);
55 static void print_backtrace_info (FILE* f);
60 static void print_backtrace_info (const std::string& filename);
61
62 static std::stack<std::pair<std::string, std::string> > bt_stack;
63// threadprivate here doesn't work with Cray, Intel, and Fujitsu
64#if defined(AMREX_USE_OMP) && !defined(_CRAYC) && !defined(__INTEL_COMPILER) && !defined(__PGI) && !defined(__NVCOMPILER) && !defined(__FUJITSU)
65#pragma omp threadprivate(bt_stack)
66#endif
67};
68
69class BLBTer
70{
71public:
79 BLBTer(const std::string& s, const char* file, int line);
80 BLBTer (BLBTer const&) = delete;
81 BLBTer (BLBTer &&) = delete;
82 BLBTer& operator= (BLBTer const&) = delete;
83 BLBTer& operator= (BLBTer &&) = delete;
84 ~BLBTer();
85private:
86 std::string line_file;
93 void pop_bt_stack();
94};
95
96}
97
98#endif
Definition AMReX_BLBackTrace.H:70
~BLBTer()
Definition AMReX_BLBackTrace.cpp:407
BLBTer & operator=(BLBTer const &)=delete
BLBTer(BLBTer const &)=delete
BLBTer(BLBTer &&)=delete
Definition AMReX_Amr.cpp:50
Definition AMReX_BLBackTrace.H:45
static void handler(int s)
Signal handler that prints and aborts on fatal signals.
Definition AMReX_BLBackTrace.cpp:50
static void print_backtrace_info(FILE *f)
Print backtrace details to f for abort handling.
Definition AMReX_BLBackTrace.cpp:199
static std::stack< std::pair< std::string, std::string > > bt_stack
Definition AMReX_BLBackTrace.H:62