|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1983 Regents of the University of California. ! 3: * All rights reserved. The Berkeley software License Agreement ! 4: * specifies the terms and conditions for redistribution. ! 5: */ ! 6: ! 7: #ifndef lint ! 8: static char sccsid[] = "@(#)debug.c 5.1 (Berkeley) 5/31/85"; ! 9: #endif not lint ! 10: ! 11: static char rcsid[] = "$Header: debug.c,v 1.5 84/12/26 10:39:01 linton Exp $"; ! 12: ! 13: /* ! 14: * Debug routines ! 15: */ ! 16: ! 17: #include "defs.h" ! 18: #include "tree.h" ! 19: #include "operators.h" ! 20: #include "eval.h" ! 21: #include "events.h" ! 22: #include "symbols.h" ! 23: #include "scanner.h" ! 24: #include "source.h" ! 25: #include "object.h" ! 26: #include "main.h" ! 27: #include "mappings.h" ! 28: #include "process.h" ! 29: #include "machine.h" ! 30: #include "debug.h" ! 31: #include <signal.h> ! 32: ! 33: public boolean tracetree; /* trace building of parse trees */ ! 34: public boolean traceeval; /* trace tree evaluation */ ! 35: ! 36: /* ! 37: * Dynamically turn on/off a debug flag, or display some information. ! 38: */ ! 39: ! 40: public debug (p) ! 41: Node p; ! 42: { ! 43: int code; ! 44: ! 45: code = p->value.lcon; ! 46: switch (code) { ! 47: case 0: ! 48: puts("debugging flags:"); ! 49: puts(" 1 trace scanner return values"); ! 50: puts(" 2 trace breakpoints"); ! 51: puts(" 3 trace execution"); ! 52: puts(" 4 trace tree building"); ! 53: puts(" 5 trace tree evaluation"); ! 54: puts(" -[12345] turns off corresponding flag"); ! 55: puts(" 6 dump function table"); ! 56: break; ! 57: ! 58: case 1: ! 59: case -1: ! 60: # ifdef LEXDEBUG ! 61: lexdebug = (boolean) (code > 0); ! 62: # else ! 63: error("can't debug scanner (not compiled with LEXDEBUG)"); ! 64: # endif ! 65: break; ! 66: ! 67: case 2: ! 68: case -2: ! 69: tracebpts = (boolean) (code > 0); ! 70: break; ! 71: ! 72: case 3: ! 73: case -3: ! 74: traceexec = (boolean) (code > 0); ! 75: break; ! 76: ! 77: case 4: ! 78: case -4: ! 79: tracetree = (boolean) (code > 0); ! 80: break; ! 81: ! 82: case 5: ! 83: case -5: ! 84: traceeval = (boolean) (code > 0); ! 85: break; ! 86: ! 87: case 6: ! 88: dumpfunctab(); ! 89: break; ! 90: ! 91: default: ! 92: error("unknown debug flag"); ! 93: break; ! 94: } ! 95: } ! 96: ! 97: private String leafname[] = { ! 98: "nop", "name", "sym", "lcon", "fcon", "scon", "rval", "index" ! 99: }; ! 100: ! 101: public String opname (op) ! 102: Operator op; ! 103: { ! 104: String s; ! 105: static char buf[100]; ! 106: ! 107: switch (op) { ! 108: case O_ITOF: ! 109: s = "itof"; ! 110: break; ! 111: ! 112: case O_ENDX: ! 113: s = "endx"; ! 114: break; ! 115: ! 116: case O_QLINE: ! 117: s = "qline"; ! 118: break; ! 119: ! 120: default: ! 121: if (ord(op) <= ord(O_INDEX)) { ! 122: s = leafname[ord(op)]; ! 123: } else { ! 124: s = opinfo[ord(op)].opstring; ! 125: if (s == nil) { ! 126: sprintf(buf, "[op %d]", op); ! 127: s = buf; ! 128: } ! 129: } ! 130: break; ! 131: } ! 132: return s; ! 133: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.