* eval.c (scm_debug_opts): New option `show-file-name'.
[bpt/guile.git] / libguile / debug.h
CommitLineData
c7ecd529
MD
1/* classes: h_files */
2
3#ifndef DEBUGH
4#define DEBUGH
f2c9fcb0 5/* Copyright (C) 1995,1996,1998, 1999, 2000 Free Software Foundation
c7ecd529
MD
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
82892bed
JB
19 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20 * Boston, MA 02111-1307 USA
c7ecd529
MD
21 *
22 * As a special exception, the Free Software Foundation gives permission
23 * for additional uses of the text contained in its release of GUILE.
24 *
25 * The exception is that, if you link the GUILE library with other files
26 * to produce an executable, this does not by itself cause the
27 * resulting executable to be covered by the GNU General Public License.
28 * Your use of that executable is in no way restricted on account of
29 * linking the GUILE library code into it.
30 *
31 * This exception does not however invalidate any other reasons why
32 * the executable file might be covered by the GNU General Public License.
33 *
34 * This exception applies only to the code released by the
35 * Free Software Foundation under the name GUILE. If you copy
36 * code from other Free Software Foundation releases into a copy of
37 * GUILE, as the General Public License permits, the exception does
38 * not apply to the code that you add in this way. To avoid misleading
39 * anyone as to the status of such modified files, you must delete
40 * this exception notice from them.
41 *
42 * If you write modifications of your own for GUILE, it is your choice
43 * whether to permit this exception to apply to your modifications.
44 * If you do not wish that, delete this exception notice.
45 *
46 * The author can be reached at djurfeldt@nada.kth.se
82892bed 47 * Mikael Djurfeldt, SANS/NADA KTH, 10044 STOCKHOLM, SWEDEN */
d3a6bc94
GB
48
49/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
50 gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
c7ecd529
MD
51\f
52
b4309c3c 53#include "libguile/__scm.h"
c7ecd529 54
e771f866 55#include "libguile/options.h"
c7ecd529
MD
56\f
57
58/*
59 * Here comes some definitions for the debugging machinery.
60 * It might seem strange to represent debug flags as ints,
61 * but consider that any particular piece of code is normally
62 * only interested in one flag at a time. This is then
63 * the most efficient representation.
64 */
65
66/* {Options}
67 */
68
33b97402 69/* scm_debug_opts is defined in eval.c.
5e8d7fd4
MD
70 */
71
1be6b49c 72extern scm_option_t scm_debug_opts[];
c7ecd529 73
5e8d7fd4
MD
74#define SCM_CHEAPTRAPS_P scm_debug_opts[0].val
75#define SCM_BREAKPOINTS_P scm_debug_opts[1].val
76#define SCM_TRACE_P scm_debug_opts[2].val
77#define SCM_REC_PROCNAMES_P scm_debug_opts[3].val
78#define SCM_BACKWARDS_P scm_debug_opts[4].val
274dc5fd
MD
79#define SCM_BACKTRACE_WIDTH scm_debug_opts[5].val
80#define SCM_BACKTRACE_INDENT scm_debug_opts[6].val
81#define SCM_N_FRAMES scm_debug_opts[7].val
82#define SCM_BACKTRACE_MAXDEPTH scm_debug_opts[8].val
83#define SCM_BACKTRACE_DEPTH scm_debug_opts[9].val
84#define SCM_BACKTRACE_P scm_debug_opts[10].val
85#define SCM_DEVAL_P scm_debug_opts[11].val
86#define SCM_STACK_LIMIT scm_debug_opts[12].val
29067b9d
MV
87#define SCM_SHOW_FILE_NAME scm_debug_opts[13].val
88#define SCM_N_DEBUG_OPTIONS 14
c7ecd529 89
7866a09b 90extern SCM (*scm_ceval_ptr) (SCM exp, SCM env);
1cc91f1b 91
5e8d7fd4
MD
92extern int scm_debug_mode;
93extern int scm_check_entry_p, scm_check_apply_p, scm_check_exit_p;
c7ecd529 94
5e8d7fd4
MD
95#define CHECK_ENTRY scm_check_entry_p
96#define CHECK_APPLY scm_check_apply_p
97#define CHECK_EXIT scm_check_exit_p
c7ecd529 98
5e8d7fd4 99#define SCM_RESET_DEBUG_MODE \
d3a6bc94 100do {\
a8485f4d
MD
101 CHECK_ENTRY = SCM_ENTER_FRAME_P || SCM_BREAKPOINTS_P;\
102 CHECK_APPLY = SCM_APPLY_FRAME_P || SCM_TRACE_P;\
103 CHECK_EXIT = SCM_EXIT_FRAME_P || SCM_TRACE_P;\
44b5e41d 104 scm_debug_mode = SCM_DEVAL_P || CHECK_ENTRY || CHECK_APPLY || CHECK_EXIT;\
5e8d7fd4 105 scm_ceval_ptr = scm_debug_mode ? scm_deval : scm_ceval;\
d3a6bc94 106} while (0)
c7ecd529
MD
107
108
109/* {Evaluator}
110 */
111
1be6b49c 112typedef union scm_debug_info_t
c7ecd529
MD
113{
114 struct { SCM exp, env; } e;
115 struct { SCM proc, args; } a;
473c250d 116 SCM id;
1be6b49c 117} scm_debug_info_t;
c7ecd529 118
1be6b49c 119extern scm_bits_t scm_debug_eframe_size;
c7ecd529 120
1be6b49c 121typedef struct scm_debug_frame_t
c7ecd529 122{
1be6b49c 123 struct scm_debug_frame_t *prev;
c7ecd529 124 long status;
1be6b49c
ML
125 scm_debug_info_t *vect;
126 scm_debug_info_t *info;
127} scm_debug_frame_t;
128
129#if (SCM_DEBUG_DEPRECATED == 0)
130# define scm_debug_info scm_debug_info_t
131# define scm_debug_frame scm_debug_frame_t
132#endif
c7ecd529 133
1646d37b 134#ifndef USE_THREADS
1be6b49c 135extern scm_debug_frame_t *scm_last_debug_frame;
1646d37b 136#endif
c7ecd529 137
77debe3c
MD
138#define SCM_EVALFRAME (0L << 11)
139#define SCM_APPLYFRAME (1L << 11)
140#define SCM_VOIDFRAME (3L << 11)
141#define SCM_MACROEXPF (1L << 10)
fcbb26b2
MD
142#define SCM_TAILREC (1L << 9)
143#define SCM_TRACED_FRAME (1L << 8)
5e8d7fd4 144#define SCM_ARGS_READY (1L << 7)
fcbb26b2 145#define SCM_DOVERFLOW (1L << 6)
5e8d7fd4
MD
146#define SCM_MAX_FRAME_SIZE 63 /* also used as a mask for the size field */
147
77debe3c 148#define SCM_FRAMETYPE (3L << 11)
fcbb26b2 149
77debe3c 150#define SCM_EVALFRAMEP(x) (((x).status & SCM_FRAMETYPE) == SCM_EVALFRAME)
fcbb26b2 151#define SCM_APPLYFRAMEP(x) (((x).status & SCM_FRAMETYPE) == SCM_APPLYFRAME)
473c250d 152#define SCM_VOIDFRAMEP(x) (((x).status & SCM_FRAMETYPE) == SCM_VOIDFRAME)
5e8d7fd4
MD
153#define SCM_OVERFLOWP(x) (((x).status & SCM_DOVERFLOW) != 0)
154#define SCM_ARGS_READY_P(x) (((x).status & SCM_ARGS_READY) != 0)
155#define SCM_TRACED_FRAME_P(x) (((x).status & SCM_TRACED_FRAME) != 0)
156#define SCM_TAILRECP(x) (((x).status & SCM_TAILREC) != 0)
77debe3c 157#define SCM_MACROEXPP(x) (((x).status & SCM_MACROEXPF) != 0)
5e8d7fd4
MD
158#define SCM_SET_OVERFLOW(x) ((x).status |= SCM_DOVERFLOW)
159#define SCM_SET_ARGSREADY(x) ((x).status |= SCM_ARGS_READY)
160#define SCM_CLEAR_ARGSREADY(x) ((x).status &= ~SCM_ARGS_READY)
161#define SCM_SET_TRACED_FRAME(x) ((x).status |= SCM_TRACED_FRAME)
162#define SCM_CLEAR_TRACED_FRAME(x) ((x).status &= ~SCM_TRACED_FRAME)
163#define SCM_SET_TAILREC(x) ((x).status |= SCM_TAILREC)
77debe3c
MD
164#define SCM_SET_MACROEXP(x) ((x).status |= SCM_MACROEXPF)
165#define SCM_CLEAR_MACROEXP(x) ((x).status &= ~SCM_MACROEXPF)
5e8d7fd4
MD
166
167#define SCM_DEBUGGINGP scm_debug_mode
168#define SCM_DSIDEVAL(x, env) if NIMP(x) scm_deval((x), (env))
c7ecd529 169
fcbb26b2
MD
170/* {Debug Objects}
171 */
172
e841c3e0 173extern scm_bits_t scm_tc16_debugobj;
fcbb26b2 174
e841c3e0
KN
175#define SCM_DEBUGOBJP(x) SCM_TYP16_PREDICATE (scm_tc16_debugobj, x)
176#define SCM_DEBUGOBJ_FRAME(x) SCM_CELL_WORD_1 (x)
177#define SCM_SET_DEBUGOBJ_FRAME(x, f) SCM_SET_CELL_WORD_1 (x, f)
fcbb26b2 178
c7ecd529
MD
179/* {Memoized Source}
180 */
181
e841c3e0 182extern scm_bits_t scm_tc16_memoized;
c7ecd529 183
e841c3e0
KN
184#define SCM_MEMOIZEDP(x) SCM_TYP16_PREDICATE (scm_tc16_memoized, x)
185#define SCM_MEMOIZED_EXP(x) SCM_CAR (SCM_CELL_OBJECT_1 (x))
186#define SCM_MEMOIZED_ENV(x) SCM_CDR (SCM_CELL_OBJECT_1 (x))
c7ecd529
MD
187
188\f
189
7866a09b
GB
190extern SCM scm_eval_string (SCM str);
191extern int scm_ready_p (void);
192extern void debug_print (SCM obj);
193extern SCM scm_debug_object_p (SCM obj);
194extern SCM scm_local_eval (SCM exp, SCM env);
195extern SCM scm_reverse_lookup (SCM env, SCM data);
196extern SCM scm_start_stack (SCM id, SCM exp, SCM env);
197extern SCM scm_procedure_environment (SCM proc);
198extern SCM scm_procedure_source (SCM proc);
199extern SCM scm_procedure_name (SCM proc);
200extern SCM scm_memoized_environment (SCM m);
201extern SCM scm_make_memoized (SCM exp, SCM env);
202extern SCM scm_memoized_p (SCM obj);
203extern SCM scm_with_traps (SCM thunk);
204extern SCM scm_evaluator_traps (SCM setting);
205extern SCM scm_debug_options (SCM setting);
206extern SCM scm_unmemoize (SCM memoized);
1be6b49c 207extern SCM scm_make_debugobj (scm_debug_frame_t *debug);
7866a09b 208extern void scm_init_debug (void);
c7ecd529 209
f3667f52 210#ifdef GUILE_DEBUG
7866a09b
GB
211extern SCM scm_make_gloc (SCM var, SCM env);
212extern SCM scm_gloc_p (SCM obj);
213extern SCM scm_make_iloc (SCM frame, SCM binding, SCM cdrp);
214extern SCM scm_iloc_p (SCM obj);
215extern SCM scm_memcons (SCM car, SCM cdr, SCM env);
216extern SCM scm_mem_to_proc (SCM obj);
217extern SCM scm_proc_to_mem (SCM obj);
218extern SCM scm_debug_hang (SCM obj);
f3667f52
JB
219#endif /*GUILE_DEBUG*/
220
c7ecd529 221#endif /* DEBUGH */
89e00824
ML
222
223/*
224 Local Variables:
225 c-file-style: "gnu"
226 End:
227*/