libMesh
Loading...
Searching...
No Matches
Functions | Variables
libMesh::MacroFunctions Namespace Reference

Functions

void here (const char *file, int line, const char *date, const char *time, std::ostream &os=libMesh::err)
 
void stop (const char *file, int line, const char *date, const char *time)
 
void report_error (const char *file, int line, const char *date, const char *time, std::ostream &os=libMesh::err)
 

Variables

Threads::spin_mutex report_error_spin_mtx
 

Function Documentation

◆ here()

void libMesh::MacroFunctions::here ( const char *  file,
int  line,
const char *  date,
const char *  time,
std::ostream &  os = libMesh::err 
)

Definition at line 47 of file libmesh_common.C.

48{
49 os << "[" << static_cast<std::size_t>(libMesh::global_processor_id()) << "] "
50 << file
51 << ", line " << line
52 << ", compiled " << date
53 << " at " << time
54 << std::endl;
55}
processor_id_type global_processor_id()

References libMesh::global_processor_id().

Referenced by report_error(), and stop().

◆ report_error()

void libMesh::MacroFunctions::report_error ( const char *  file,
int  line,
const char *  date,
const char *  time,
std::ostream &  os = libMesh::err 
)

Definition at line 77 of file libmesh_common.C.

78{
79 // Avoid a race condition on that static bool
80 Threads::spin_mutex::scoped_lock lock(report_error_spin_mtx);
81
82 // It is possible to have an error *inside* report_error; e.g. from
83 // print_trace. We don't want to infinitely recurse.
84 static bool reporting_error = false;
85 if (reporting_error)
86 {
87 // I heard you like error reporting, so we put an error report
88 // in report_error() so you can report errors from the report.
89 os << "libMesh encountered an error while attempting to report_error." << std::endl;
90 return;
91 }
92 reporting_error = true;
93
94 libMesh::MacroFunctions::here(file, line, date, time, os);
95
97 libMesh::on_command_line("--print-trace"))
99 else
101
102 reporting_error = false;
103}
void here(const char *file, int line, const char *date, const char *time, std::ostream &os=libMesh::err)
void write_traceout()
Writes a stack trace to a uniquely named file if –enable-tracefiles has been set by configure,...
processor_id_type global_n_processors()
void print_trace(std::ostream &out_stream=std::cerr)
Print a stack trace (for code compiled with gcc)
bool on_command_line(std::string arg)
Definition libmesh.C:934

References libMesh::global_n_processors(), here(), libMesh::on_command_line(), libMesh::print_trace(), report_error_spin_mtx, and libMesh::write_traceout().

◆ stop()

void libMesh::MacroFunctions::stop ( const char *  file,
int  line,
const char *  date,
const char *  time 
)

Definition at line 59 of file libmesh_common.C.

60{
62 {
63 libMesh::MacroFunctions::here(file, line, date, time);
64#if defined(LIBMESH_HAVE_CSIGNAL) && defined(SIGSTOP)
65 libMesh::out << "Stopping process " << getpid() << "..." << std::endl;
66 std::raise(SIGSTOP);
67 libMesh::out << "Continuing process " << getpid() << "..." << std::endl;
68#else
69 libMesh::out << "WARNING: libmesh_stop() does not work; no operating system support." << std::endl;
70#endif
71 }
72}
OStreamProxy out

References libMesh::global_n_processors(), here(), and libMesh::out.

Variable Documentation

◆ report_error_spin_mtx

Threads::spin_mutex libMesh::MacroFunctions::report_error_spin_mtx

Definition at line 75 of file libmesh_common.C.

Referenced by report_error().