diff --git a/C/errors.c b/C/errors.c index 57757961a..7eb223186 100755 --- a/C/errors.c +++ b/C/errors.c @@ -29,6 +29,50 @@ #endif #include "Foreign.h" +#if DEBUG +void +Yap_PrintPredName( PredEntry *ap ) +{ + CACHE_REGS + Term tmod = ap->ModuleOfPred; + if (!tmod) tmod = TermProlog; +#if THREADS + Yap_DebugPlWrite(MkIntegerTerm(worker_id)); + Yap_DebugPutc(LOCAL_c_error_stream,' '); +#endif + Yap_DebugPutc(LOCAL_c_error_stream,'>'); + Yap_DebugPutc(LOCAL_c_error_stream,'\t'); + Yap_DebugPlWrite(tmod); + Yap_DebugPutc(LOCAL_c_error_stream,':'); + if (ap->ModuleOfPred == IDB_MODULE) { + Term t = Deref(ARG1); + if (IsAtomTerm(t)) { + Yap_DebugPlWrite(t); + } else if (IsIntegerTerm(t)) { + Yap_DebugPlWrite(t); + } else { + Functor f = FunctorOfTerm(t); + Atom At = NameOfFunctor(f); + Yap_DebugPlWrite(MkAtomTerm(At)); + Yap_DebugPutc(LOCAL_c_error_stream,'/'); + Yap_DebugPlWrite(MkIntegerTerm(ArityOfFunctor(f))); + } + } else { + if (ap->ArityOfPE == 0) { + Atom At = (Atom)ap->FunctorOfPred; + Yap_DebugPlWrite(MkAtomTerm(At)); + } else { + Functor f = ap->FunctorOfPred; + Atom At = NameOfFunctor(f); + Yap_DebugPlWrite(MkAtomTerm(At)); + Yap_DebugPutc(LOCAL_c_error_stream,'/'); + Yap_DebugPlWrite(MkIntegerTerm(ArityOfFunctor(f))); + } + } + Yap_DebugPutc(LOCAL_c_error_stream,'\n'); +} +#endif + int Yap_HandleError( const char *s, ... ) { CACHE_REGS yap_error_number err = LOCAL_Error_TYPE; @@ -1991,7 +2035,7 @@ E); Yap_RestartYap( 1 ); } #if DEBUG - DumpActiveGoals( PASS_REGS1 ); + // DumpActiveGoals( PASS_REGS1 ); #endif /* wait if we we are in user code, it's up to her to decide */ diff --git a/C/qlyr.c b/C/qlyr.c index 6ac2dddae..b1936c28b 100755 --- a/C/qlyr.c +++ b/C/qlyr.c @@ -657,18 +657,18 @@ read_bits16(IOSTREAM *stream) } static UInt -read_uint(IOSTREAM *stream) +read_UInt(IOSTREAM *stream) { UInt v; read_bytes(stream, &v, sizeof(UInt)); return v; } -static int -read_int(IOSTREAM *stream) +static Int +read_Int(IOSTREAM *stream) { - int v; - read_bytes(stream, &v, sizeof(int)); + Int v; + read_bytes(stream, &v, sizeof(Int)); return v; } @@ -692,18 +692,18 @@ ReadHash(IOSTREAM *stream) CACHE_REGS UInt i; RCHECK(read_tag(stream) == QLY_START_X); - LOCAL_XDiff = (char *)(&ARG1) - (char *)read_uint(stream); + LOCAL_XDiff = (char *)(&ARG1) - (char *)read_UInt(stream); RCHECK(read_tag(stream) == QLY_START_OPCODES); - RCHECK(read_int(stream) == _std_top); + RCHECK(read_Int(stream) == _std_top); for (i= 0; i <= _std_top; i++) { - InsertOPCODE((OPCODE)read_uint(stream), i, Yap_opcode(i)); + InsertOPCODE((OPCODE)read_UInt(stream), i, Yap_opcode(i)); } RCHECK(read_tag(stream) == QLY_START_ATOMS); - LOCAL_ImportAtomHashTableNum = read_uint(stream); + LOCAL_ImportAtomHashTableNum = read_UInt(stream); LOCAL_ImportAtomHashTableSize = LOCAL_ImportAtomHashTableNum*2; LOCAL_ImportAtomHashChain = (import_atom_hash_entry_t **)calloc(LOCAL_ImportAtomHashTableSize, sizeof(import_atom_hash_entry_t *)); for (i = 0; i < LOCAL_ImportAtomHashTableNum; i++) { - Atom oat = (Atom)read_uint(stream); + Atom oat = (Atom)read_UInt(stream); Atom at; qlf_tag_t tg = read_tag(stream); @@ -711,7 +711,7 @@ ReadHash(IOSTREAM *stream) wchar_t *rep = (wchar_t *)AllocTempSpace(); UInt len; - len = read_uint(stream); + len = read_UInt(stream); if (!EnoughTempSpace(len)) QLYR_ERROR(OUT_OF_TEMP_SPACE); read_bytes(stream, rep, (len+1)*sizeof(wchar_t)); while (!(at = Yap_LookupWideAtom(rep))) { @@ -724,7 +724,7 @@ ReadHash(IOSTREAM *stream) char *rep = (char *)AllocTempSpace(); UInt len; - len = read_uint(stream); + len = read_UInt(stream); if (!EnoughTempSpace(len)) QLYR_ERROR(OUT_OF_TEMP_SPACE); read_bytes(stream, rep, (len+1)*sizeof(char)); while (!(at = Yap_FullLookupAtom(rep))) { @@ -741,13 +741,13 @@ ReadHash(IOSTREAM *stream) } /* functors */ RCHECK(read_tag(stream) == QLY_START_FUNCTORS); - LOCAL_ImportFunctorHashTableNum = read_uint(stream); + LOCAL_ImportFunctorHashTableNum = read_UInt(stream); LOCAL_ImportFunctorHashTableSize = 2*LOCAL_ImportFunctorHashTableNum; LOCAL_ImportFunctorHashChain = (import_functor_hash_entry_t **)calloc(LOCAL_ImportFunctorHashTableSize, sizeof(import_functor_hash_entry_t *)); for (i = 0; i < LOCAL_ImportFunctorHashTableNum; i++) { - Functor of = (Functor)read_uint(stream); - UInt arity = read_uint(stream); - Atom oat = (Atom)read_uint(stream); + Functor of = (Functor)read_UInt(stream); + UInt arity = read_UInt(stream); + Atom oat = (Atom)read_UInt(stream); Atom at = AtomAdjust(oat); Functor f; while (!(f = Yap_MkFunctor(at, arity))) { @@ -758,13 +758,13 @@ ReadHash(IOSTREAM *stream) InsertFunctor(of, f); } RCHECK(read_tag(stream) == QLY_START_PRED_ENTRIES); - LOCAL_ImportPredEntryHashTableNum = read_uint(stream); + LOCAL_ImportPredEntryHashTableNum = read_UInt(stream); LOCAL_ImportPredEntryHashTableSize = 2*LOCAL_ImportPredEntryHashTableNum; LOCAL_ImportPredEntryHashChain = (import_pred_entry_hash_entry_t **)calloc( LOCAL_ImportPredEntryHashTableSize, sizeof(import_pred_entry_hash_entry_t *)); for (i = 0; i < LOCAL_ImportPredEntryHashTableNum; i++) { - PredEntry *ope = (PredEntry *)read_uint(stream), *pe; - UInt arity = read_uint(stream); - Atom omod = (Atom)read_uint(stream); + PredEntry *ope = (PredEntry *)read_UInt(stream), *pe; + UInt arity = read_UInt(stream); + Atom omod = (Atom)read_UInt(stream); Term mod; if (omod) { @@ -776,7 +776,7 @@ ReadHash(IOSTREAM *stream) if (mod != IDB_MODULE) { if (arity) { - Functor of = (Functor)read_uint(stream); + Functor of = (Functor)read_UInt(stream); Functor f = LookupFunctor(of); while(!(pe = RepPredProp(PredPropByFuncAndMod(f,mod)))) { if (!Yap_growheap(FALSE, 0, NULL)) { @@ -784,20 +784,20 @@ ReadHash(IOSTREAM *stream) } } } else { - Atom oa = (Atom)read_uint(stream); + Atom oa = (Atom)read_UInt(stream); Atom a = LookupAtom(oa); pe = RepPredProp(PredPropByAtomAndMod(a,mod)); } } else { if (arity == (UInt)-1) { - UInt i = read_uint(stream); + UInt i = read_UInt(stream); pe = Yap_FindLUIntKey(i); } else if (arity == (UInt)(-2)) { - Atom oa = (Atom)read_uint(stream); + Atom oa = (Atom)read_UInt(stream); Atom a = LookupAtom(oa); pe = RepPredProp(PredPropByAtomAndMod(a,mod)); } else { - Functor of = (Functor)read_uint(stream); + Functor of = (Functor)read_UInt(stream); Functor f = LookupFunctor(of); pe = RepPredProp(PredPropByFuncAndMod(f,mod)); } @@ -806,13 +806,13 @@ ReadHash(IOSTREAM *stream) InsertPredEntry(ope, pe); } RCHECK(read_tag(stream) == QLY_START_DBREFS); - LOCAL_ImportDBRefHashTableNum = read_uint(stream); + LOCAL_ImportDBRefHashTableNum = read_UInt(stream); LOCAL_ImportDBRefHashTableSize = 2*LOCAL_ImportDBRefHashTableNum; LOCAL_ImportDBRefHashChain = (import_dbref_hash_entry_t **)calloc(LOCAL_ImportDBRefHashTableSize, sizeof(import_dbref_hash_entry_t *)); for (i = 0; i < LOCAL_ImportDBRefHashTableNum; i++) { - LogUpdClause *ocl = (LogUpdClause *)read_uint(stream); - UInt sz = read_uint(stream); - UInt nrefs = read_uint(stream); + LogUpdClause *ocl = (LogUpdClause *)read_UInt(stream); + UInt sz = read_UInt(stream); + UInt nrefs = read_UInt(stream); LogUpdClause *ncl = (LogUpdClause *)Yap_AlwaysAllocCodeSpace(sz); if (!ncl) { QLYR_ERROR(OUT_OF_CODE_SPACE); @@ -822,7 +822,7 @@ ReadHash(IOSTREAM *stream) InsertDBRef((DBRef)ocl,(DBRef)ncl); } RCHECK(read_tag(stream) == QLY_FAILCODE); - LOCAL_ImportFAILCODE = (yamop *)read_uint(stream); + LOCAL_ImportFAILCODE = (yamop *)read_UInt(stream); } static void @@ -843,8 +843,8 @@ read_clauses(IOSTREAM *stream, PredEntry *pp, UInt nclauses, UInt flags) { return; } while ((read_tag(stream) == QLY_START_LU_CLAUSE)) { - char *base = (void *)read_uint(stream); - UInt size = read_uint(stream); + char *base = (void *)read_UInt(stream); + UInt size = read_UInt(stream); LogUpdClause *cl; Int nrefs = 0; @@ -862,9 +862,9 @@ read_clauses(IOSTREAM *stream, PredEntry *pp, UInt nclauses, UInt flags) { } } else if (pp->PredFlags & MegaClausePredFlag) { CACHE_REGS - char *base = (void *)read_uint(stream); - UInt mask = read_uint(stream); - UInt size = read_uint(stream); + char *base = (void *)read_UInt(stream); + UInt mask = read_UInt(stream); + UInt size = read_UInt(stream); MegaClause *cl = (MegaClause *)Yap_AlwaysAllocCodeSpace(size); if (nclauses) { @@ -894,8 +894,8 @@ read_clauses(IOSTREAM *stream, PredEntry *pp, UInt nclauses, UInt flags) { UInt i; for (i = 0; i < nclauses; i++) { - char *base = (void *)read_uint(stream); - UInt size = read_uint(stream); + char *base = (void *)read_UInt(stream); + UInt size = read_UInt(stream); DynamicClause *cl = (DynamicClause *)Yap_AlwaysAllocCodeSpace(size); LOCAL_HDiff = (char *)cl-base; @@ -917,8 +917,8 @@ read_clauses(IOSTREAM *stream, PredEntry *pp, UInt nclauses, UInt flags) { } Yap_Abolish(pp); for (i = 0; i < nclauses; i++) { - char *base = (void *)read_uint(stream); - UInt size = read_uint(stream); + char *base = (void *)read_UInt(stream); + UInt size = read_UInt(stream); StaticClause *cl = (StaticClause *)Yap_AlwaysAllocCodeSpace(size); LOCAL_HDiff = (char *)cl-base; @@ -938,12 +938,12 @@ read_pred(IOSTREAM *stream, Term mod) { UInt nclauses, fl1; PredEntry *ap; - ap = LookupPredEntry((PredEntry *)read_uint(stream)); - flags = read_uint(stream); + ap = LookupPredEntry((PredEntry *)read_UInt(stream)); + flags = read_UInt(stream); #if SIZEOF_INT_P==4 - eflags = read_uint(stream); + eflags = read_UInt(stream); #endif - nclauses = read_uint(stream); + nclauses = read_UInt(stream); if (ap->PredFlags & IndexedPredFlag) { Yap_RemoveIndexation(ap); } @@ -959,14 +959,14 @@ read_pred(IOSTREAM *stream, Term mod) { ap->PredFlags |= fl1; #endif if (flags & NumberDBPredFlag) { - ap->src.IndxId = read_uint(stream); + ap->src.IndxId = read_UInt(stream); } else { - ap->src.OwnerFile = (Atom)read_uint(stream); + ap->src.OwnerFile = (Atom)read_UInt(stream); if (ap->src.OwnerFile) { ap->src.OwnerFile = AtomAdjust(ap->src.OwnerFile); } } - ap->TimeStampOfPred = read_uint(stream); + ap->TimeStampOfPred = read_UInt(stream); /* multifile predicates cannot reside in module 0 */ if (flags & MultiFileFlag && ap->ModuleOfPred == PROLOG_MODULE) { ap->ModuleOfPred = TermProlog; @@ -981,8 +981,8 @@ static void read_ops(IOSTREAM *stream) { Int x; while ((x = read_tag(stream)) != QLY_END_OPS) { - Atom at = (Atom)read_uint(stream); - Term mod = (Term)read_uint(stream); + Atom at = (Atom)read_UInt(stream); + Term mod = (Term)read_UInt(stream); OpEntry *op; at = AtomAdjust(at); @@ -1005,7 +1005,7 @@ read_module(IOSTREAM *stream) { read_header(stream); ReadHash(stream); while ((x = read_tag(stream)) == QLY_START_MODULE) { - Term mod = (Term)read_uint(stream); + Term mod = (Term)read_UInt(stream); mod = MkAtomTerm(AtomAdjust(AtomOfTerm(mod))); if (mod) while ((x = read_tag(stream)) == QLY_START_PREDICATE) { diff --git a/C/qlyw.c b/C/qlyw.c index 42a34d298..b98757e95 100755 --- a/C/qlyw.c +++ b/C/qlyw.c @@ -537,16 +537,16 @@ static size_t save_bits16(IOSTREAM *stream, BITS16 val) return save_bytes(stream, &v, sizeof(BITS16)); } -static size_t save_uint(IOSTREAM *stream, UInt val) +static size_t save_UInt(IOSTREAM *stream, UInt val) { UInt v = val; return save_bytes(stream, &v, sizeof(UInt)); } -static size_t save_int(IOSTREAM *stream, int val) +static size_t save_Int(IOSTREAM *stream, Int val) { - UInt v = val; - return save_bytes(stream, &v, sizeof(int)); + Int v = val; + return save_bytes(stream, &v, sizeof(Int)); } static size_t save_tag(IOSTREAM *stream, qlf_tag_t tag) @@ -561,63 +561,63 @@ SaveHash(IOSTREAM *stream) UInt i; /* first, current opcodes */ CHECK(save_tag(stream, QLY_START_X)); - save_uint(stream, (UInt)&ARG1); + save_UInt(stream, (UInt)&ARG1); CHECK(save_tag(stream, QLY_START_OPCODES)); - save_int(stream, _std_top); + save_Int(stream, _std_top); for (i= 0; i <= _std_top; i++) { - save_uint(stream, (UInt)Yap_opcode(i)); + save_UInt(stream, (UInt)Yap_opcode(i)); } CHECK(save_tag(stream, QLY_START_ATOMS)); - CHECK(save_uint(stream, LOCAL_ExportAtomHashTableNum)); + CHECK(save_UInt(stream, LOCAL_ExportAtomHashTableNum)); for (i = 0; i < LOCAL_ExportAtomHashTableSize; i++) { export_atom_hash_entry_t *a = LOCAL_ExportAtomHashChain+i; if (a->val) { Atom at = a->val; - CHECK(save_uint(stream, (UInt)at)); + CHECK(save_UInt(stream, (UInt)at)); if (IsWideAtom(at)) { CHECK(save_tag(stream, QLY_ATOM_WIDE)); - CHECK(save_uint(stream, wcslen(RepAtom(at)->WStrOfAE))); + CHECK(save_UInt(stream, wcslen(RepAtom(at)->WStrOfAE))); CHECK(save_bytes(stream, at->WStrOfAE, (wcslen(at->WStrOfAE)+1)*sizeof(wchar_t))); } else { CHECK(save_tag(stream, QLY_ATOM)); - CHECK(save_uint(stream, strlen(RepAtom(at)->StrOfAE))); + CHECK(save_UInt(stream, strlen(RepAtom(at)->StrOfAE))); CHECK(save_bytes(stream, at->StrOfAE, (strlen(at->StrOfAE)+1)*sizeof(char))); } } } save_tag(stream, QLY_START_FUNCTORS); - save_uint(stream, LOCAL_ExportFunctorHashTableNum); + save_UInt(stream, LOCAL_ExportFunctorHashTableNum); for (i = 0; i < LOCAL_ExportFunctorHashTableSize; i++) { export_functor_hash_entry_t *f = LOCAL_ExportFunctorHashChain+i; if (!(f->val)) continue; - CHECK(save_uint(stream, (UInt)(f->val))); - CHECK(save_uint(stream, f->arity)); - CHECK(save_uint(stream, (CELL)(f->name))); + CHECK(save_UInt(stream, (UInt)(f->val))); + CHECK(save_UInt(stream, f->arity)); + CHECK(save_UInt(stream, (CELL)(f->name))); } save_tag(stream, QLY_START_PRED_ENTRIES); - save_uint(stream, LOCAL_ExportPredEntryHashTableNum); + save_UInt(stream, LOCAL_ExportPredEntryHashTableNum); for (i = 0; i < LOCAL_ExportPredEntryHashTableSize; i++) { export_pred_entry_hash_entry_t *p = LOCAL_ExportPredEntryHashChain+i; if (!(p->val)) continue; - CHECK(save_uint(stream, (UInt)(p->val))); - CHECK(save_uint(stream, p->arity)); - CHECK(save_uint(stream, (UInt)p->module)); - CHECK(save_uint(stream, (UInt)p->u_af.f)); + CHECK(save_UInt(stream, (UInt)(p->val))); + CHECK(save_UInt(stream, p->arity)); + CHECK(save_UInt(stream, (UInt)p->module)); + CHECK(save_UInt(stream, (UInt)p->u_af.f)); } save_tag(stream, QLY_START_DBREFS); - save_uint(stream, LOCAL_ExportDBRefHashTableNum); + save_UInt(stream, LOCAL_ExportDBRefHashTableNum); for (i = 0; i < LOCAL_ExportDBRefHashTableSize; i++) { export_dbref_hash_entry_t *p = LOCAL_ExportDBRefHashChain+i; if (p->val) { - CHECK(save_uint(stream, (UInt)(p->val))); - CHECK(save_uint(stream, p->sz)); - CHECK(save_uint(stream, p->refs)); + CHECK(save_UInt(stream, (UInt)(p->val))); + CHECK(save_UInt(stream, p->sz)); + CHECK(save_UInt(stream, p->refs)); } } save_tag(stream, QLY_FAILCODE); - save_uint(stream, (UInt)FAILCODE); + save_UInt(stream, (UInt)FAILCODE); return 1; } @@ -637,8 +637,8 @@ save_clauses(IOSTREAM *stream, PredEntry *pp) { if (IN_BETWEEN(cl->ClTimeStart, pp->TimeStampOfPred, cl->ClTimeEnd)) { UInt size = cl->ClSize; CHECK(save_tag(stream, QLY_START_LU_CLAUSE)); - CHECK(save_uint(stream, (UInt)cl)); - CHECK(save_uint(stream, size)); + CHECK(save_UInt(stream, (UInt)cl)); + CHECK(save_UInt(stream, size)); CHECK(save_bytes(stream, cl, size)); } cl = cl->ClNext; @@ -648,9 +648,9 @@ save_clauses(IOSTREAM *stream, PredEntry *pp) { MegaClause *cl = ClauseCodeToMegaClause(FirstC); UInt size = cl->ClSize; - CHECK(save_uint(stream, (UInt)cl)); - CHECK(save_uint(stream, (UInt)(cl->ClFlags))); - CHECK(save_uint(stream, size)); + CHECK(save_UInt(stream, (UInt)cl)); + CHECK(save_UInt(stream, (UInt)(cl->ClFlags))); + CHECK(save_UInt(stream, size)); CHECK(save_bytes(stream, cl, size)); } else if (pp->PredFlags & DynamicPredFlag) { yamop *cl = FirstC; @@ -659,8 +659,8 @@ save_clauses(IOSTREAM *stream, PredEntry *pp) { DynamicClause *dcl = ClauseCodeToDynamicClause(cl); UInt size = dcl->ClSize; - CHECK(save_uint(stream, (UInt)cl)); - CHECK(save_uint(stream, size)); + CHECK(save_UInt(stream, (UInt)cl)); + CHECK(save_UInt(stream, size)); CHECK(save_bytes(stream, dcl, size)); if (cl == LastC) return 1; cl = NextDynamicClause(cl); @@ -674,8 +674,8 @@ save_clauses(IOSTREAM *stream, PredEntry *pp) { do { UInt size = cl->ClSize; - CHECK(save_uint(stream, (UInt)cl)); - CHECK(save_uint(stream, size)); + CHECK(save_UInt(stream, (UInt)cl)); + CHECK(save_UInt(stream, size)); CHECK(save_bytes(stream, cl, size)); if (cl->ClCode == LastC) return 1; cl = cl->ClNext; @@ -686,14 +686,14 @@ save_clauses(IOSTREAM *stream, PredEntry *pp) { static size_t save_pred(IOSTREAM *stream, PredEntry *ap) { - CHECK(save_uint(stream, (UInt)ap)); - CHECK(save_uint(stream, ap->PredFlags)); + CHECK(save_UInt(stream, (UInt)ap)); + CHECK(save_UInt(stream, ap->PredFlags)); #if SIZEOF_INT_P==4 - CHECK(save_uint(stream, ap->ExtraPredFlags)); + CHECK(save_UInt(stream, ap->ExtraPredFlags)); #endif - CHECK(save_uint(stream, ap->cs.p_code.NOfClauses)); - CHECK(save_uint(stream, ap->src.IndxId)); - CHECK(save_uint(stream, ap->TimeStampOfPred)); + CHECK(save_UInt(stream, ap->cs.p_code.NOfClauses)); + CHECK(save_UInt(stream, ap->src.IndxId)); + CHECK(save_UInt(stream, ap->TimeStampOfPred)); return save_clauses(stream, ap); } @@ -714,6 +714,9 @@ static size_t mark_pred(PredEntry *ap) { CACHE_REGS +#if DEBUG_RESTORE2 + Yap_PrintPredName( ap ); +#endif if (ap->ModuleOfPred != IDB_MODULE) { if (ap->ArityOfPE) { FuncAdjust(ap->FunctorOfPred); @@ -755,8 +758,8 @@ save_ops(IOSTREAM *stream, Term mod) { while (op) { if (!mod || op->OpModule == mod) { CHECK(save_tag(stream, QLY_NEW_OP)); - save_uint(stream, (UInt)op->OpName); - save_uint(stream, (UInt)op->OpModule); + save_UInt(stream, (UInt)op->OpName); + save_UInt(stream, (UInt)op->OpModule); save_bits16(stream, op->Prefix); save_bits16(stream, op->Infix); save_bits16(stream, op->Posfix); @@ -781,7 +784,7 @@ save_module(IOSTREAM *stream, Term mod) { mark_ops(stream, mod); SaveHash(stream); CHECK(save_tag(stream, QLY_START_MODULE)); - CHECK(save_uint(stream, (UInt)mod)); + CHECK(save_UInt(stream, (UInt)mod)); ap = Yap_ModulePred(mod); while (ap) { CHECK(save_tag(stream, QLY_START_PREDICATE)); @@ -831,7 +834,7 @@ save_program(IOSTREAM *stream) { PredEntry *pp; pp = me->PredForME; CHECK(save_tag(stream, QLY_START_MODULE)); - CHECK(save_uint(stream, (UInt)MkAtomTerm(me->AtomOfME))); + CHECK(save_UInt(stream, (UInt)MkAtomTerm(me->AtomOfME))); while (pp != NULL) { CHECK(save_tag(stream, QLY_START_PREDICATE)); CHECK(save_pred(stream, pp)); diff --git a/H/Yapproto.h b/H/Yapproto.h index 28b42d2e7..f6854c44f 100755 --- a/H/Yapproto.h +++ b/H/Yapproto.h @@ -161,6 +161,10 @@ void Yap_InitBackDB(void); void Yap_InitDBPreds(void); /* errors.c */ +#if DEBUG +void +Yap_PrintPredName( struct pred_entry *ap ); +#endif void Yap_RestartYap(int); void Yap_exit(int); yamop *Yap_Error(yap_error_number,Term,char *msg, ...); diff --git a/H/rclause.h b/H/rclause.h index cfb35b8f7..b7061f0ce 100644 --- a/H/rclause.h +++ b/H/rclause.h @@ -2,6 +2,11 @@ /* This file was generated automatically by "yap -L misc/buildops" please do not update */ +//#define DEBUG_RESTORE2 1 +#if DEBUG_RESTORE2 +static volatile yamop *cur_opc; +static volatile op_numbers cur_op; +#endif static void restore_opcodes(yamop *pc, yamop *max USES_REGS) @@ -9,11 +14,18 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS) yamop *opc = NULL; do { op_numbers op; - if (max && pc >= max) return; + if (max && pc >= max) { +#ifdef DEBUG_RESTORE2 + fprintf(stderr, "\n"); +#endif + return; + } op = Yap_op_from_opcode(pc->opc); pc->opc = Yap_opcode(op); #ifdef DEBUG_RESTORE2 - fprintf(stderr, "%s ", Yap_op_names[op]); + cur_op = op; + cur_opc = pc; + fprintf(stderr, "%s\n", Yap_op_names[op]); #endif switch (op) { /* instructions type D */ @@ -239,7 +251,12 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS) case _write_l_list: case _write_list: case _write_void: - if (op == _Nstop || op == _copy_idb_term || op == _unify_idb_term) return; + if (op == _Nstop || op == _copy_idb_term || op == _unify_idb_term){ +#ifdef DEBUG_RESTORE2 + fprintf(stderr, "\n"); +#endif + return; + } pc = NEXTOP(pc,e); break; /* instructions type fa */ @@ -270,7 +287,12 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS) case _try_clause4: case _try_in: pc->y_u.l.l = PtoOpAdjust(pc->y_u.l.l); - if (op == _Ystop) return; + if (op == _Ystop) { +#ifdef DEBUG_RESTORE2 + fprintf(stderr, "\n"); +#endif + return; + } pc = NEXTOP(pc,l); break; /* instructions type llll */ @@ -832,7 +854,12 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS) break; /* instructions type e */ case _getwork_first_time: - if (op == _Nstop || op == _copy_idb_term || op == _unify_idb_term) return; + if (op == _Nstop || op == _copy_idb_term || op == _unify_idb_term) { +#ifdef DEBUG_RESTORE2 + fprintf(stderr, "\n"); +#endif + return; + } pc = NEXTOP(pc,e); break; #endif @@ -863,7 +890,12 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS) #ifdef TABLING_INNER_CUTS case _clause_with_cut: #endif - if (op == _Nstop || op == _copy_idb_term || op == _unify_idb_term) return; + if (op == _Nstop || op == _copy_idb_term || op == _unify_idb_term) { +#ifdef DEBUG_RESTORE2 + fprintf(stderr, "\n"); +#endif + return; + } pc = NEXTOP(pc,e); break; /* instructions type s */ @@ -936,7 +968,12 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS) case _trie_try_val_in_pair: case _trie_try_var: case _trie_try_var_in_pair: - if (op == _Nstop || op == _copy_idb_term || op == _unify_idb_term) return; + if (op == _Nstop || op == _copy_idb_term || op == _unify_idb_term) { +#ifdef DEBUG_RESTORE2 + fprintf(stderr, "\n"); +#endif + return; + } pc = NEXTOP(pc,e); break; #endif @@ -957,4 +994,7 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS) #endif } } while (TRUE); +#ifdef DEBUG_RESTORE2 + fprintf(stderr, "\n"); +#endif } diff --git a/H/rheap.h b/H/rheap.h index 5689c5f63..3abf304ef 100644 --- a/H/rheap.h +++ b/H/rheap.h @@ -1390,7 +1390,7 @@ CleanCode(PredEntry *pp USES_REGS) return; } #ifdef DEBUG_RESTORE2 - fprintf(stderr, "at %ux Correcting clauses from %p to %p\n", *(OPCODE *) FirstC, FirstC, LastC); + fprintf(stderr, "at %lx Correcting clauses from %p to %p\n", *(OPCODE *) FirstC, FirstC, LastC); #endif CleanClauses(FirstC, LastC, pp PASS_REGS); if (flag & IndexedPredFlag) { @@ -1632,9 +1632,9 @@ RestoreAtom(AtomEntry *at USES_REGS) at->PropsOfAE = PropAdjust(at->PropsOfAE); #if DEBUG_RESTORE2 /* useful during debug */ if (IsWideAtom(AbsAtom(at))) - fprintf(errout, "Restoring %S\n", at->WStrOfAE); + fprintf(stderr, "Restoring %S\n", at->WStrOfAE); else - fprintf(errout, "Restoring %s\n", at->StrOfAE); + fprintf(stderr, "Restoring %s\n", at->StrOfAE); #endif RestoreEntries(RepProp(at->PropsOfAE), FALSE PASS_REGS); /* cannot use AtomAdjust without breaking agc */