xref: /petsc/src/sys/error/errabort.c (revision ace3abfce6818a63371c0ee8fdb525d96915299c)
1 #define PETSC_DLL
2 /*
3        The default error handlers and code that allows one to change
4    error handlers.
5 */
6 #include "petscsys.h"           /*I "petscsys.h" I*/
7 #if defined(PETSC_HAVE_STDLIB_H)
8 #include <stdlib.h>
9 #endif
10 
11 #undef __FUNCT__
12 #define __FUNCT__ "PetscAbortErrorHandler"
13 /*@C
14    PetscAbortErrorHandler - Error handler that calls abort on error.
15    This routine is very useful when running in the debugger, because the
16    user can look directly at the stack frames and the variables.
17 
18    Not Collective
19 
20    Input Parameters:
21 +  comm - communicator over which error occurred
22 .  line - the line number of the error (indicated by __LINE__)
23 .  func - function where error occured (indicated by __FUNCT__)
24 .  file - the file in which the error was detected (indicated by __FILE__)
25 .  dir - the directory of the file (indicated by __SDIR__)
26 .  mess - an error text string, usually just printed to the screen
27 .  n - the generic error number
28 .  p - specific error number
29 -  ctx - error handler context
30 
31    Options Database Keys:
32 +  -on_error_abort - Activates aborting when an error is encountered
33 -  -start_in_debugger [noxterm,dbx,xxgdb]  [-display name] - Starts all
34     processes in the debugger and uses PetscAbortErrorHandler().  By default the
35     debugger is gdb; alternatives are dbx and xxgdb.
36 
37    Level: developer
38 
39    Notes:
40    Most users need not directly employ this routine and the other error
41    handlers, but can instead use the simplified interface SETERRQ, which
42    has the calling sequence
43 $     SETERRQ(comm,number,mess)
44    or its variants, SETERRQ1(number,formatstring,arg1), SETERRQ2(), ... that
45    allow including arguments in the message.
46 
47    Notes for experienced users:
48    Use PetscPushErrorHandler() to set the desired error handler.  The
49    currently available PETSc error handlers include PetscTraceBackErrorHandler(),
50    PetscAttachDebuggerErrorHandler(), and PetscAbortErrorHandler().
51 
52    Concepts: error handler^aborting
53    Concepts: aborting on error
54 
55 .seealso: PetscPushErrorHandler(), PetscTraceBackErrorHandler(),
56           PetscAttachDebuggerErrorHandler()
57 @*/
58 PetscErrorCode PETSCSYS_DLLEXPORT PetscAbortErrorHandler(MPI_Comm comm,int line,const char *fun,const char *file,const char* dir,PetscErrorCode n,PetscErrorType p,const char *mess,void *ctx)
59 {
60   PetscFunctionBegin;
61   (*PetscErrorPrintf)("%s() line %d in %s%s %s\n",fun,line,dir,file,mess);
62   abort();
63   PetscFunctionReturn(0);
64 }
65 
66