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

     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.

     19:    Not Collective

     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

     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.

     37:    Level: developer

     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.

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

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

     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: {
     61:   (*PetscErrorPrintf)("%s() line %d in %s%s %s\n",fun,line,dir,file,mess);
     62:   abort();
     63:   return(0);
     64: }