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;
90 , n_stacktrace_frames(0)
93#ifdef DEAL_II_HAVE_GLIBC_STACKTRACE
103 , function(exc.function)
106 , stacktrace(nullptr)
108 n_stacktrace_frames(0)
112#ifdef DEAL_II_HAVE_GLIBC_STACKTRACE
145#ifdef DEAL_II_HAVE_GLIBC_STACKTRACE
156#ifdef DEAL_II_HAVE_GLIBC_STACKTRACE
185 out <<
"An error occurred in line <" <<
line <<
"> of file <" <<
file
186 <<
"> in function" << std::endl
188 <<
"The violated condition was: " << std::endl
189 <<
" " <<
cond << std::endl;
203 if (std::strstr(
cond,
"::ExcMessage") !=
nullptr)
204 out <<
"The name and call sequence of the exception was:" << std::endl
205 <<
" " <<
exc << std::endl;
208 out <<
"Additional information: " << std::endl;
216 out <<
" (none)" << std::endl;
232 out <<
"Stacktrace:" << std::endl <<
"-----------" << std::endl;
240 ((std::string(
stacktrace[frame]).find(
"ExceptionBase") !=
241 std::string::npos) ||
242 (std::string(
stacktrace[frame]).find(
"deal_II_exceptions") !=
247 const unsigned int first_significant_frame = frame;
250 out <<
'#' << frame - first_significant_frame <<
" ";
255 std::string stacktrace_entry(
stacktrace[frame]);
256 const unsigned int pos_start = stacktrace_entry.find(
'('),
257 pos_end = stacktrace_entry.find(
'+');
258 std::string functionname =
259 stacktrace_entry.substr(pos_start + 1, pos_end - pos_start - 1);
261 stacktrace_entry = stacktrace_entry.substr(0, pos_start);
262 stacktrace_entry +=
": ";
268#ifdef DEAL_II_HAVE_LIBSTDCXX_DEMANGLER
271 abi::__cxa_demangle(functionname.c_str(),
nullptr,
nullptr, &status);
273 if ((status == 0) && (functionname !=
"main"))
275 std::string realname(p);
282 while (realname.find(
", boost::tuples::null_type>") !=
284 realname.erase(realname.find(
", boost::tuples::null_type>"),
285 std::string(
", boost::tuples::null_type").size());
287 stacktrace_entry += realname;
290 stacktrace_entry += functionname;
296 stacktrace_entry += functionname;
300 out << stacktrace_entry << std::endl;
303 if (functionname ==
"main")
318 std::ostringstream converter;
320 converter << std::endl
321 <<
"--------------------------------------------------------"
331 std::ostringstream message;
334 const auto message_in_lines =
338 for (
const auto &
line : message_in_lines)
339 converter <<
" " <<
line <<
'\n';
349 <<
"--------------------------------------------------------"
355 converter <<
"--------------------------------------------------------"
363 what_str =
"ExceptionBase::generate_message () failed";
371#ifdef DEAL_II_WITH_MPI
373 : error_code(error_code)
379 char error_name[MPI_MAX_ERROR_STRING];
380 error_name[0] =
'\0';
381 int resulting_length = MPI_MAX_ERROR_STRING;
383 bool error_name_known =
false;
391 int ierr = MPI_Error_class(
error_code, &error_class);
392 error_name_known = (ierr == MPI_SUCCESS);
396 if (error_name_known)
398 ierr = MPI_Error_string(error_class, error_name, &resulting_length);
399 error_name_known = error_name_known && (ierr == MPI_SUCCESS);
403 out <<
"deal.II encountered an error while calling an MPI function."
405 if (error_name_known)
407 out <<
"The description of the error provided by MPI is \""
408 << error_name <<
"\"." << std::endl;
413 <<
"This error code is not equal to any of the standard MPI error codes."
416 out <<
"The numerical value of the original error code is " <<
error_code
423#ifdef DEAL_II_TRILINOS_WITH_SEACAS
424 ExcExodusII::ExcExodusII(
const int error_code)
425 : error_code(error_code)
429 static_assert(EX_NOERR == 0,
430 "EX_NOERR is assumed to be zero in all versions of ExodusII");
436 ExcExodusII::print_info(std::ostream &out)
const
438 out <<
"Error code is " << error_code <<
'\n';
439 out <<
"String description: " << ex_strerror(error_code) <<
'\n';
452 std::cerr << exc.what() << std::endl;
466#ifdef DEAL_II_WITH_MPI
468 MPI_Initialized(&is_initialized);
477 <<
"Calling MPI_Abort now.\n"
478 <<
"To break execution in a GDB session, execute 'break MPI_Abort' before "
479 <<
"running. You can also put the following into your ~/.gdbinit:\n"
480 <<
" set breakpoint pending on\n"
481 <<
" break MPI_Abort\n"
482 <<
" set breakpoint pending auto" << std::endl;
484 MPI_Abort(MPI_COMM_WORLD,
503 deallog <<
"Exception: " << exc.get_exc_name() << std::endl;
504 deallog << exc.what() << std::endl;
510#ifdef DEAL_II_WITH_CUDA
516 case CUSPARSE_STATUS_NOT_INITIALIZED:
518 return "The cuSPARSE library was not initialized";
520 case CUSPARSE_STATUS_ALLOC_FAILED:
522 return "Resource allocation failed inside the cuSPARSE library";
524 case CUSPARSE_STATUS_INVALID_VALUE:
526 return "An unsupported value of parameter was passed to the function";
528 case CUSPARSE_STATUS_ARCH_MISMATCH:
530 return "The function requires a feature absent from the device architecture";
532 case CUSPARSE_STATUS_MAPPING_ERROR:
534 return "An access to GPU memory space failed";
536 case CUSPARSE_STATUS_EXECUTION_FAILED:
538 return "The GPU program failed to execute";
540 case CUSPARSE_STATUS_INTERNAL_ERROR:
542 return "An internal cuSPARSE operation failed";
544 case CUSPARSE_STATUS_MATRIX_TYPE_NOT_SUPPORTED:
546 return "The matrix type is not supported by this function";
550 return "Unknown error";
563 case CUSOLVER_STATUS_NOT_INITIALIZED:
565 return "The cuSolver library was not initialized";
567 case CUSOLVER_STATUS_ALLOC_FAILED:
569 return "Resource allocation failed inside the cuSolver library";
571 case CUSOLVER_STATUS_INVALID_VALUE:
573 return "An unsupported value of a parameter was passed to the function";
575 case CUSOLVER_STATUS_ARCH_MISMATCH:
577 return "The function requires a feature absent from the device architecture";
579 case CUSOLVER_STATUS_EXECUTION_FAILED:
581 return "The GPU program failed to execute";
583 case CUSOLVER_STATUS_INTERNAL_ERROR:
585 return "An internal cuSolver operation failed";
587 case CUSOLVER_STATUS_MATRIX_TYPE_NOT_SUPPORTED:
589 return "The matrix type is not supported by this function";
593 return "Unknown error";
void generate_message() const
void print_stack_trace(std::ostream &out) const
virtual ~ExceptionBase() noexcept override
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
SymmetricTensor< 2, dim, Number > e(const Tensor< 2, dim, Number > &F)
Tensor< 2, dim, Number > l(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
VectorType::value_type * end(VectorType &V)
VectorType::value_type * begin(VectorType &V)
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 disable_abort_on_exception()
void set_additional_assert_output(const char *const p)
void suppress_stacktrace_in_exceptions()