|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1983 The Regents of the University of California. ! 3: * All rights reserved. ! 4: * ! 5: * Redistribution and use in source and binary forms are permitted ! 6: * provided that: (1) source distributions retain this entire copyright ! 7: * notice and comment, and (2) distributions including binaries display ! 8: * the following acknowledgement: ``This product includes software ! 9: * developed by the University of California, Berkeley and its contributors'' ! 10: * in the documentation or other materials provided with the distribution ! 11: * and in all advertising materials mentioning features or use of this ! 12: * software. Neither the name of the University nor the names of its ! 13: * contributors may be used to endorse or promote products derived ! 14: * from this software without specific prior written permission. ! 15: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR ! 16: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED ! 17: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 18: */ ! 19: ! 20: #ifndef lint ! 21: static char sccsid[] = "@(#)debug.c 5.3 (Berkeley) 6/1/90"; ! 22: #endif /* not lint */ ! 23: ! 24: /* ! 25: * Debug routines ! 26: */ ! 27: ! 28: #include "defs.h" ! 29: #include "tree.h" ! 30: #include "operators.h" ! 31: #include "eval.h" ! 32: #include "events.h" ! 33: #include "symbols.h" ! 34: #include "scanner.h" ! 35: #include "source.h" ! 36: #include "object.h" ! 37: #include "main.h" ! 38: #include "mappings.h" ! 39: #include "process.h" ! 40: #include "machine.h" ! 41: #include "debug.h" ! 42: #include <signal.h> ! 43: ! 44: public boolean tracetree; /* trace building of parse trees */ ! 45: public boolean traceeval; /* trace tree evaluation */ ! 46: ! 47: /* ! 48: * Dynamically turn on/off a debug flag, or display some information. ! 49: */ ! 50: ! 51: public debug (p) ! 52: Node p; ! 53: { ! 54: int code; ! 55: ! 56: code = p->value.lcon; ! 57: switch (code) { ! 58: case 0: ! 59: puts("debugging flags:"); ! 60: puts(" 1 trace scanner return values"); ! 61: puts(" 2 trace breakpoints"); ! 62: puts(" 3 trace execution"); ! 63: puts(" 4 trace tree building"); ! 64: puts(" 5 trace tree evaluation"); ! 65: puts(" -[12345] turns off corresponding flag"); ! 66: puts(" 6 dump function table"); ! 67: break; ! 68: ! 69: case 1: ! 70: case -1: ! 71: # ifdef LEXDEBUG ! 72: lexdebug = (boolean) (code > 0); ! 73: # else ! 74: error("can't debug scanner (not compiled with LEXDEBUG)"); ! 75: # endif ! 76: break; ! 77: ! 78: case 2: ! 79: case -2: ! 80: tracebpts = (boolean) (code > 0); ! 81: break; ! 82: ! 83: case 3: ! 84: case -3: ! 85: traceexec = (boolean) (code > 0); ! 86: break; ! 87: ! 88: case 4: ! 89: case -4: ! 90: tracetree = (boolean) (code > 0); ! 91: break; ! 92: ! 93: case 5: ! 94: case -5: ! 95: traceeval = (boolean) (code > 0); ! 96: break; ! 97: ! 98: case 6: ! 99: dumpfunctab(); ! 100: break; ! 101: ! 102: default: ! 103: error("unknown debug flag"); ! 104: break; ! 105: } ! 106: } ! 107: ! 108: private String leafname[] = { ! 109: "nop", "name", "sym", "lcon", "fcon", "scon", "rval", "index" ! 110: }; ! 111: ! 112: public String opname (op) ! 113: Operator op; ! 114: { ! 115: String s; ! 116: static char buf[100]; ! 117: ! 118: switch (op) { ! 119: case O_ITOF: ! 120: s = "itof"; ! 121: break; ! 122: ! 123: case O_ENDX: ! 124: s = "endx"; ! 125: break; ! 126: ! 127: case O_QLINE: ! 128: s = "qline"; ! 129: break; ! 130: ! 131: default: ! 132: if (ord(op) <= ord(O_INDEX)) { ! 133: s = leafname[ord(op)]; ! 134: } else { ! 135: s = opinfo[ord(op)].opstring; ! 136: if (s == nil) { ! 137: sprintf(buf, "[op %d]", op); ! 138: s = buf; ! 139: } ! 140: } ! 141: break; ! 142: } ! 143: return s; ! 144: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.