📄 breakpoint.c
字号:
return;}/* Delete breakpoints and traces. Usage is delete [number ...] */voidcom_delete(wl) wordlist *wl;{ int i; char *s, buf[64]; struct dbcomm *d, *dt; if (wl && eq(wl->wl_word, "all")) { for (dt = dbs; dt; dt = d) { d = dt->db_next; dbfree(dt); } dbs = NULL; return; } else if (!wl) { if (!dbs) { fprintf(cp_err, "Error: no debugs in effect\n"); return; }#ifdef notdef if (dbs->db_type == DB_TRACENODE) wrd_chtrace(dbs->db_nodename1, false, VF_PRINT); else if (dbs->db_type == DB_TRACEALL) wrd_chtrace((char *) NULL, false, VF_PRINT); else if (dbs->db_type == DB_IPLOT) wrd_chtrace(dbs->db_nodename1, false, VF_PLOT); else if (dbs->db_type == DB_IPLOTALL) wrd_chtrace((char *) NULL, false, VF_PLOT); else if (dbs->db_type == DB_SAVE) wrd_chtrace(dbs->db_nodename1, false, VF_ACCUM); else if (dbs->db_type == DB_SAVEALL) wrd_chtrace((char *) NULL, false, VF_ACCUM);#endif dbfree(dbs); } while (wl) {#ifndef IBM for (s = wl->wl_word, i = 0; *s; s++) if (!isdigit(*s)) { fprintf(cp_err, "Error: %s isn't a number.\n", wl->wl_word); goto bad; } else i = i * 10 + (*s - '0');#else i = atoi(wl->wl_next->wl_word); /* etoi ??? */#endif for (d = dbs, dt = NULL; d; d = d->db_next) { if (d->db_number == i) { if (dt) dt->db_next = d->db_next; else dbs = d->db_next; /* Make sure that writedata knows that this * debug has been removed... */#ifdef notdef if (d->db_type == DB_TRACENODE) wrd_chtrace(d->db_nodename1, false, VF_PRINT); else if (d->db_type == DB_TRACEALL) wrd_chtrace((char *) NULL, false, VF_PRINT); else if (d->db_type == DB_IPLOT) wrd_chtrace(d->db_nodename1, false, VF_PLOT); else if (d->db_type == DB_IPLOTALL) wrd_chtrace((char *) NULL, false, VF_PLOT); else if (d->db_type == DB_SAVE) wrd_chtrace(d->db_nodename1, false, VF_ACCUM); else if (d->db_type == DB_SAVEALL) wrd_chtrace((char *) NULL, false, VF_ACCUM);#endif if (dt) dt->db_next = d->db_next; dbfree(d); (void) sprintf(buf, "%d", i); cp_remkword(CT_DBNUMS, buf); break; } dt = d; }bad: wl = wl->wl_next; } return;}/* Writedata calls this routine to see if it should keep going. If it * returns true, then the run should resume. */boolft_bpcheck(runplot, iteration) struct plot *runplot; int iteration;{ struct dbcomm *d, *dt; if ((howmanysteps > 0) && (--howmanysteps == 0)) { if (steps > 1) fprintf(cp_err, "Stopped after %d steps.\n", steps); return (false); } /* Check the debugs set. */ for (d = dbs; d; d = d->db_next) { for (dt = d; dt; dt = dt->db_also) { switch (dt->db_type) { case DB_TRACENODE: case DB_TRACEALL: case DB_IPLOT: case DB_IPLOTALL: case DB_SAVE: case DB_SAVEALL: goto more; case DB_STOPAFTER: if (iteration == dt->db_iteration) break; else goto more; case DB_STOPWHEN: /* See if the condition is true. */ if (satisfied(dt, runplot)) break; else goto more; default: fprintf(cp_err, "ft_bpcheck: Internal Error: bad db %d\n", dt->db_type); } } if (dt == NULL) { /* It made it... */ fprintf(cp_err, "%-2d: condition met: stop ", d->db_number); printcond(d, cp_err); (void) putc('\n', cp_err); return (false); }more: /* Just continue... */ ; } return (true);}/* This is called to determine whether a STOPWHEN is true. */static boolsatisfied(d, plot) struct dbcomm *d; struct plot *plot;{ struct dvec *v1 = NULL, *v2 = NULL; double d1, d2; if (d->db_nodename1) { if ((v1 = vec_fromplot(d->db_nodename1, plot)) == NULL) { fprintf(cp_err, "Error: %s: no such node\n", d->db_nodename1); return (false); } if (isreal(v1)) d1 = v1->v_realdata[v1->v_length - 1]; else d1 = realpart(&(v1->v_compdata[v1->v_length - 1])); } else d1 = d->db_value1; if (d->db_nodename2) { if ((v2 = vec_fromplot(d->db_nodename2, plot)) == NULL) { fprintf(cp_err, "Error: %s: no such node\n", d->db_nodename2); return (false); } if (isreal(v2)) d2 = v2->v_realdata[v2->v_length - 1]; else d2 = realpart(&(v2->v_compdata[v2->v_length - 1])); } else d2 = d->db_value2; switch (d->db_op) { case DBC_EQU: return ((d1 == d2) ? true : false); case DBC_NEQ: return ((d1 != d2) ? true : false); case DBC_GTE: return ((d1 >= d2) ? true : false); case DBC_LTE: return ((d1 <= d2) ? true : false); case DBC_GT: return ((d1 > d2) ? true : false); case DBC_LT: return ((d1 < d2) ? true : false); default: fprintf(cp_err, "satisfied: Internal Error: bad cond %d\n", d->db_op); return (false); }}/* Writedata calls this before it starts a run, to set the proper flags * on the dvecs. If a change is made during a break, then the routine * wrd_chtrace is used from these routines. We have to be clever with save: * if there was no save given, then save everything. Unfortunately you * can't stop in the middle, do a save, and have the rest then discarded. */voidft_trquery(){#ifdef notdef struct dbcomm *d; bool saved = false; for (d = dbs; d; d = d->db_next) if (d->db_type == DB_TRACENODE) wrd_chtrace(d->db_nodename1, true, VF_PRINT); else if (d->db_type == DB_TRACEALL) wrd_chtrace((char *) NULL, true, VF_PRINT); else if (d->db_type == DB_IPLOT) wrd_chtrace(d->db_nodename1, true, VF_PLOT); else if (d->db_type == DB_IPLOTALL) wrd_chtrace((char *) NULL, true, VF_PLOT); else if (d->db_type == DB_SAVE) { wrd_chtrace(d->db_nodename1, true, VF_ACCUM); saved = true; } else if (d->db_type == DB_SAVEALL) { wrd_chtrace((char *) NULL, true, VF_ACCUM); saved = true; } if (saved == false) wrd_chtrace((char *) NULL, true, VF_ACCUM);#endif return;}intft_getSaves(savesp) char ***savesp;{ struct dbcomm *d; int count = 0, i = 0; char **array; for (d = dbs; d; d = d->db_next) if (d->db_type == DB_SAVE) count++; if (!count) return (0); *savesp = array = (char **) tmalloc(sizeof (char *) * count); for (d = dbs; d; d = d->db_next) if (d->db_type == DB_SAVE) array[i++] = copy(d->db_nodename1); return (count);}static voidprintcond(d, fp) struct dbcomm *d; FILE *fp;{ struct dbcomm *dt; for (dt = d; dt; dt = dt->db_also) { if (dt->db_type == DB_STOPAFTER) fprintf(fp, " after %ld", dt->db_iteration); else { if (dt->db_nodename1) fprintf(fp, " when %s", dt->db_nodename1); else fprintf(fp, " when %lg", dt->db_value1); switch (dt->db_op) { case DBC_EQU: fputs(" =", fp); break; case DBC_NEQ: fputs(" <>", fp); break; case DBC_GT: fputs(" >", fp); break; case DBC_LT: fputs(" <", fp); break; case DBC_GTE: fputs(" >=", fp); break; case DBC_LTE: fputs(" <=", fp); break; default: fprintf(cp_err, "printcond: Internal Error: bad cond %d", dt->db_op); } if (dt->db_nodename2) fprintf(fp, " %s", dt->db_nodename2); else fprintf(fp, " %lg", dt->db_value2); } } return;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -