xref: /petsc/src/sys/error/errabort.c (revision e5c89e4ece6e3231999e6896bd6dacaf81d4b32f)
1 #define PETSC_DLL
2 /*
3        The default error handlers and code that allows one to change
4    error handlers.
5 */
6 #include "petsc.h"           /*I "petsc.h" I*/
7 #if defined(PETSC_HAVE_STDLIB_H)
8 #include <stdlib.h>
9 #endif
10 #include "petscfix.h"
11 
12 #undef __FUNCT__
13 #define __FUNCT__ "PetscAbortErrorHandler"
14 /*@C
15    PetscAbortErrorHandler - Error handler that calls abort on error.
16    This routine is very useful when running in the debugger, because the
17    user can look directly at the stack frames and the variables.
18 
19    Not Collective
20 
21    Input Parameters:
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(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 PETSC_DLLEXPORT PetscAbortErrorHandler(int line,const char *fun,const char *file,const char* dir,PetscErrorCode n,int 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