fix warning

This commit is contained in:
Vítor Santos Costa 2015-10-09 19:05:36 +01:00
parent f10a329f9f
commit a66f5f0531
4 changed files with 15 additions and 38 deletions

View File

@ -403,10 +403,8 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno,
Yap_exit(1);
}
if (LOCAL_PrologMode == BootMode) {
Yap_detect_bug_location(P, FIND_PRED_FROM_ANYWHERE, (char *)HR, 256);
fprintf(stderr, "%%\n%% PC: %s\n", (char *)HR);
Yap_detect_bug_location(CP, FIND_PRED_FROM_ANYWHERE, (char *)HR, 256);
fprintf(stderr, "%% Continuation: %s\n", (char *)HR);
Yap_detect_bug_location(P, FIND_PRED_FROM_ANYWHERE, 256);
Yap_detect_bug_location(CP, FIND_PRED_FROM_ANYWHERE, 256);
error_exit_yap(1);
}
va_start(ap, where);
@ -471,7 +469,7 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno,
if (LOCAL_PrologMode & BootMode) {
fprintf(stderr, "%% YAP crashed while booting %s\n", tmpbuf);
} else {
Yap_detect_bug_location(P, FIND_PRED_FROM_ANYWHERE, tmpbuf, YAP_BUF_SIZE);
Yap_detect_bug_location(P, FIND_PRED_FROM_ANYWHERE, YAP_BUF_SIZE);
fprintf(stderr, "%% Bug found while executing %s\n", tmpbuf);
}
error_exit_yap(1);

View File

@ -1661,9 +1661,10 @@ void Yap_dump_stack(void) {
}
#endif
#endif
Yap_detect_bug_location(P, FIND_PRED_FROM_ANYWHERE, (char *)HR, 256);
Yap_detect_bug_location(P, FIND_PRED_FROM_ANYWHERE
, 256);
fprintf(stderr, "%%\n%% PC: %s\n", (char *)HR);
Yap_detect_bug_location(CP, FIND_PRED_FROM_ANYWHERE, (char *)HR, 256);
Yap_detect_bug_location(CP, FIND_PRED_FROM_ANYWHERE, 256);
fprintf(stderr, "%% Continuation: %s\n", (char *)HR);
fprintf(stderr, "%% %luKB of Global Stack (%p--%p)\n",
(unsigned long int)(sizeof(CELL) * (HR - H0)) / 1024, H0, HR);
@ -1692,7 +1693,7 @@ void Yap_dump_stack(void) {
"Use--Local In Use)\n%%\n");
while (b_ptr != NULL) {
while (env_ptr && env_ptr <= (CELL *)b_ptr) {
Yap_detect_bug_location(ipc, FIND_PRED_FROM_ENV, tp, 256);
Yap_detect_bug_location(ipc, FIND_PRED_FROM_ENV, 256);
if (env_ptr == (CELL *)b_ptr && (choiceptr)env_ptr[E_CB] > b_ptr) {
b_ptr = b_ptr->cp_b;
fprintf(stderr, "%% %s\n", tp);
@ -1716,7 +1717,7 @@ void Yap_dump_stack(void) {
b_ptr->cp_ap->opc != Yap_opcode(_or_last) &&
b_ptr->cp_ap->opc != Yap_opcode(_Nstop)) {
/* we can safely ignore ; because there is always an upper env */
Yap_detect_bug_location(b_ptr->cp_ap, FIND_PRED_FROM_CP, tp, 256);
Yap_detect_bug_location(b_ptr->cp_ap, FIND_PRED_FROM_CP, 256);
fprintf(stderr, "%% %s (%luKB--%luKB)\n", tp,
(unsigned long int)((b_ptr->cp_h - H0) * sizeof(CELL) / 1024),
(unsigned long int)((ADDR)LCL0 - (ADDR)b_ptr) / 1024);
@ -1850,51 +1851,28 @@ void DumpActiveGoals(USES_REGS1) {
}
}
void Yap_detect_bug_location(yamop *yap_pc, int where_from, char *tp,
void Yap_detect_bug_location(yamop *yap_pc, int where_from,
int psize) {
Atom pred_name;
UInt pred_arity;
Term pred_module;
Int cl;
tp[0] = '\0';
if ((cl = Yap_PredForCode(yap_pc, where_from, &pred_name, &pred_arity,
&pred_module)) == 0) {
/* system predicate */
#if HAVE_SNPRINTF
snprintf(tp, psize, "%s", "meta-call");
#else
sprintf(tp, "%s", "meta-call");
#endif
fprintf(stderr, "%s", "meta-call");
} else if (pred_module == 0) {
/* don't give info on system predicates */
#if HAVE_SNPRINTF
snprintf(tp, psize, "prolog:%s/%lu", RepAtom(pred_name)->StrOfAE,
(unsigned long int)pred_arity);
#else
sprintf(tp, "in prolog:%s/%lu", RepAtom(pred_name)->StrOfAE,
fprintf(stderr, "in prolog:%s/%lu", RepAtom(pred_name)->StrOfAE,
(unsigned long int)pred_arity);
#endif
} else if (cl < 0) {
#if HAVE_SNPRINTF
snprintf(tp, psize, "%s:%s/%lu", RepAtom(AtomOfTerm(pred_module))->StrOfAE,
RepAtom(pred_name)->StrOfAE, (unsigned long int)pred_arity);
#else
sprintf(tp, "%s:%s/%lu", RepAtom(AtomOfTerm(pred_module))->StrOfAE,
fprintf(stderr, "%s:%s/%lu", RepAtom(AtomOfTerm(pred_module))->StrOfAE,
RepAtom(pred_name)->StrOfAE, (unsigned long int)pred_arity);
#endif
} else {
#if HAVE_SNPRINTF
snprintf(tp, psize, "%s:%s/%lu at clause %lu ",
RepAtom(AtomOfTerm(pred_module))->StrOfAE,
RepAtom(pred_name)->StrOfAE, (unsigned long int)pred_arity,
(unsigned long int)cl);
#else
sprintf(tp, "%s:%s/%lu at clause %lu",
fprintf(stderr, "%s:%s/%lu at clause %lu",
RepAtom(AtomOfTerm(pred_module))->StrOfAE,
RepAtom(pred_name)->StrOfAE, (unsigned long int)pred_arity,
(unsigned long int)cl);
#endif
}
}

View File

@ -3171,6 +3171,7 @@
PREG = NEXTOP(PREG, yx);
GONext();
derefa_body(d0, pt0, punsafe_unk, punsafe_nonvar);
/* d0 is a variable, check whether we need to globalise it */
if (pt0 <= HR || pt0 >= YREG) {

View File

@ -365,7 +365,7 @@ void Yap_InitSortPreds(void);
/* stack.c */
void Yap_InitStInfo(void);
void Yap_dump_stack( void );
void Yap_detect_bug_location(yamop *yap_pc, int where_from, char *tp, int psize);
void Yap_detect_bug_location(yamop *yap_pc, int where_from, int psize);
#if !defined(YAPOR) && !defined(THREADS)
bool Yap_search_for_static_predicate_in_use(struct pred_entry *, bool);