* debug.c, debug.h: Removed obsolete code.
[bpt/guile.git] / libguile / debug.h
1 /* classes: h_files */
2
3 #ifndef DEBUGH
4 #define DEBUGH
5 /* Copyright (C) 1995,1996 Mikael Djurfeldt
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this software; see the file COPYING. If not, write to
19 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20 *
21 * As a special exception, the Free Software Foundation gives permission
22 * for additional uses of the text contained in its release of GUILE.
23 *
24 * The exception is that, if you link the GUILE library with other files
25 * to produce an executable, this does not by itself cause the
26 * resulting executable to be covered by the GNU General Public License.
27 * Your use of that executable is in no way restricted on account of
28 * linking the GUILE library code into it.
29 *
30 * This exception does not however invalidate any other reasons why
31 * the executable file might be covered by the GNU General Public License.
32 *
33 * This exception applies only to the code released by the
34 * Free Software Foundation under the name GUILE. If you copy
35 * code from other Free Software Foundation releases into a copy of
36 * GUILE, as the General Public License permits, the exception does
37 * not apply to the code that you add in this way. To avoid misleading
38 * anyone as to the status of such modified files, you must delete
39 * this exception notice from them.
40 *
41 * If you write modifications of your own for GUILE, it is your choice
42 * whether to permit this exception to apply to your modifications.
43 * If you do not wish that, delete this exception notice.
44 *
45 * The author can be reached at djurfeldt@nada.kth.se
46 * Mikael Djurfeldt, SANS/NADA KTH, 10044 STOCKHOLM, SWEDEN
47 */
48 \f
49
50 #include "libguile/__scm.h"
51
52 #include "libguile/options.h"
53 \f
54
55 /*
56 * Here comes some definitions for the debugging machinery.
57 * It might seem strange to represent debug flags as ints,
58 * but consider that any particular piece of code is normally
59 * only interested in one flag at a time. This is then
60 * the most efficient representation.
61 */
62
63 /* {Options}
64 */
65
66 /* scm_debug_opts and scm_evaluator_trap_table are defined in eval.c.
67 */
68
69 extern scm_option scm_debug_opts[];
70
71 #define SCM_CHEAPTRAPS_P scm_debug_opts[0].val
72 #define SCM_BREAKPOINTS_P scm_debug_opts[1].val
73 #define SCM_TRACE_P scm_debug_opts[2].val
74 #define SCM_REC_PROCNAMES_P scm_debug_opts[3].val
75 #define SCM_BACKWARDS_P scm_debug_opts[4].val
76 #define SCM_BACKTRACE_INDENT scm_debug_opts[5].val
77 #define SCM_N_FRAMES scm_debug_opts[6].val
78 #define SCM_BACKTRACE_MAXDEPTH scm_debug_opts[7].val
79 #define SCM_BACKTRACE_DEPTH scm_debug_opts[8].val
80 #define SCM_BACKTRACE_P scm_debug_opts[9].val
81 #define SCM_DEVAL_P scm_debug_opts[10].val
82 #define SCM_STACK_LIMIT scm_debug_opts[11].val
83 #define SCM_N_DEBUG_OPTIONS 12
84
85 extern scm_option scm_evaluator_trap_table[];
86
87 #define SCM_ENTER_FRAME_P scm_evaluator_trap_table[0].val
88 #define SCM_APPLY_FRAME_P scm_evaluator_trap_table[1].val
89 #define SCM_EXIT_FRAME_P scm_evaluator_trap_table[2].val
90 #define SCM_N_EVALUATOR_TRAPS 3
91
92 extern SCM (*scm_ceval_ptr) SCM_P ((SCM exp, SCM env));
93
94 extern int scm_debug_mode;
95 extern int scm_check_entry_p, scm_check_apply_p, scm_check_exit_p;
96
97 #define CHECK_ENTRY scm_check_entry_p
98 #define CHECK_APPLY scm_check_apply_p
99 #define CHECK_EXIT scm_check_exit_p
100
101 #define SCM_RESET_DEBUG_MODE \
102 {\
103 if (SCM_ENTER_FRAME_P || SCM_BREAKPOINTS_P) CHECK_ENTRY = 1;\
104 if (SCM_APPLY_FRAME_P || SCM_TRACE_P) CHECK_APPLY = 1;\
105 if (SCM_EXIT_FRAME_P || SCM_TRACE_P) CHECK_EXIT = 1;\
106 scm_debug_mode = SCM_DEVAL_P || SCM_BACKTRACE_P || CHECK_ENTRY || CHECK_APPLY || CHECK_EXIT;\
107 scm_ceval_ptr = scm_debug_mode ? scm_deval : scm_ceval;\
108 }
109
110
111 /* {Evaluator}
112 */
113
114 typedef union scm_debug_info
115 {
116 struct { SCM exp, env; } e;
117 struct { SCM proc, args; } a;
118 } scm_debug_info;
119
120 extern int scm_debug_eframe_size;
121
122 typedef struct scm_debug_frame
123 {
124 struct scm_debug_frame *prev;
125 long status;
126 scm_debug_info vect[1];
127 } scm_debug_frame;
128
129 #ifndef USE_THREADS
130 extern scm_debug_frame *scm_last_debug_frame;
131 #endif
132
133 #define SCM_EVALFRAME (0L << 10)
134 #define SCM_APPLYFRAME (1L << 10)
135 #define SCM_TAILREC (1L << 9)
136 #define SCM_TRACED_FRAME (1L << 8)
137 #define SCM_ARGS_READY (1L << 7)
138 #define SCM_DOVERFLOW (1L << 6)
139 #define SCM_MAX_FRAME_SIZE 63 /* also used as a mask for the size field */
140
141 #define SCM_FRAMETYPE (1L << 10)
142
143 #define SCM_EVALFRAMEP(x) (((x).status & SCM_FRAMETYPE) == SCM_EVALFRAME)
144 #define SCM_APPLYFRAMEP(x) (((x).status & SCM_FRAMETYPE) == SCM_APPLYFRAME)
145 #define SCM_STARTFRAMEP(x) (((x).status & SCM_FRAMETYPE) == SCM_STARTFRAME)
146 #define SCM_OVERFLOWP(x) (((x).status & SCM_DOVERFLOW) != 0)
147 #define SCM_ARGS_READY_P(x) (((x).status & SCM_ARGS_READY) != 0)
148 #define SCM_TRACED_FRAME_P(x) (((x).status & SCM_TRACED_FRAME) != 0)
149 #define SCM_TAILRECP(x) (((x).status & SCM_TAILREC) != 0)
150 #define SCM_SET_OVERFLOW(x) ((x).status |= SCM_DOVERFLOW)
151 #define SCM_SET_ARGSREADY(x) ((x).status |= SCM_ARGS_READY)
152 #define SCM_CLEAR_ARGSREADY(x) ((x).status &= ~SCM_ARGS_READY)
153 #define SCM_SET_TRACED_FRAME(x) ((x).status |= SCM_TRACED_FRAME)
154 #define SCM_CLEAR_TRACED_FRAME(x) ((x).status &= ~SCM_TRACED_FRAME)
155 #define SCM_SET_TAILREC(x) ((x).status |= SCM_TAILREC)
156
157 #define SCM_DEBUGGINGP scm_debug_mode
158 #define SCM_DSIDEVAL(x, env) if NIMP(x) scm_deval((x), (env))
159
160 /* {Debug Objects}
161 */
162
163 extern long scm_tc16_debugobj;
164
165 #define SCM_DEBUGOBJP(x) (scm_tc16_debugobj == SCM_TYP16 (x))
166 #define SCM_DEBUGOBJ_FRAME(x) SCM_CDR (x)
167
168 /* {Memoized Source}
169 */
170
171 extern long scm_tc16_memoized;
172
173 #define SCM_MEMOIZEDP(x) (scm_tc16_memoized == SCM_TYP16 (x))
174 #define SCM_MEMOIZED_EXP(x) SCM_CAR (SCM_CDR (x))
175 #define SCM_MEMOIZED_ENV(x) SCM_CDR (SCM_CDR (x))
176
177 \f
178
179 extern SCM * scm_lookup_cstr SCM_P ((char *str, int len, SCM env));
180 extern SCM * scm_lookup_soft SCM_P ((SCM var, SCM genv));
181 extern SCM scm_evstr SCM_P ((char *str));
182 extern SCM scm_eval_string SCM_P ((SCM str));
183 extern int scm_ready_p SCM_P ((void));
184 extern void debug_print SCM_P ((SCM obj));
185 extern SCM scm_debug_object_p SCM_P ((SCM obj));
186 extern SCM scm_local_eval SCM_P ((SCM exp, SCM env));
187 extern SCM scm_procedure_environment SCM_P ((SCM proc));
188 extern SCM scm_procedure_source SCM_P ((SCM proc));
189 extern SCM scm_procedure_name SCM_P ((SCM proc));
190 extern SCM scm_memoized_environment SCM_P ((SCM m));
191 extern SCM scm_make_memoized SCM_P ((SCM exp, SCM env));
192 extern SCM scm_memoized_p SCM_P ((SCM obj));
193 extern SCM scm_single_step SCM_P ((SCM cont, SCM val));
194 extern SCM scm_evaluator_traps SCM_P ((SCM setting));
195 extern SCM scm_debug_options SCM_P ((SCM setting));
196 extern SCM scm_unmemoize SCM_P ((SCM memoized));
197 extern SCM scm_make_debugobj SCM_P ((scm_debug_frame* debug));
198 extern void scm_init_debug SCM_P ((void));
199
200 #endif /* DEBUGH */