libMesh
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.

References libMesh::global_processor_id().

Referenced by report_error(), and stop().

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()
Definition: libmesh_base.h:85

◆ 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.

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

Referenced by libMesh::TriangulatorInterface::MeshedHole::MeshedHole().

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  if (libMesh::global_n_processors() == 1 ||
95  libMesh::on_command_line("--print-trace"))
97  else
99  libMesh::MacroFunctions::here(file, line, date, time, os);
100 
101  reporting_error = false;
102 }
processor_id_type global_n_processors()
Definition: libmesh_base.h:75
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...
Definition: print_trace.C:240
Threads::spin_mutex report_error_spin_mtx
void print_trace(std::ostream &out_stream=std::cerr)
Print a stack trace (for code compiled with gcc)
Definition: print_trace.C:202
bool on_command_line(std::string arg)
Definition: libmesh.C:987

◆ 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.

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

Referenced by libMesh::PetscMatrixBase< Number >::col_start(), libMesh::PetscMatrixBase< Number >::col_stop(), libMesh::PetscMatrixBase< Number >::row_start(), and libMesh::PetscMatrixBase< Number >::row_stop().

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 }
processor_id_type global_n_processors()
Definition: libmesh_base.h:75
void here(const char *file, int line, const char *date, const char *time, std::ostream &os=libMesh::err)
OStreamProxy 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().