5 /* Copyright (C) 1995,1996 Mikael Djurfeldt
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)
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.
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.
21 * As a special exception, the Free Software Foundation gives permission
22 * for additional uses of the text contained in its release of GUILE.
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.
30 * This exception does not however invalidate any other reasons why
31 * the executable file might be covered by the GNU General Public License.
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.
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.
45 * The author can be reached at djurfeldt@nada.kth.se
46 * Mikael Djurfeldt, SANS/NADA KTH, 10044 STOCKHOLM, SWEDEN
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.
66 extern scm_option scm_debug_opts
[];
68 #define RECORD_PROCNAMES scm_debug_opts[0].val
69 #define DEBUG_EVAL scm_debug_opts[1].val
70 #define BREAKPOINTS scm_debug_opts[2].val
71 #define TRACE scm_debug_opts[3].val
72 #define BACKTRACE scm_debug_opts[4].val
73 #define BACKTRACE_DEPTH scm_debug_opts[5].val
74 #define FRAMES scm_debug_opts[6].val
75 #define CHEAPTRAPS scm_debug_opts[7].val
76 #define N_DEBUG_OPTIONS 8
78 extern scm_option scm_evaluator_trap_table
[];
80 #define ENTER_FRAME scm_evaluator_trap_table[0].val
81 #define APPLY_FRAME scm_evaluator_trap_table[1].val
82 #define EXIT_FRAME scm_evaluator_trap_table[2].val
83 #define N_EVALUATOR_TRAPS 3
86 extern SCM (*scm_ceval_ptr
) (SCM exp
, SCM env
);
88 extern SCM (*scm_ceval_ptr
) ();
90 extern int debug_mode
, check_entry
, check_apply
, check_exit
;
92 #define CHECK_ENTRY check_entry
93 #define CHECK_APPLY check_apply
94 #define CHECK_EXIT check_exit
96 #define RESET_DEBUG_MODE \
98 if (ENTER_FRAME || BREAKPOINTS) CHECK_ENTRY = 1;\
99 if (APPLY_FRAME || TRACE) CHECK_APPLY = 1;\
100 if (EXIT_FRAME || TRACE) CHECK_EXIT = 1;\
101 debug_mode = DEBUG_EVAL || BACKTRACE || CHECK_ENTRY || CHECK_APPLY || CHECK_EXIT;\
102 scm_ceval_ptr = debug_mode ? scm_deval : scm_ceval;\
109 typedef union scm_debug_info
111 struct { SCM exp
, env
; } e
;
112 struct { SCM proc
, args
; } a
;
115 extern int scm_debug_eframe_size
;
117 typedef struct scm_debug_frame
119 struct scm_debug_frame
*prev
;
121 scm_debug_info vect
[1];
124 extern scm_debug_frame
*last_debug_info_frame
;
126 #define TAILREC (1L << 10)
127 #define TRACEDFRAME (1L << 9)
128 #define APPLYFRAME (1L << 8)
129 #define ARGSREADY (1L << 7)
130 #define DOVERFLOW (1L << 6)
131 #define MAXFRAMESIZE 63 /* also used as a mask for the size field */
133 #define EVALFRAMEP(x) (((x).status & APPLYFRAME) == 0)
134 #define APPLYFRAMEP(x) (((x).status & APPLYFRAME) != 0)
135 #define OVERFLOWP(x) (((x).status & DOVERFLOW) != 0)
136 #define ARGSREADYP(x) (((x).status & ARGSREADY) != 0)
137 #define TRACEDFRAMEP(x) (((x).status & TRACEDFRAME) != 0)
138 #define TAILRECP(x) (((x).status & TAILREC) != 0)
139 #define SETOVERFLOW(x) ((x).status |= DOVERFLOW)
140 #define SETARGSREADY(x) ((x).status |= ARGSREADY)
141 #define CLEARARGSREADY(x) ((x).status &= ~ARGSREADY)
142 #define SETTRACEDFRAME(x) ((x).status |= TRACEDFRAME)
143 #define CLEARTRACEDFRAME(x) ((x).status &= ~TRACEDFRAME)
144 #define SETTAILREC(x) ((x).status |= TAILREC)
146 #define DEBUGGINGP debug_mode
147 #define DSIDEVAL(x, env) if NIMP(x) scm_deval((x), (env))
152 extern long scm_tc16_memoized
;
154 #define SCM_MEMOIZEDP(x) (scm_tc16_memoized == SCM_TYP16 (x))
155 #define SCM_MEMOEXP(x) SCM_CAR (SCM_CDR (x))
156 #define SCM_MEMOENV(x) SCM_CDR (SCM_CDR (x))
161 extern SCM
scm_unmemoize (SCM memoized
);
162 extern SCM
scm_make_debugobj (scm_debug_frame
* debug
);
163 extern void scm_init_debug (void);
165 extern SCM
scm_unmemoize ();
166 extern SCM
scm_make_debugobj ();
167 extern void scm_init_debug ();