Actual source code: errtrace.c
2: #include petsc.h
7: /*@C
8: PetscIgnoreErrorHandler - Ignores the error, allows program to continue as if error did not occure
10: Not Collective
12: Input Parameters:
13: + line - the line number of the error (indicated by __LINE__)
14: . func - the function where error is detected (indicated by __FUNCT__)
15: . file - the file in which the error was detected (indicated by __FILE__)
16: . dir - the directory of the file (indicated by __SDIR__)
17: . mess - an error text string, usually just printed to the screen
18: . n - the generic error number
19: . p - specific error number
20: - ctx - error handler context
22: Level: developer
24: Notes:
25: Most users need not directly employ this routine and the other error
26: handlers, but can instead use the simplified interface SETERRQ, which has
27: the calling sequence
28: $ SETERRQ(number,p,mess)
30: Notes for experienced users:
31: Use PetscPushErrorHandler() to set the desired error handler. The
32: currently available PETSc error handlers include PetscTraceBackErrorHandler(),
33: PetscAttachDebuggerErrorHandler(), PetscAbortErrorHandler(), and PetscStopErrorHandler()
35: Concepts: error handler^traceback
36: Concepts: traceback^generating
38: .seealso: PetscPushErrorHandler(), PetscAttachDebuggerErrorHandler(),
39: PetscAbortErrorHandler(), PetscTraceBackErrorHandler()
40: @*/
41: PetscErrorCode PetscIgnoreErrorHandler(int line,const char *fun,const char* file,const char *dir,int n,int p,const char *mess,void *ctx)
42: {
44: PetscFunctionReturn(n);
45: }
50: /*@C
52: PetscTraceBackErrorHandler - Default error handler routine that generates
53: a traceback on error detection.
55: Not Collective
57: Input Parameters:
58: + line - the line number of the error (indicated by __LINE__)
59: . func - the function where error is detected (indicated by __FUNCT__)
60: . file - the file in which the error was detected (indicated by __FILE__)
61: . dir - the directory of the file (indicated by __SDIR__)
62: . mess - an error text string, usually just printed to the screen
63: . n - the generic error number
64: . p - specific error number
65: - ctx - error handler context
67: Level: developer
69: Notes:
70: Most users need not directly employ this routine and the other error
71: handlers, but can instead use the simplified interface SETERRQ, which has
72: the calling sequence
73: $ SETERRQ(number,p,mess)
75: Notes for experienced users:
76: Use PetscPushErrorHandler() to set the desired error handler. The
77: currently available PETSc error handlers include PetscTraceBackErrorHandler(),
78: PetscAttachDebuggerErrorHandler(), PetscAbortErrorHandler(), and PetscStopErrorHandler()
80: Concepts: error handler^traceback
81: Concepts: traceback^generating
83: .seealso: PetscPushErrorHandler(), PetscAttachDebuggerErrorHandler(),
84: PetscAbortErrorHandler()
85: @*/
86: PetscErrorCode PetscTraceBackErrorHandler(int line,const char *fun,const char* file,const char *dir,int n,int p,const char *mess,void *ctx)
87: {
88: PetscLogDouble mem,rss;
89: PetscTruth flg1,flg2;
93: (*PetscErrorPrintf)("%s() line %d in %s%s\n",fun,line,dir,file);
94: if (p == 1) {
95: if (n == PETSC_ERR_MEM) {
96: (*PetscErrorPrintf)("Out of memory. This could be due to allocating\n");
97: (*PetscErrorPrintf)("too large an object or bleeding by not properly\n");
98: (*PetscErrorPrintf)("destroying unneeded objects.\n");
99: PetscTrSpace(&mem,PETSC_NULL,PETSC_NULL);
100: PetscGetResidentSetSize(&rss);
101: PetscOptionsHasName(PETSC_NULL,"-trdump",&flg1);
102: PetscOptionsHasName(PETSC_NULL,"-trmalloc_log",&flg2);
103: if (flg2) {
104: PetscTrLogDump(stdout);
105: } else {
106: (*PetscErrorPrintf)("Memory allocated %D Memory used by process %D\n",(PetscInt)mem,(PetscInt)rss);
107: if (flg1) {
108: PetscTrDump(stdout);
109: } else {
110: (*PetscErrorPrintf)("Try running with -trdump or -trmalloc_log for info.\n");
111: }
112: }
113: } else {
114: const char *text;
115: PetscErrorMessage(n,&text,PETSC_NULL);
116: if (text) (*PetscErrorPrintf)("%s!\n",text);
117: }
118: if (mess) {
119: (*PetscErrorPrintf)("%s!\n",mess);
120: }
121: }
122: PetscFunctionReturn(n);
123: }