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