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