From d8ccb42440d286475db41c83ed9f83a8fb54bf8f Mon Sep 17 00:00:00 2001 From: vsc Date: Thu, 20 Apr 2006 17:29:46 +0000 Subject: [PATCH] fix current_thread to make sure it uses the integer ID even with aliases. git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1604 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- C/tracer.c | 63 +++++++++++++++++++++++++++++++++--------------- changes-5.1.html | 2 ++ pl/threads.yap | 8 +++--- 3 files changed, 49 insertions(+), 24 deletions(-) diff --git a/C/tracer.c b/C/tracer.c index 97a35195b..ef7669ce5 100644 --- a/C/tracer.c +++ b/C/tracer.c @@ -133,8 +133,8 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args) char *mname; Int arity; /* extern int gc_calls; */ - static PredEntry *pe; + LOCK(Yap_heap_regs->low_level_trace_lock); sc = Yap_heap_regs; vsc_count++; #ifdef COMMENTED @@ -147,51 +147,72 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args) if (port != enter_pred || !pred || pred->ArityOfPE != 4 || - strcmp(RepAtom(NameOfFunctor(pred->FunctorOfPred))->StrOfAE,"in_between_target_phrases")) + strcmp(RepAtom(NameOfFunctor(pred->FunctorOfPred))->StrOfAE,"in_between_target_phrases")) { + UNLOCK(Yap_heap_regs->low_level_trace_lock); return; - if (vsc_count < 1246949400LL) + } + if (vsc_count < 1246949400LL) { + UNLOCK(Yap_heap_regs->low_level_trace_lock); return; + } if (vsc_count == 1246949493LL) vsc_xstop = TRUE; - if (vsc_count < 5646100000LL) + if (vsc_count < 5646100000LL) { + UNLOCK(Yap_heap_regs->low_level_trace_lock); return; + } if (vsc_count == 5646100441LL) vsc_xstop = TRUE; if (vsc_count < 2923351500LL) { + UNLOCK(Yap_heap_regs->low_level_trace_lock); return; } if (vsc_count == 123536441LL) vsc_xstop = 1; if (vsc_count < 5530257LL) { + UNLOCK(Yap_heap_regs->low_level_trace_lock); return; } if (vsc_count == 9414280LL) { vsc_xstop = TRUE; } if (vsc_count < 3399741LL) { + UNLOCK(Yap_heap_regs->low_level_trace_lock); return; } if (vsc_count == 51021) { printf("Here I go\n"); } - if (vsc_count < 52000) return; + if (vsc_count < 52000) { + UNLOCK(Yap_heap_regs->low_level_trace_lock); + return; + } if (vsc_count > 52000) exit(0); + UNLOCK(Yap_heap_regs->low_level_trace_lock); return; if (vsc_count == 837074) { printf("Here I go\n"); } - if (gc_calls < 1) return; - { - CELL *env_ptr = ENV; - PredEntry *p; - while (env_ptr) { - PredEntry *pe = EnvPreg(env_ptr[E_CP]); - printf("%p->",env_ptr,pe); - if (vsc_count == 52LL) printf("\n"); - if (p == pe) return(TRUE); - if (env_ptr != NULL) - env_ptr = (CELL *)(env_ptr[E_E]); + if (gc_calls < 1) { + UNLOCK(Yap_heap_regs->low_level_trace_lock); + return; + } + { + CELL *env_ptr = ENV; + PredEntry *p; + + while (env_ptr) { + PredEntry *pe = EnvPreg(env_ptr[E_CP]); + + printf("%p->",env_ptr,pe); + if (vsc_count == 52LL) printf("\n"); + if (p == pe) { + UNLOCK(Yap_heap_regs->low_level_trace_lock); + return; } - printf("\n"); + if (env_ptr != NULL) + env_ptr = (CELL *)(env_ptr[E_E]); + } + printf("\n"); } #endif fprintf(Yap_stderr,"%lld %x ", vsc_count,ActiveSignals); @@ -199,10 +220,14 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args) fprintf(Yap_stderr,"(%d)", worker_id); #endif /* check_trail_consistency(); */ - if (pred == NULL) + if (pred == NULL) { + UNLOCK(Yap_heap_regs->low_level_trace_lock); return; - if (pred->ModuleOfPred == 0 && !do_trace_primitives) + } + if (pred->ModuleOfPred == 0 && !do_trace_primitives) { + UNLOCK(Yap_heap_regs->low_level_trace_lock); return; + } switch (port) { case enter_pred: mname = RepAtom(AtomOfTerm(Yap_Module_Name(pred)))->StrOfAE; diff --git a/changes-5.1.html b/changes-5.1.html index 8747f12a3..eaf640d60 100644 --- a/changes-5.1.html +++ b/changes-5.1.html @@ -16,6 +16,8 @@

Yap-5.1.2:

diff --git a/pl/threads.yap b/pl/threads.yap index c9d2b29a8..7070ccc7a 100644 --- a/pl/threads.yap +++ b/pl/threads.yap @@ -55,8 +55,8 @@ thread_create(Goal, Id, Options) :- '$check_callable'(Goal,G0), '$thread_options'(Options, Aliases, Stack, Trail, System, Detached, G0), '$thread_new_tid'(Id), - '$add_thread_aliases'(Aliases, Id), '$clean_db_on_id'(Id), + '$add_thread_aliases'(Aliases, Id), '$create_mq'(Id), '$create_thread'(Goal, Stack, Trail, System, Detached, Id). @@ -163,12 +163,10 @@ current_thread(Tid, Status) :- var(Tid), !, '$cur_threads'(0, Tid, Status). current_thread(Tid, Status) :- - '$check_thread_alias'(Id0,Tid), !, + '$check_thread_alias'(Id0,Tid), + integer(Id0), !, '$valid_thread'(Id0), '$thr_status'(Id0, Status). -current_thread(Tid, Status) :- integer(Tid), !, - '$valid_thread'(Tid), - '$thr_status'(Tid, Status). current_thread(Tid, Status) :- '$do_error'(type_error(integer,Tid),current_thread(Tid, Status)).