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
This commit is contained in:
vsc 2006-04-20 17:29:46 +00:00
parent 5198ba1077
commit d8ccb42440
3 changed files with 49 additions and 24 deletions

View File

@ -133,8 +133,8 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
char *mname; char *mname;
Int arity; Int arity;
/* extern int gc_calls; */ /* extern int gc_calls; */
static PredEntry *pe;
LOCK(Yap_heap_regs->low_level_trace_lock);
sc = Yap_heap_regs; sc = Yap_heap_regs;
vsc_count++; vsc_count++;
#ifdef COMMENTED #ifdef COMMENTED
@ -147,51 +147,72 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
if (port != enter_pred || if (port != enter_pred ||
!pred || !pred ||
pred->ArityOfPE != 4 || 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; return;
if (vsc_count < 1246949400LL) }
if (vsc_count < 1246949400LL) {
UNLOCK(Yap_heap_regs->low_level_trace_lock);
return; return;
}
if (vsc_count == 1246949493LL) if (vsc_count == 1246949493LL)
vsc_xstop = TRUE; vsc_xstop = TRUE;
if (vsc_count < 5646100000LL) if (vsc_count < 5646100000LL) {
UNLOCK(Yap_heap_regs->low_level_trace_lock);
return; return;
}
if (vsc_count == 5646100441LL) if (vsc_count == 5646100441LL)
vsc_xstop = TRUE; vsc_xstop = TRUE;
if (vsc_count < 2923351500LL) { if (vsc_count < 2923351500LL) {
UNLOCK(Yap_heap_regs->low_level_trace_lock);
return; return;
} }
if (vsc_count == 123536441LL) vsc_xstop = 1; if (vsc_count == 123536441LL) vsc_xstop = 1;
if (vsc_count < 5530257LL) { if (vsc_count < 5530257LL) {
UNLOCK(Yap_heap_regs->low_level_trace_lock);
return; return;
} }
if (vsc_count == 9414280LL) { if (vsc_count == 9414280LL) {
vsc_xstop = TRUE; vsc_xstop = TRUE;
} }
if (vsc_count < 3399741LL) { if (vsc_count < 3399741LL) {
UNLOCK(Yap_heap_regs->low_level_trace_lock);
return; return;
} }
if (vsc_count == 51021) { if (vsc_count == 51021) {
printf("Here I go\n"); 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); if (vsc_count > 52000) exit(0);
UNLOCK(Yap_heap_regs->low_level_trace_lock);
return; return;
if (vsc_count == 837074) { if (vsc_count == 837074) {
printf("Here I go\n"); printf("Here I go\n");
} }
if (gc_calls < 1) return; if (gc_calls < 1) {
{ UNLOCK(Yap_heap_regs->low_level_trace_lock);
CELL *env_ptr = ENV; return;
PredEntry *p; }
while (env_ptr) { {
PredEntry *pe = EnvPreg(env_ptr[E_CP]); CELL *env_ptr = ENV;
printf("%p->",env_ptr,pe); PredEntry *p;
if (vsc_count == 52LL) printf("\n");
if (p == pe) return(TRUE); while (env_ptr) {
if (env_ptr != NULL) PredEntry *pe = EnvPreg(env_ptr[E_CP]);
env_ptr = (CELL *)(env_ptr[E_E]);
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 #endif
fprintf(Yap_stderr,"%lld %x ", vsc_count,ActiveSignals); 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); fprintf(Yap_stderr,"(%d)", worker_id);
#endif #endif
/* check_trail_consistency(); */ /* check_trail_consistency(); */
if (pred == NULL) if (pred == NULL) {
UNLOCK(Yap_heap_regs->low_level_trace_lock);
return; return;
if (pred->ModuleOfPred == 0 && !do_trace_primitives) }
if (pred->ModuleOfPred == 0 && !do_trace_primitives) {
UNLOCK(Yap_heap_regs->low_level_trace_lock);
return; return;
}
switch (port) { switch (port) {
case enter_pred: case enter_pred:
mname = RepAtom(AtomOfTerm(Yap_Module_Name(pred)))->StrOfAE; mname = RepAtom(AtomOfTerm(Yap_Module_Name(pred)))->StrOfAE;

View File

@ -16,6 +16,8 @@
<h2>Yap-5.1.2:</h2> <h2>Yap-5.1.2:</h2>
<ul> <ul>
<li> FIXED: thread aliases were being cleaned up just after being
installed (obs Paulo Moura).</li>
<li> FIXED: rb_partial_map was broken.</li> <li> FIXED: rb_partial_map was broken.</li>
<li> NEW: wdgraph and wundgraph libraries, for weighted graphs.</li> <li> NEW: wdgraph and wundgraph libraries, for weighted graphs.</li>
</ul> </ul>

View File

@ -55,8 +55,8 @@ thread_create(Goal, Id, Options) :-
'$check_callable'(Goal,G0), '$check_callable'(Goal,G0),
'$thread_options'(Options, Aliases, Stack, Trail, System, Detached, G0), '$thread_options'(Options, Aliases, Stack, Trail, System, Detached, G0),
'$thread_new_tid'(Id), '$thread_new_tid'(Id),
'$add_thread_aliases'(Aliases, Id),
'$clean_db_on_id'(Id), '$clean_db_on_id'(Id),
'$add_thread_aliases'(Aliases, Id),
'$create_mq'(Id), '$create_mq'(Id),
'$create_thread'(Goal, Stack, Trail, System, Detached, Id). '$create_thread'(Goal, Stack, Trail, System, Detached, Id).
@ -163,12 +163,10 @@ current_thread(Tid, Status) :-
var(Tid), !, var(Tid), !,
'$cur_threads'(0, Tid, Status). '$cur_threads'(0, Tid, Status).
current_thread(Tid, Status) :- current_thread(Tid, Status) :-
'$check_thread_alias'(Id0,Tid), !, '$check_thread_alias'(Id0,Tid),
integer(Id0), !,
'$valid_thread'(Id0), '$valid_thread'(Id0),
'$thr_status'(Id0, Status). '$thr_status'(Id0, Status).
current_thread(Tid, Status) :- integer(Tid), !,
'$valid_thread'(Tid),
'$thr_status'(Tid, Status).
current_thread(Tid, Status) :- current_thread(Tid, Status) :-
'$do_error'(type_error(integer,Tid),current_thread(Tid, Status)). '$do_error'(type_error(integer,Tid),current_thread(Tid, Status)).