27#ifdef DEAL_II_WITH_MPI
31#ifdef DEAL_II_TRILINOS_WITH_SEACAS
35#ifdef DEAL_II_HAVE_GLIBC_STACKTRACE
39#ifdef DEAL_II_HAVE_LIBSTDCXX_DEMANGLER
53 static std::string additional_assert_output;
54 return additional_assert_output;
103 , n_stacktrace_frames(0)
106#ifdef DEAL_II_HAVE_GLIBC_STACKTRACE
116 , function(exc.function)
119 , n_stacktrace_frames(exc.n_stacktrace_frames)
123#ifdef DEAL_II_HAVE_GLIBC_STACKTRACE
127 std::copy(std::begin(
exc.raw_stacktrace),
128 std::end(
exc.raw_stacktrace),
153#ifdef DEAL_II_HAVE_GLIBC_STACKTRACE
184 out <<
"An error occurred in line <" <<
line <<
"> of file <" <<
file
185 <<
"> in function" << std::endl
187 <<
"The violated condition was: " << std::endl
188 <<
" " <<
cond << std::endl;
202 if (std::strstr(
cond,
"::ExcMessage") !=
nullptr)
203 out <<
"The name and call sequence of the exception was:" << std::endl
204 <<
" " <<
exc << std::endl;
207 out <<
"Additional information: " << std::endl;
215 out <<
" (none)" << std::endl;
229 char **stacktrace =
nullptr;
230#ifdef DEAL_II_HAVE_GLIBC_STACKTRACE
240 out <<
"Stacktrace:" << std::endl <<
"-----------" << std::endl;
248 ((std::string(stacktrace[frame]).find(
"ExceptionBase") !=
249 std::string::npos) ||
250 (std::string(stacktrace[frame]).find(
"deal_II_exceptions") !=
255 const unsigned int first_significant_frame = frame;
258 out <<
'#' << frame - first_significant_frame <<
" ";
263 std::string stacktrace_entry(stacktrace[frame]);
264 const unsigned int pos_start = stacktrace_entry.find(
'('),
265 pos_end = stacktrace_entry.find(
'+');
266 std::string functionname =
267 stacktrace_entry.substr(pos_start + 1, pos_end - pos_start - 1);
269 stacktrace_entry = stacktrace_entry.substr(0, pos_start);
270 stacktrace_entry +=
": ";
276#ifdef DEAL_II_HAVE_LIBSTDCXX_DEMANGLER
279 abi::__cxa_demangle(functionname.c_str(),
nullptr,
nullptr, &status);
281 if ((status == 0) && (functionname !=
"main"))
283 std::string realname(p);
290 while (realname.find(
", boost::tuples::null_type>") !=
292 realname.erase(realname.find(
", boost::tuples::null_type>"),
293 std::string(
", boost::tuples::null_type").size());
295 stacktrace_entry += realname;
298 stacktrace_entry += functionname;
304 stacktrace_entry += functionname;
308 out << stacktrace_entry << std::endl;
311 if (functionname ==
"main")
316 stacktrace =
nullptr;
329 std::ostringstream converter;
331 converter << std::endl
332 <<
"--------------------------------------------------------"
342 std::ostringstream message;
345 const auto message_in_lines =
349 for (
const auto &
line : message_in_lines)
350 converter <<
" " <<
line <<
'\n';
360 <<
"--------------------------------------------------------"
366 converter <<
"--------------------------------------------------------"
374 what_str =
"ExceptionBase::generate_message () failed";
382#ifdef DEAL_II_WITH_MPI
384 : error_code(error_code)
390 char error_name[MPI_MAX_ERROR_STRING];
391 error_name[0] =
'\0';
392 int resulting_length = MPI_MAX_ERROR_STRING;
394 bool error_name_known =
false;
402 int ierr = MPI_Error_class(
error_code, &error_class);
403 error_name_known = (ierr == MPI_SUCCESS);
407 if (error_name_known)
409 ierr = MPI_Error_string(error_class, error_name, &resulting_length);
410 error_name_known = error_name_known && (ierr == MPI_SUCCESS);
414 out <<
"deal.II encountered an error while calling an MPI function."
416 if (error_name_known)
418 out <<
"The description of the error provided by MPI is \""
419 << error_name <<
"\"." << std::endl;
424 <<
"This error code is not equal to any of the standard MPI error codes."
427 out <<
"The numerical value of the original error code is " <<
error_code
434#ifdef DEAL_II_TRILINOS_WITH_SEACAS
435 ExcExodusII::ExcExodusII(
const int error_code)
436 : error_code(error_code)
440 static_assert(EX_NOERR == 0,
441 "EX_NOERR is assumed to be zero in all versions of ExodusII");
447 ExcExodusII::print_info(std::ostream &out)
const
449 out <<
"Error code is " << error_code <<
'\n';
450 out <<
"String description: " << ex_strerror(error_code) <<
'\n';
463 std::cerr << exc.what() << std::endl;
477#ifdef DEAL_II_WITH_MPI
479 MPI_Initialized(&is_initialized);
480 if (is_initialized != 0)
488 <<
"Calling MPI_Abort now.\n"
489 <<
"To break execution in a GDB session, execute 'break MPI_Abort' before "
490 <<
"running. You can also put the following into your ~/.gdbinit:\n"
491 <<
" set breakpoint pending on\n"
492 <<
" break MPI_Abort\n"
493 <<
" set breakpoint pending auto" << std::endl;
495 MPI_Abort(MPI_COMM_WORLD,
514 deallog <<
"Exception: " << exc.get_exc_name() << std::endl;
515 deallog << exc.what() << std::endl;
521#ifdef DEAL_II_WITH_CUDA
527 case CUSPARSE_STATUS_NOT_INITIALIZED:
529 return "The cuSPARSE library was not initialized";
531 case CUSPARSE_STATUS_ALLOC_FAILED:
533 return "Resource allocation failed inside the cuSPARSE library";
535 case CUSPARSE_STATUS_INVALID_VALUE:
537 return "An unsupported value of parameter was passed to the function";
539 case CUSPARSE_STATUS_ARCH_MISMATCH:
541 return "The function requires a feature absent from the device architecture";
543 case CUSPARSE_STATUS_MAPPING_ERROR:
545 return "An access to GPU memory space failed";
547 case CUSPARSE_STATUS_EXECUTION_FAILED:
549 return "The GPU program failed to execute";
551 case CUSPARSE_STATUS_INTERNAL_ERROR:
553 return "An internal cuSPARSE operation failed";
555 case CUSPARSE_STATUS_MATRIX_TYPE_NOT_SUPPORTED:
557 return "The matrix type is not supported by this function";
561 return "Unknown error";
574 case CUSOLVER_STATUS_NOT_INITIALIZED:
576 return "The cuSolver library was not initialized";
578 case CUSOLVER_STATUS_ALLOC_FAILED:
580 return "Resource allocation failed inside the cuSolver library";
582 case CUSOLVER_STATUS_INVALID_VALUE:
584 return "An unsupported value of a parameter was passed to the function";
586 case CUSOLVER_STATUS_ARCH_MISMATCH:
588 return "The function requires a feature absent from the device architecture";
590 case CUSOLVER_STATUS_EXECUTION_FAILED:
592 return "The GPU program failed to execute";
594 case CUSOLVER_STATUS_INTERNAL_ERROR:
596 return "An internal cuSolver operation failed";
598 case CUSOLVER_STATUS_MATRIX_TYPE_NOT_SUPPORTED:
600 return "The matrix type is not supported by this function";
604 return "Unknown error";
void generate_message() const
void print_stack_trace(std::ostream &out) const
const char * get_exc_name() const
void set_fields(const char *file, const int line, const char *function, const char *cond, const char *exc_name)
virtual void print_info(std::ostream &out) const
virtual const char * what() const noexcept override
void print_exc_data(std::ostream &out) const
void * raw_stacktrace[25]
virtual void print_info(std::ostream &out) const override
ExcMPI(const int error_code)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
unsigned int n_mpi_processes(const MPI_Comm &mpi_communicator)
std::vector< std::string > break_text_into_lines(const std::string &original_text, const unsigned int width, const char delimiter=' ')
std::string get_cusolver_error_string(const cusolverStatus_t error_code)
std::string get_cusparse_error_string(const cusparseStatus_t error_code)
void abort(const ExceptionBase &exc) noexcept
std::string & get_additional_assert_output()
void do_issue_error_nothrow(const ExceptionBase &e) noexcept
bool allow_abort_on_exception
void enable_abort_on_exception()
void disable_abort_on_exception()
void set_additional_assert_output(const char *const p)
void suppress_stacktrace_in_exceptions()