📄 breakpoint.c
字号:
/* RCS Info: $Revision: 1.1 $ on $Date: 91/04/02 12:10:56 $ * $Source: //pepper/atesse_spice/spice3/FTE/RCS/breakpoint.c,v $ * Copyright (c) 1985 Wayne A. Christopher, U. C. Berkeley CAD Group * * Stuff to deal with breakpoints and tracing. */#include "prefix.h"#include "CPdefs.h"#include "FTEdefs.h"#include "FTEdata.h"#include "FTEdebug.h"#include "suffix.h"static bool satisfied();static void dbfree();static void printcond();static void settrace();struct dbcomm *dbs = NULL; /* export for iplot */static int debugnumber = 1;static int howmanysteps = 0;static int steps = 0;/* Set a breakpoint. Possible commands are: * stop after n * stop when var cond val * * If more than one is given on a command line, then this is a conjunction. */voidcom_stop(wl) wordlist *wl;{ struct dbcomm *d, *thisone = NULL; char *s, buf[64]; int i; double *val; while (wl) { if (thisone == NULL) thisone = d = alloc(dbcomm); else { d->db_also = alloc(dbcomm); d = d->db_also; } /* Figure out what the first condition is. */ if (eq(wl->wl_word, "after") && wl->wl_next) { d->db_type = DB_STOPAFTER; d->db_number = debugnumber;#ifndef IBM for (s = wl->wl_next->wl_word, i = 0; *s; s++) if (!isdigit(*s)) goto bad; else i = i * 10 + (*s - '0');#else i = atoi(wl->wl_next->wl_word); /* etoi ??? */#endif d->db_iteration = i; wl = wl->wl_next->wl_next; } else if (eq(wl->wl_word, "when") && wl->wl_next && wl->wl_next->wl_next && /* ick... */ wl->wl_next->wl_next->wl_next) { wl = wl->wl_next; d->db_number = debugnumber; d->db_type = DB_STOPWHEN; s = wl->wl_word; val = ft_numparse(&s, false); if (val) d->db_value1 = *val; else d->db_nodename1 = copy(wl->wl_word); wl = wl->wl_next; /* Now get the condition... */ if (eq(wl->wl_word, "eq") || eq(wl->wl_word, "=")) d->db_op = DBC_EQU; else if (eq(wl->wl_word, "ne") || eq(wl->wl_word, "<>")) d->db_op = DBC_NEQ; else if (eq(wl->wl_word, "gt") || eq(wl->wl_word, ">")) d->db_op = DBC_GT; else if (eq(wl->wl_word, "lt") || eq(wl->wl_word, "<")) d->db_op = DBC_LT; else if (eq(wl->wl_word, "ge") || eq(wl->wl_word, ">=")) d->db_op = DBC_GTE; else if (eq(wl->wl_word, "le") || eq(wl->wl_word, "<=")) d->db_op = DBC_LTE; else goto bad; wl = wl->wl_next; /* Now see about the second one. */ s = wl->wl_word; val = ft_numparse(&s, false); if (val) d->db_value2 = *val; else d->db_nodename2 = copy(wl->wl_word); wl = wl->wl_next; } else goto bad; } if (thisone) { if (dbs) { for (d = dbs; d->db_next; d = d->db_next); d->db_next = thisone; } else dbs = thisone; (void) sprintf(buf, "%d", debugnumber); cp_addkword(CT_DBNUMS, buf); debugnumber++; } return;bad: fprintf(cp_err, "Syntax error.\n"); return;}/* Trace a node (have wrd_point print it). Usage is trace node ... */voidcom_trce(wl) wordlist *wl;{ settrace(wl, VF_PRINT); return;}/* Incrementally plot a value. This is just like trace. */voidcom_iplot(wl) wordlist *wl;{ /* settrace(wl, VF_PLOT); */ struct dbcomm *d, *td, *currentdb = NULL; char *s; /* We use a modified ad-hoc algorithm here where db_also denotes vectors on the same command line and db_next denotes separate iplot commands. */ while (wl) { s = cp_unquote(wl->wl_word); d = alloc(dbcomm); d->db_number = debugnumber++; if (eq(s, "all")) { d->db_type = DB_IPLOTALL; } else { d->db_type = DB_IPLOT; d->db_nodename1 = copy(s); } d->db_also = currentdb; currentdb = d; wl = wl->wl_next; } if (dbs) { for (td = dbs; td->db_next; td = td->db_next) ; td->db_next = currentdb; } else dbs = currentdb; return;}/* Save a vector. */voidcom_save(wl) wordlist *wl;{ settrace(wl, VF_ACCUM); return;}static voidsettrace(wl, what) wordlist *wl;{ struct dbcomm *d, *td; char *s; while (wl) { s = cp_unquote(wl->wl_word); d = alloc(dbcomm); d->db_number = debugnumber++; if (eq(s, "all")) { switch (what) { case VF_PRINT: d->db_type = DB_TRACEALL; break;/* case VF_PLOT: d->db_type = DB_IPLOTALL; break; */ case VF_ACCUM: d->db_type = DB_SAVEALL; break; }/* wrd_chtrace((char *) NULL, true, what); */ } else { switch (what) { case VF_PRINT: d->db_type = DB_TRACENODE; break;/* case VF_PLOT: d->db_type = DB_IPLOT; break; */ case VF_ACCUM: d->db_type = DB_SAVE; break; } d->db_nodename1 = copy(s);/* wrd_chtrace(s, true, what); */ } if (dbs) { for (td = dbs; td->db_next; td = td->db_next) ; td->db_next = d; } else dbs = d; wl = wl->wl_next; } return;}/* Step a number of iterations. */voidcom_step(wl) wordlist *wl;{ if (wl) steps = howmanysteps = atoi(wl->wl_word); else steps = howmanysteps = 1; com_resume((wordlist *) NULL); return;}/* Print out the currently active breakpoints and traces. If we are printing * to a file, assume that the file will be used for a later source and leave * off the event numbers (with UNIX, that is). -- I don't like this... */#define isatty(xxxx) 1/* ARGSUSED */voidcom_sttus(wl) wordlist *wl;{ struct dbcomm *d, *dc; for (d = dbs; d; d = d->db_next) { if (d->db_type == DB_TRACENODE) { if (isatty(fileno(cp_out))) fprintf(cp_out, "%-4d trace %s", d->db_number, d->db_nodename1); else fprintf(cp_out, "trace %s", d->db_nodename1); } else if (d->db_type == DB_IPLOT) { if (isatty(fileno(cp_out))) { fprintf(cp_out, "%-4d iplot %s", d->db_number, d->db_nodename1); } else { fprintf(cp_out, "iplot %s", d->db_nodename1); } for (dc = d->db_also; dc; dc = dc->db_also) { fprintf(cp_out, " %s", dc->db_nodename1); } } else if (d->db_type == DB_SAVE) { if (isatty(fileno(cp_out))) fprintf(cp_out, "%-4d save %s", d->db_number, d->db_nodename1); else fprintf(cp_out, "save %s", d->db_nodename1); } else if (d->db_type == DB_TRACEALL) { if (isatty(fileno(cp_out))) fprintf(cp_out, "%-4d trace all", d->db_number); else fprintf(cp_out, "trace all"); } else if (d->db_type == DB_IPLOTALL) { if (isatty(fileno(cp_out))) fprintf(cp_out, "%-4d iplot all", d->db_number); else fprintf(cp_out, "iplot all"); } else if (d->db_type == DB_SAVEALL) { if (isatty(fileno(cp_out))) fprintf(cp_out, "%-4d save all", d->db_number); else fprintf(cp_out, "save all"); } else if ((d->db_type == DB_STOPAFTER) || (d->db_type == DB_STOPWHEN)) { if (isatty(fileno(cp_out))) fprintf(cp_out, "%-4d stop", d->db_number); else fprintf(cp_out, "stop"); printcond(d, cp_out); } else fprintf(cp_err, "com_sttus: Internal Error: bad db %d...\n", d->db_type); (void) putc('\n', cp_out); } return;}static voiddbfree(db) struct dbcomm *db;{ struct dbcomm *dd, *dn; if (db == dbs) dbs = dbs->db_next; for (dd = db; dd; dd = dn) { dn = dd->db_also; tfree(dd->db_nodename1); tfree(dd->db_nodename2); tfree(dd); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -