Commit | Line | Data |
---|---|---|
c7ecd529 MD |
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 | ||
b4309c3c | 50 | #include "libguile/__scm.h" |
c7ecd529 | 51 | |
e771f866 | 52 | #include "libguile/options.h" |
c7ecd529 MD |
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 | ||
5e8d7fd4 MD |
66 | /* scm_debug_opts and scm_evaluator_trap_table are defined in eval.c. |
67 | */ | |
68 | ||
c7ecd529 MD |
69 | extern scm_option scm_debug_opts[]; |
70 | ||
5e8d7fd4 MD |
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 | |
fcbb26b2 MD |
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 | |
c7ecd529 MD |
84 | |
85 | extern scm_option scm_evaluator_trap_table[]; | |
86 | ||
5e8d7fd4 MD |
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 | |
c7ecd529 | 91 | |
1cc91f1b JB |
92 | extern SCM (*scm_ceval_ptr) SCM_P ((SCM exp, SCM env)); |
93 | ||
5e8d7fd4 MD |
94 | extern int scm_debug_mode; |
95 | extern int scm_check_entry_p, scm_check_apply_p, scm_check_exit_p; | |
c7ecd529 | 96 | |
5e8d7fd4 MD |
97 | #define CHECK_ENTRY scm_check_entry_p |
98 | #define CHECK_APPLY scm_check_apply_p | |
99 | #define CHECK_EXIT scm_check_exit_p | |
c7ecd529 | 100 | |
5e8d7fd4 | 101 | #define SCM_RESET_DEBUG_MODE \ |
c7ecd529 | 102 | {\ |
5e8d7fd4 MD |
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;\ | |
44b5e41d | 106 | scm_debug_mode = SCM_DEVAL_P || CHECK_ENTRY || CHECK_APPLY || CHECK_EXIT;\ |
5e8d7fd4 | 107 | scm_ceval_ptr = scm_debug_mode ? scm_deval : scm_ceval;\ |
c7ecd529 MD |
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; | |
473c250d | 118 | SCM id; |
c7ecd529 MD |
119 | } scm_debug_info; |
120 | ||
121 | extern int scm_debug_eframe_size; | |
122 | ||
123 | typedef struct scm_debug_frame | |
124 | { | |
125 | struct scm_debug_frame *prev; | |
126 | long status; | |
c0ab1b8d JB |
127 | scm_debug_info *vect; |
128 | scm_debug_info *info; | |
c7ecd529 MD |
129 | } scm_debug_frame; |
130 | ||
1646d37b MD |
131 | #ifndef USE_THREADS |
132 | extern scm_debug_frame *scm_last_debug_frame; | |
133 | #endif | |
c7ecd529 | 134 | |
fcbb26b2 MD |
135 | #define SCM_EVALFRAME (0L << 10) |
136 | #define SCM_APPLYFRAME (1L << 10) | |
473c250d | 137 | #define SCM_VOIDFRAME (2L << 10) |
fcbb26b2 MD |
138 | #define SCM_TAILREC (1L << 9) |
139 | #define SCM_TRACED_FRAME (1L << 8) | |
5e8d7fd4 | 140 | #define SCM_ARGS_READY (1L << 7) |
fcbb26b2 | 141 | #define SCM_DOVERFLOW (1L << 6) |
5e8d7fd4 MD |
142 | #define SCM_MAX_FRAME_SIZE 63 /* also used as a mask for the size field */ |
143 | ||
473c250d | 144 | #define SCM_FRAMETYPE (3L << 10) |
fcbb26b2 MD |
145 | |
146 | #define SCM_EVALFRAMEP(x) (((x).status & SCM_FRAMETYPE) == SCM_EVALFRAME) | |
147 | #define SCM_APPLYFRAMEP(x) (((x).status & SCM_FRAMETYPE) == SCM_APPLYFRAME) | |
473c250d | 148 | #define SCM_VOIDFRAMEP(x) (((x).status & SCM_FRAMETYPE) == SCM_VOIDFRAME) |
5e8d7fd4 MD |
149 | #define SCM_OVERFLOWP(x) (((x).status & SCM_DOVERFLOW) != 0) |
150 | #define SCM_ARGS_READY_P(x) (((x).status & SCM_ARGS_READY) != 0) | |
151 | #define SCM_TRACED_FRAME_P(x) (((x).status & SCM_TRACED_FRAME) != 0) | |
152 | #define SCM_TAILRECP(x) (((x).status & SCM_TAILREC) != 0) | |
153 | #define SCM_SET_OVERFLOW(x) ((x).status |= SCM_DOVERFLOW) | |
154 | #define SCM_SET_ARGSREADY(x) ((x).status |= SCM_ARGS_READY) | |
155 | #define SCM_CLEAR_ARGSREADY(x) ((x).status &= ~SCM_ARGS_READY) | |
156 | #define SCM_SET_TRACED_FRAME(x) ((x).status |= SCM_TRACED_FRAME) | |
157 | #define SCM_CLEAR_TRACED_FRAME(x) ((x).status &= ~SCM_TRACED_FRAME) | |
158 | #define SCM_SET_TAILREC(x) ((x).status |= SCM_TAILREC) | |
159 | ||
160 | #define SCM_DEBUGGINGP scm_debug_mode | |
161 | #define SCM_DSIDEVAL(x, env) if NIMP(x) scm_deval((x), (env)) | |
c7ecd529 | 162 | |
fcbb26b2 MD |
163 | /* {Debug Objects} |
164 | */ | |
165 | ||
166 | extern long scm_tc16_debugobj; | |
167 | ||
168 | #define SCM_DEBUGOBJP(x) (scm_tc16_debugobj == SCM_TYP16 (x)) | |
169 | #define SCM_DEBUGOBJ_FRAME(x) SCM_CDR (x) | |
a6c64c3c | 170 | #define SCM_SET_DEBUGOBJ_FRAME(x, f) SCM_SETCDR (x, f) |
fcbb26b2 | 171 | |
c7ecd529 MD |
172 | /* {Memoized Source} |
173 | */ | |
174 | ||
175 | extern long scm_tc16_memoized; | |
176 | ||
177 | #define SCM_MEMOIZEDP(x) (scm_tc16_memoized == SCM_TYP16 (x)) | |
fcbb26b2 MD |
178 | #define SCM_MEMOIZED_EXP(x) SCM_CAR (SCM_CDR (x)) |
179 | #define SCM_MEMOIZED_ENV(x) SCM_CDR (SCM_CDR (x)) | |
c7ecd529 MD |
180 | |
181 | \f | |
182 | ||
1cc91f1b JB |
183 | extern SCM * scm_lookup_cstr SCM_P ((char *str, int len, SCM env)); |
184 | extern SCM * scm_lookup_soft SCM_P ((SCM var, SCM genv)); | |
185 | extern SCM scm_evstr SCM_P ((char *str)); | |
186 | extern SCM scm_eval_string SCM_P ((SCM str)); | |
187 | extern int scm_ready_p SCM_P ((void)); | |
188 | extern void debug_print SCM_P ((SCM obj)); | |
1cc91f1b JB |
189 | extern SCM scm_debug_object_p SCM_P ((SCM obj)); |
190 | extern SCM scm_local_eval SCM_P ((SCM exp, SCM env)); | |
191 | extern SCM scm_procedure_environment SCM_P ((SCM proc)); | |
192 | extern SCM scm_procedure_source SCM_P ((SCM proc)); | |
193 | extern SCM scm_procedure_name SCM_P ((SCM proc)); | |
194 | extern SCM scm_memoized_environment SCM_P ((SCM m)); | |
195 | extern SCM scm_make_memoized SCM_P ((SCM exp, SCM env)); | |
196 | extern SCM scm_memoized_p SCM_P ((SCM obj)); | |
197 | extern SCM scm_single_step SCM_P ((SCM cont, SCM val)); | |
198 | extern SCM scm_evaluator_traps SCM_P ((SCM setting)); | |
199 | extern SCM scm_debug_options SCM_P ((SCM setting)); | |
200 | extern SCM scm_unmemoize SCM_P ((SCM memoized)); | |
201 | extern SCM scm_make_debugobj SCM_P ((scm_debug_frame* debug)); | |
202 | extern void scm_init_debug SCM_P ((void)); | |
c7ecd529 MD |
203 | |
204 | #endif /* DEBUGH */ |