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