xref: /petsc/src/sys/error/errabort.c (revision 0700a8246d308f50502909ba325e6169d3ee27eb)
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 +  line - the line number of the error (indicated by __LINE__)
22 .  func - function where error occured (indicated by __FUNCT__)
23 .  file - the file in which the error was detected (indicated by __FILE__)
24 .  dir - the directory of the file (indicated by __SDIR__)
25 .  mess - an error text string, usually just printed to the screen
26 .  n - the generic error number
27 .  p - specific error number
28 -  ctx - error handler context
29 
30    Options Database Keys:
31 +  -on_error_abort - Activates aborting when an error is encountered
32 -  -start_in_debugger [noxterm,dbx,xxgdb]  [-display name] - Starts all
33     processes in the debugger and uses PetscAbortErrorHandler().  By default the
34     debugger is gdb; alternatives are dbx and xxgdb.
35 
36    Level: developer
37 
38    Notes:
39    Most users need not directly employ this routine and the other error
40    handlers, but can instead use the simplified interface SETERRQ, which
41    has the calling sequence
42 $     SETERRQ(number,mess)
43    or its variants, SETERRQ1(number,formatstring,arg1), SETERRQ2(), ... that
44    allow including arguments in the message.
45 
46    Notes for experienced users:
47    Use PetscPushErrorHandler() to set the desired error handler.  The
48    currently available PETSc error handlers include PetscTraceBackErrorHandler(),
49    PetscAttachDebuggerErrorHandler(), and PetscAbortErrorHandler().
50 
51    Concepts: error handler^aborting
52    Concepts: aborting on error
53 
54 .seealso: PetscPushErrorHandler(), PetscTraceBackErrorHandler(),
55           PetscAttachDebuggerErrorHandler()
56 @*/
57 PetscErrorCode PETSC_DLLEXPORT PetscAbortErrorHandler(int line,const char *fun,const char *file,const char* dir,PetscErrorCode n,int p,const char *mess,void *ctx)
58 {
59   PetscFunctionBegin;
60   (*PetscErrorPrintf)("%s() line %d in %s%s %s\n",fun,line,dir,file,mess);
61   abort();
62   PetscFunctionReturn(0);
63 }
64 
65