Actual source code: errabort.c

  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
  7: #if defined(PETSC_HAVE_STDLIB_H)
  8: #include <stdlib.h>
  9: #endif

 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.

 18:    Not Collective

 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

 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.

 36:    Level: developer

 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.

 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().

 51:    Concepts: error handler^aborting
 52:    Concepts: aborting on error

 54: .seealso: PetscPushErrorHandler(), PetscTraceBackErrorHandler(), 
 55:           PetscAttachDebuggerErrorHandler()
 56: @*/
 57: PetscErrorCode  PetscAbortErrorHandler(int line,const char *fun,const char *file,const char* dir,PetscErrorCode n,int p,const char *mess,void *ctx)
 58: {
 60:   (*PetscErrorPrintf)("%s() line %d in %s%s %s\n",fun,line,dir,file,mess);
 61:   abort();
 62:   return(0);
 63: }