Commit | Line | Data |
---|---|---|
c7ecd529 MD |
1 | /* classes: h_files */ |
2 | ||
13dcb666 DH |
3 | #ifndef SCM_DEBUG_H |
4 | #define SCM_DEBUG_H | |
b29058ff | 5 | |
5132eef0 | 6 | /* Copyright (C) 1995,1996,1998,1999,2000,2001,2002 Free Software Foundation, Inc. |
b29058ff | 7 | * |
73be1d9e MV |
8 | * This library is free software; you can redistribute it and/or |
9 | * modify it under the terms of the GNU Lesser General Public | |
10 | * License as published by the Free Software Foundation; either | |
11 | * version 2.1 of the License, or (at your option) any later version. | |
b29058ff | 12 | * |
73be1d9e | 13 | * This library is distributed in the hope that it will be useful, |
c7ecd529 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
73be1d9e MV |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | * Lesser General Public License for more details. | |
b29058ff | 17 | * |
73be1d9e MV |
18 | * You should have received a copy of the GNU Lesser General Public |
19 | * License along with this library; if not, write to the Free Software | |
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 | */ | |
d3a6bc94 | 22 | |
c7ecd529 MD |
23 | \f |
24 | ||
b4309c3c | 25 | #include "libguile/__scm.h" |
c7ecd529 | 26 | |
e771f866 | 27 | #include "libguile/options.h" |
c7ecd529 MD |
28 | \f |
29 | ||
30 | /* | |
31 | * Here comes some definitions for the debugging machinery. | |
32 | * It might seem strange to represent debug flags as ints, | |
33 | * but consider that any particular piece of code is normally | |
34 | * only interested in one flag at a time. This is then | |
35 | * the most efficient representation. | |
36 | */ | |
37 | ||
38 | /* {Options} | |
39 | */ | |
40 | ||
33b97402 | 41 | /* scm_debug_opts is defined in eval.c. |
5e8d7fd4 MD |
42 | */ |
43 | ||
33b001fd | 44 | SCM_API scm_t_option scm_debug_opts[]; |
c7ecd529 | 45 | |
5e8d7fd4 MD |
46 | #define SCM_CHEAPTRAPS_P scm_debug_opts[0].val |
47 | #define SCM_BREAKPOINTS_P scm_debug_opts[1].val | |
48 | #define SCM_TRACE_P scm_debug_opts[2].val | |
49 | #define SCM_REC_PROCNAMES_P scm_debug_opts[3].val | |
50 | #define SCM_BACKWARDS_P scm_debug_opts[4].val | |
274dc5fd MD |
51 | #define SCM_BACKTRACE_WIDTH scm_debug_opts[5].val |
52 | #define SCM_BACKTRACE_INDENT scm_debug_opts[6].val | |
53 | #define SCM_N_FRAMES scm_debug_opts[7].val | |
54 | #define SCM_BACKTRACE_MAXDEPTH scm_debug_opts[8].val | |
55 | #define SCM_BACKTRACE_DEPTH scm_debug_opts[9].val | |
56 | #define SCM_BACKTRACE_P scm_debug_opts[10].val | |
57 | #define SCM_DEVAL_P scm_debug_opts[11].val | |
58 | #define SCM_STACK_LIMIT scm_debug_opts[12].val | |
29067b9d MV |
59 | #define SCM_SHOW_FILE_NAME scm_debug_opts[13].val |
60 | #define SCM_N_DEBUG_OPTIONS 14 | |
c7ecd529 | 61 | |
33b001fd | 62 | SCM_API SCM (*scm_ceval_ptr) (SCM exp, SCM env); |
1cc91f1b | 63 | |
33b001fd MV |
64 | SCM_API int scm_debug_mode; |
65 | SCM_API int scm_check_entry_p; | |
66 | SCM_API int scm_check_apply_p; | |
67 | SCM_API int scm_check_exit_p; | |
c7ecd529 | 68 | |
5e8d7fd4 | 69 | #define SCM_RESET_DEBUG_MODE \ |
d3a6bc94 | 70 | do {\ |
5132eef0 | 71 | scm_check_entry_p = (SCM_ENTER_FRAME_P || SCM_BREAKPOINTS_P)\ |
b29058ff | 72 | && !SCM_FALSEP (SCM_ENTER_FRAME_HDLR);\ |
5132eef0 | 73 | scm_check_apply_p = (SCM_APPLY_FRAME_P || SCM_TRACE_P)\ |
b29058ff | 74 | && !SCM_FALSEP (SCM_APPLY_FRAME_HDLR);\ |
5132eef0 | 75 | scm_check_exit_p = (SCM_EXIT_FRAME_P || SCM_TRACE_P)\ |
b29058ff | 76 | && !SCM_FALSEP (SCM_EXIT_FRAME_HDLR);\ |
5132eef0 DH |
77 | scm_debug_mode = SCM_DEVAL_P\ |
78 | || scm_check_entry_p || scm_check_apply_p || scm_check_exit_p;\ | |
5e8d7fd4 | 79 | scm_ceval_ptr = scm_debug_mode ? scm_deval : scm_ceval;\ |
d3a6bc94 | 80 | } while (0) |
c7ecd529 | 81 | |
c7ecd529 MD |
82 | /* {Evaluator} |
83 | */ | |
84 | ||
92c2555f | 85 | typedef union scm_t_debug_info |
c7ecd529 MD |
86 | { |
87 | struct { SCM exp, env; } e; | |
88 | struct { SCM proc, args; } a; | |
473c250d | 89 | SCM id; |
92c2555f | 90 | } scm_t_debug_info; |
c7ecd529 | 91 | |
33b001fd | 92 | SCM_API long scm_debug_eframe_size; |
c7ecd529 | 93 | |
92c2555f | 94 | typedef struct scm_t_debug_frame |
c7ecd529 | 95 | { |
92c2555f | 96 | struct scm_t_debug_frame *prev; |
c7ecd529 | 97 | long status; |
92c2555f MV |
98 | scm_t_debug_info *vect; |
99 | scm_t_debug_info *info; | |
100 | } scm_t_debug_frame; | |
1be6b49c | 101 | |
77debe3c MD |
102 | #define SCM_EVALFRAME (0L << 11) |
103 | #define SCM_APPLYFRAME (1L << 11) | |
104 | #define SCM_VOIDFRAME (3L << 11) | |
105 | #define SCM_MACROEXPF (1L << 10) | |
fcbb26b2 MD |
106 | #define SCM_TAILREC (1L << 9) |
107 | #define SCM_TRACED_FRAME (1L << 8) | |
5e8d7fd4 | 108 | #define SCM_ARGS_READY (1L << 7) |
fcbb26b2 | 109 | #define SCM_DOVERFLOW (1L << 6) |
020c890c | 110 | #define SCM_MAX_FRAME_SIZE 63 |
5e8d7fd4 | 111 | |
77debe3c | 112 | #define SCM_FRAMETYPE (3L << 11) |
fcbb26b2 | 113 | |
77debe3c | 114 | #define SCM_EVALFRAMEP(x) (((x).status & SCM_FRAMETYPE) == SCM_EVALFRAME) |
fcbb26b2 | 115 | #define SCM_APPLYFRAMEP(x) (((x).status & SCM_FRAMETYPE) == SCM_APPLYFRAME) |
473c250d | 116 | #define SCM_VOIDFRAMEP(x) (((x).status & SCM_FRAMETYPE) == SCM_VOIDFRAME) |
5e8d7fd4 MD |
117 | #define SCM_OVERFLOWP(x) (((x).status & SCM_DOVERFLOW) != 0) |
118 | #define SCM_ARGS_READY_P(x) (((x).status & SCM_ARGS_READY) != 0) | |
119 | #define SCM_TRACED_FRAME_P(x) (((x).status & SCM_TRACED_FRAME) != 0) | |
120 | #define SCM_TAILRECP(x) (((x).status & SCM_TAILREC) != 0) | |
77debe3c | 121 | #define SCM_MACROEXPP(x) (((x).status & SCM_MACROEXPF) != 0) |
5e8d7fd4 MD |
122 | #define SCM_SET_OVERFLOW(x) ((x).status |= SCM_DOVERFLOW) |
123 | #define SCM_SET_ARGSREADY(x) ((x).status |= SCM_ARGS_READY) | |
124 | #define SCM_CLEAR_ARGSREADY(x) ((x).status &= ~SCM_ARGS_READY) | |
125 | #define SCM_SET_TRACED_FRAME(x) ((x).status |= SCM_TRACED_FRAME) | |
126 | #define SCM_CLEAR_TRACED_FRAME(x) ((x).status &= ~SCM_TRACED_FRAME) | |
127 | #define SCM_SET_TAILREC(x) ((x).status |= SCM_TAILREC) | |
77debe3c MD |
128 | #define SCM_SET_MACROEXP(x) ((x).status |= SCM_MACROEXPF) |
129 | #define SCM_CLEAR_MACROEXP(x) ((x).status &= ~SCM_MACROEXPF) | |
5e8d7fd4 MD |
130 | |
131 | #define SCM_DEBUGGINGP scm_debug_mode | |
c7ecd529 | 132 | |
fcbb26b2 MD |
133 | /* {Debug Objects} |
134 | */ | |
135 | ||
33b001fd | 136 | SCM_API scm_t_bits scm_tc16_debugobj; |
fcbb26b2 | 137 | |
13dcb666 DH |
138 | #define SCM_DEBUGOBJP(x) \ |
139 | SCM_TYP16_PREDICATE (scm_tc16_debugobj, x) | |
140 | #define SCM_DEBUGOBJ_FRAME(x) \ | |
141 | ((scm_t_debug_frame *) SCM_CELL_WORD_1 (x)) | |
e841c3e0 | 142 | #define SCM_SET_DEBUGOBJ_FRAME(x, f) SCM_SET_CELL_WORD_1 (x, f) |
fcbb26b2 | 143 | |
c7ecd529 MD |
144 | /* {Memoized Source} |
145 | */ | |
146 | ||
33b001fd | 147 | SCM_API scm_t_bits scm_tc16_memoized; |
c7ecd529 | 148 | |
e841c3e0 KN |
149 | #define SCM_MEMOIZEDP(x) SCM_TYP16_PREDICATE (scm_tc16_memoized, x) |
150 | #define SCM_MEMOIZED_EXP(x) SCM_CAR (SCM_CELL_OBJECT_1 (x)) | |
151 | #define SCM_MEMOIZED_ENV(x) SCM_CDR (SCM_CELL_OBJECT_1 (x)) | |
c7ecd529 MD |
152 | |
153 | \f | |
154 | ||
33b001fd MV |
155 | SCM_API SCM scm_debug_object_p (SCM obj); |
156 | SCM_API SCM scm_local_eval (SCM exp, SCM env); | |
157 | SCM_API SCM scm_reverse_lookup (SCM env, SCM data); | |
00f9eace | 158 | SCM_API SCM scm_start_stack (SCM info_id, SCM exp, SCM env); |
33b001fd MV |
159 | SCM_API SCM scm_procedure_environment (SCM proc); |
160 | SCM_API SCM scm_procedure_source (SCM proc); | |
161 | SCM_API SCM scm_procedure_name (SCM proc); | |
162 | SCM_API SCM scm_memoized_environment (SCM m); | |
163 | SCM_API SCM scm_make_memoized (SCM exp, SCM env); | |
164 | SCM_API SCM scm_memoized_p (SCM obj); | |
165 | SCM_API SCM scm_with_traps (SCM thunk); | |
166 | SCM_API SCM scm_evaluator_traps (SCM setting); | |
167 | SCM_API SCM scm_debug_options (SCM setting); | |
168 | SCM_API SCM scm_unmemoize (SCM memoized); | |
169 | SCM_API SCM scm_make_debugobj (scm_t_debug_frame *debug); | |
170 | SCM_API void scm_init_debug (void); | |
c7ecd529 | 171 | |
f3667f52 | 172 | #ifdef GUILE_DEBUG |
33b001fd MV |
173 | SCM_API SCM scm_make_iloc (SCM frame, SCM binding, SCM cdrp); |
174 | SCM_API SCM scm_iloc_p (SCM obj); | |
175 | SCM_API SCM scm_memcons (SCM car, SCM cdr, SCM env); | |
176 | SCM_API SCM scm_mem_to_proc (SCM obj); | |
177 | SCM_API SCM scm_proc_to_mem (SCM obj); | |
178 | SCM_API SCM scm_debug_hang (SCM obj); | |
f3667f52 JB |
179 | #endif /*GUILE_DEBUG*/ |
180 | ||
5132eef0 DH |
181 | #if SCM_ENABLE_DEPRECATED == 1 |
182 | #define CHECK_ENTRY scm_check_entry_p | |
183 | #define CHECK_APPLY scm_check_apply_p | |
184 | #define CHECK_EXIT scm_check_exit_p | |
185 | #endif | |
186 | ||
b29058ff | 187 | #endif /* SCM_DEBUG_H */ |
89e00824 ML |
188 | |
189 | /* | |
190 | Local Variables: | |
191 | c-file-style: "gnu" | |
192 | End: | |
193 | */ |