imprive error handling.
This commit is contained in:
parent
14d4386e5a
commit
9ce268915d
@ -444,7 +444,7 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
|
||||
tmpbuf[0] = '\0';
|
||||
}
|
||||
va_end (ap);
|
||||
fprintf(stderr,"%% ERROR WITHIN ERROR: %s\n", tmpbuf);
|
||||
fprintf(stderr,"%% ERROR WITHIN ERROR %d: %s\n", tmpbuf, LOCAL_CurrentError);
|
||||
exit(1);
|
||||
}
|
||||
/* must do this here */
|
||||
@ -485,6 +485,7 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
|
||||
if (type == PURE_ABORT || LOCAL_PrologMode & BootMode) {
|
||||
where = TermNil;
|
||||
LOCAL_PrologMode &= ~AbortMode;
|
||||
LOCAL_CurrentError = type;
|
||||
LOCAL_PrologMode |= InErrorMode;
|
||||
/* make sure failure will be seen at next port */
|
||||
if (LOCAL_PrologMode & AsyncIntMode)
|
||||
@ -499,6 +500,7 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
|
||||
}
|
||||
/* Exit Abort Mode, if we were there */
|
||||
LOCAL_PrologMode &= ~AbortMode;
|
||||
LOCAL_CurrentError = type;
|
||||
LOCAL_PrologMode |= InErrorMode;
|
||||
if (!(where = Yap_CopyTerm(where))) {
|
||||
where = TermNil;
|
||||
|
22
C/stdpreds.c
22
C/stdpreds.c
@ -4010,7 +4010,7 @@ p_executable( USES_REGS1 )
|
||||
if (GLOBAL_argv && GLOBAL_argv[0])
|
||||
Yap_TrueFileName (GLOBAL_argv[0], LOCAL_FileNameBuf, FALSE);
|
||||
else
|
||||
strncpy(LOCAL_FileNameBuf,Yap_FindExecutable (), YAP_FILENAME_MAX) ;
|
||||
strncpy(LOCAL_FileNameBuf, Yap_FindExecutable(), YAP_FILENAME_MAX-1) ;
|
||||
|
||||
return Yap_unify(MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf)),ARG1);
|
||||
}
|
||||
@ -4034,23 +4034,25 @@ p_access_yap_flags( USES_REGS1 )
|
||||
if (flag < 0 || flag >= NUMBER_OF_YAP_FLAGS) {
|
||||
return(FALSE);
|
||||
}
|
||||
#ifdef TABLING
|
||||
if (flag == TABLING_MODE_FLAG) {
|
||||
#ifdef TABLING
|
||||
tout = TermNil;
|
||||
if (IsMode_LocalTrie(yap_flags[flag]))
|
||||
tout = MkPairTerm(MkAtomTerm(AtomLocalTrie), tout);
|
||||
else if (IsMode_GlobalTrie(yap_flags[flag]))
|
||||
else // if (IsMode_GlobalTrie(yap_flags[flag]))
|
||||
tout = MkPairTerm(MkAtomTerm(AtomGlobalTrie), tout);
|
||||
if (IsMode_ExecAnswers(yap_flags[flag]))
|
||||
tout = MkPairTerm(MkAtomTerm(AtomExecAnswers), tout);
|
||||
else if (IsMode_LoadAnswers(yap_flags[flag]))
|
||||
if (IsMode_LoadAnswers(yap_flags[flag]))
|
||||
tout = MkPairTerm(MkAtomTerm(AtomLoadAnswers), tout);
|
||||
if (IsMode_Batched(yap_flags[flag]))
|
||||
tout = MkPairTerm(MkAtomTerm(AtomBatched), tout);
|
||||
else if (IsMode_Local(yap_flags[flag]))
|
||||
else // if (IsMode_ExecAnswers(yap_flags[flag]))
|
||||
tout = MkPairTerm(MkAtomTerm(AtomExecAnswers), tout);
|
||||
if (IsMode_Local(yap_flags[flag]))
|
||||
tout = MkPairTerm(MkAtomTerm(AtomLocal), tout);
|
||||
} else
|
||||
else // if (IsMode_Batched(yap_flags[flag]))
|
||||
tout = MkPairTerm(MkAtomTerm(AtomBatched), tout);
|
||||
#else
|
||||
tout = MkAtomTerm(AtomFalse);
|
||||
#endif /* TABLING */
|
||||
} else
|
||||
tout = MkIntegerTerm(yap_flags[flag]);
|
||||
return(Yap_unify(ARG2, tout));
|
||||
}
|
||||
|
@ -105,7 +105,6 @@ typedef void (*YapInitProc)(void);
|
||||
#define STD_PROTO(F,A) F A
|
||||
#endif
|
||||
|
||||
char *STD_PROTO(Yap_FindExecutable,(void));
|
||||
void *STD_PROTO(Yap_LoadForeignFile,(char *, int));
|
||||
int STD_PROTO(Yap_CallForeignFile,(void *, char *));
|
||||
int STD_PROTO(Yap_CloseForeignFile,(void *));
|
||||
|
@ -186,6 +186,9 @@ Term STD_PROTO(Yap_GetException,(void));
|
||||
/* exo.c */
|
||||
void STD_PROTO(Yap_InitExoPreds,(void));
|
||||
|
||||
/* foreign.c */
|
||||
char *STD_PROTO(Yap_FindExecutable,(void));
|
||||
|
||||
/* gprof.c */
|
||||
void STD_PROTO(Yap_InitLowProf,(void));
|
||||
#if LOW_PROF
|
||||
|
@ -310,6 +310,8 @@
|
||||
|
||||
#define LOCAL_matherror LOCAL->matherror_
|
||||
#define REMOTE_matherror(wid) REMOTE(wid)->matherror_
|
||||
#define LOCAL_CurrentError LOCAL->CurrentError_
|
||||
#define REMOTE_CurrentError(wid) REMOTE(wid)->CurrentError_
|
||||
|
||||
#define LOCAL_heap_overflows LOCAL->heap_overflows_
|
||||
#define REMOTE_heap_overflows(wid) REMOTE(wid)->heap_overflows_
|
||||
|
@ -176,6 +176,7 @@ typedef struct worker_local {
|
||||
struct db_globs* s_dbg_;
|
||||
|
||||
yap_error_number matherror_;
|
||||
yap_error_number CurrentError_;
|
||||
|
||||
int heap_overflows_;
|
||||
Int total_heap_overflow_time_;
|
||||
|
@ -176,6 +176,7 @@ static void InitWorker(int wid) {
|
||||
|
||||
|
||||
REMOTE_matherror(wid) = YAP_NO_ERROR;
|
||||
REMOTE_CurrentError(wid) = YAP_NO_ERROR;
|
||||
|
||||
REMOTE_heap_overflows(wid) = 0;
|
||||
REMOTE_total_heap_overflow_time(wid) = 0;
|
||||
|
@ -188,6 +188,7 @@ static void RestoreWorker(int wid USES_REGS) {
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef LOAD_DYLD
|
||||
|
||||
#endif
|
||||
|
@ -199,6 +199,7 @@ struct db_globs* s_dbg void
|
||||
|
||||
//eval.c
|
||||
yap_error_number matherror =YAP_NO_ERROR
|
||||
yap_error_number CurrentError =YAP_NO_ERROR
|
||||
|
||||
//grow.c
|
||||
int heap_overflows =0
|
||||
|
Reference in New Issue
Block a user