From: Timo Heister Date: Wed, 7 Jun 2017 17:26:07 +0000 (+0200) Subject: try to break in gdb when Assert fails X-Git-Tag: v9.0.0-rc1~1521^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b943cff6df2d1ce5d9888b0dc75a2603a39e693d;p=dealii.git try to break in gdb when Assert fails addresses #4490 (as good as we can do it), improves #4413 --- diff --git a/source/base/exceptions.cc b/source/base/exceptions.cc index 6f7c217dd0..90c8962e8b 100644 --- a/source/base/exceptions.cc +++ b/source/base/exceptions.cc @@ -421,14 +421,30 @@ namespace deal_II_exceptions // if the others don't recognize this, or at the very least // delay their termination until they realize that their // communication with the job that died times out. + // + // Unlike std::abort(), MPI_Abort() unfortunately doesn't break when + // running inside a debugger like GDB, so only use this strategy if + // absolutely necessary and inform the user how to use a debugger. #ifdef DEAL_II_WITH_MPI int is_initialized; MPI_Initialized(&is_initialized); if (is_initialized) - MPI_Abort (MPI_COMM_WORLD, - /* return code = */ 255); - else - std::abort (); + { + const unsigned int n_proc = Utilities::MPI::n_mpi_processes(MPI_COMM_WORLD); + if (n_proc>1) + { + std::cerr << "Calling MPI_Abort now.\n" + << "To break execution in a GDB session, execute 'break MPI_Abort' before " + << "running. You can also put the following into your ~/.gdbinit:\n" + << " set breakpoint pending on\n" + << " break MPI_Abort\n" + << " set breakpoint pending auto" << std::endl; + + MPI_Abort (MPI_COMM_WORLD, + /* return code = */ 255); + } + } + std::abort (); #else std::abort(); #endif