26#ifdef DEAL_II_WITH_MPI
30#ifdef DEAL_II_TRILINOS_WITH_SEACAS
34#ifdef DEAL_II_HAVE_GLIBC_STACKTRACE
38#ifdef DEAL_II_HAVE_LIBSTDCXX_DEMANGLER
52 static std::string additional_assert_output;
53 return additional_assert_output;
102 , n_stacktrace_frames(0)
105#ifdef DEAL_II_HAVE_GLIBC_STACKTRACE
115 , function(exc.function)
118 , n_stacktrace_frames(exc.n_stacktrace_frames)
122#ifdef DEAL_II_HAVE_GLIBC_STACKTRACE
126 std::copy(std::begin(
exc.raw_stacktrace),
127 std::end(
exc.raw_stacktrace),
152#ifdef DEAL_II_HAVE_GLIBC_STACKTRACE
183 out <<
"An error occurred in line <" <<
line <<
"> of file <" <<
file
184 <<
"> in function" << std::endl
197 if ((
cond !=
nullptr) && (std::strcmp(
cond,
"false") != 0))
198 out <<
"The violated condition was: " << std::endl
199 <<
" " <<
cond << std::endl;
219 if ((
exc !=
nullptr) &&
220 ((
cond ==
nullptr) ||
221 (std::strstr(
cond,
"::ExcMessage") !=
nullptr)))
222 out <<
"The name and call sequence of the exception was:" << std::endl
223 <<
" " <<
exc << std::endl;
226 out <<
"Additional information: " << std::endl;
234 out <<
" (none)" << std::endl;
248 char **stacktrace =
nullptr;
249#ifdef DEAL_II_HAVE_GLIBC_STACKTRACE
259 out <<
"Stacktrace:" << std::endl <<
"-----------" << std::endl;
267 ((std::string(stacktrace[frame]).find(
"ExceptionBase") !=
268 std::string::npos) ||
269 (std::string(stacktrace[frame]).find(
"deal_II_exceptions") !=
274 const unsigned int first_significant_frame = frame;
277 out <<
'#' << frame - first_significant_frame <<
" ";
282 std::string stacktrace_entry(stacktrace[frame]);
283 const unsigned int pos_start = stacktrace_entry.find(
'('),
284 pos_end = stacktrace_entry.find(
'+');
285 std::string functionname =
286 stacktrace_entry.substr(pos_start + 1, pos_end - pos_start - 1);
288 stacktrace_entry.resize(pos_start);
289 stacktrace_entry +=
": ";
295#ifdef DEAL_II_HAVE_LIBSTDCXX_DEMANGLER
298 abi::__cxa_demangle(functionname.c_str(),
nullptr,
nullptr, &status);
300 if ((status == 0) && (functionname !=
"main"))
302 std::string realname(p);
309 while (realname.find(
", boost::tuples::null_type>") !=
311 realname.erase(realname.find(
", boost::tuples::null_type>"),
312 std::string(
", boost::tuples::null_type").size());
314 stacktrace_entry += realname;
317 stacktrace_entry += functionname;
323 stacktrace_entry += functionname;
327 out << stacktrace_entry << std::endl;
330 if (functionname ==
"main")
335 stacktrace =
nullptr;
348 std::ostringstream converter;
350 converter << std::endl
351 <<
"--------------------------------------------------------"
361 std::ostringstream message;
364 const auto message_in_lines =
368 for (
const auto &
line : message_in_lines)
369 converter <<
" " <<
line <<
'\n';
379 <<
"--------------------------------------------------------"
385 converter <<
"--------------------------------------------------------"
393 what_str =
"ExceptionBase::generate_message () failed";
401#ifdef DEAL_II_WITH_MPI
403 : error_code(error_code)
409 char error_name[MPI_MAX_ERROR_STRING];
410 error_name[0] =
'\0';
411 int resulting_length = MPI_MAX_ERROR_STRING;
413 bool error_name_known =
false;
421 int ierr = MPI_Error_class(
error_code, &error_class);
422 error_name_known = (ierr == MPI_SUCCESS);
426 if (error_name_known)
428 ierr = MPI_Error_string(error_class, error_name, &resulting_length);
429 error_name_known = error_name_known && (ierr == MPI_SUCCESS);
433 out <<
"deal.II encountered an error while calling an MPI function."
435 if (error_name_known)
437 out <<
"The description of the error provided by MPI is \""
438 << error_name <<
"\"." << std::endl;
443 <<
"This error code is not equal to any of the standard MPI error codes."
446 out <<
"The numerical value of the original error code is " <<
error_code
453#ifdef DEAL_II_TRILINOS_WITH_SEACAS
454 ExcExodusII::ExcExodusII(
const int error_code)
455 : error_code(error_code)
459 static_assert(EX_NOERR == 0,
460 "EX_NOERR is assumed to be zero in all versions of ExodusII");
466 ExcExodusII::print_info(std::ostream &out)
const
468 out <<
"Error code is " << error_code <<
'\n';
469 out <<
"String description: " << ex_strerror(error_code) <<
'\n';
482 std::cerr << exc.what() << std::endl;
496#ifdef DEAL_II_WITH_MPI
498 MPI_Initialized(&is_initialized);
499 if (is_initialized != 0)
507 <<
"Calling MPI_Abort now.\n"
508 <<
"To break execution in a GDB session, execute 'break MPI_Abort' before "
509 <<
"running. You can also put the following into your ~/.gdbinit:\n"
510 <<
" set breakpoint pending on\n"
511 <<
" break MPI_Abort\n"
512 <<
" set breakpoint pending auto" << std::endl;
514 MPI_Abort(MPI_COMM_WORLD,
523 if constexpr (std::is_same_v<Kokkos::DefaultExecutionSpace,
524 Kokkos::DefaultHostExecutionSpace>)
534 "Abort() was called during dealing with an assertion or exception.");
549 deallog <<
"Exception: " << exc.get_exc_name() << std::endl;
550 deallog << exc.what() << std::endl;
556#ifdef DEAL_II_WITH_CUDA
562 case CUSPARSE_STATUS_NOT_INITIALIZED:
564 return "The cuSPARSE library was not initialized";
566 case CUSPARSE_STATUS_ALLOC_FAILED:
568 return "Resource allocation failed inside the cuSPARSE library";
570 case CUSPARSE_STATUS_INVALID_VALUE:
572 return "An unsupported value of parameter was passed to the function";
574 case CUSPARSE_STATUS_ARCH_MISMATCH:
576 return "The function requires a feature absent from the device architecture";
578 case CUSPARSE_STATUS_MAPPING_ERROR:
580 return "An access to GPU memory space failed";
582 case CUSPARSE_STATUS_EXECUTION_FAILED:
584 return "The GPU program failed to execute";
586 case CUSPARSE_STATUS_INTERNAL_ERROR:
588 return "An internal cuSPARSE operation failed";
590 case CUSPARSE_STATUS_MATRIX_TYPE_NOT_SUPPORTED:
592 return "The matrix type is not supported by this function";
596 return "Unknown error";
609 case CUSOLVER_STATUS_NOT_INITIALIZED:
611 return "The cuSolver library was not initialized";
613 case CUSOLVER_STATUS_ALLOC_FAILED:
615 return "Resource allocation failed inside the cuSolver library";
617 case CUSOLVER_STATUS_INVALID_VALUE:
619 return "An unsupported value of a parameter was passed to the function";
621 case CUSOLVER_STATUS_ARCH_MISMATCH:
623 return "The function requires a feature absent from the device architecture";
625 case CUSOLVER_STATUS_EXECUTION_FAILED:
627 return "The GPU program failed to execute";
629 case CUSOLVER_STATUS_INTERNAL_ERROR:
631 return "An internal cuSolver operation failed";
633 case CUSOLVER_STATUS_MATRIX_TYPE_NOT_SUPPORTED:
635 return "The matrix type is not supported by this function";
639 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()