Commit | Line | Data |
---|---|---|
c7ecd529 MD |
1 | /* classes: h_files */ |
2 | ||
13dcb666 DH |
3 | #ifndef SCM_DEBUG_H |
4 | #define SCM_DEBUG_H | |
b29058ff | 5 | |
b7742c6b | 6 | /* Copyright (C) 1995,1996,1998,1999,2000,2001,2002,2004,2008,2009 |
434f2f7a | 7 | * Free Software Foundation, Inc. |
b29058ff | 8 | * |
73be1d9e | 9 | * This library is free software; you can redistribute it and/or |
53befeb7 NJ |
10 | * modify it under the terms of the GNU Lesser General Public License |
11 | * as published by the Free Software Foundation; either version 3 of | |
12 | * the License, or (at your option) any later version. | |
b29058ff | 13 | * |
53befeb7 NJ |
14 | * This library is distributed in the hope that it will be useful, but |
15 | * 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 | |
53befeb7 NJ |
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
22 | * 02110-1301 USA | |
73be1d9e | 23 | */ |
d3a6bc94 | 24 | |
c7ecd529 MD |
25 | \f |
26 | ||
b4309c3c | 27 | #include "libguile/__scm.h" |
c7ecd529 | 28 | |
e771f866 | 29 | #include "libguile/options.h" |
c7ecd529 MD |
30 | \f |
31 | ||
32 | /* | |
33 | * Here comes some definitions for the debugging machinery. | |
34 | * It might seem strange to represent debug flags as ints, | |
35 | * but consider that any particular piece of code is normally | |
36 | * only interested in one flag at a time. This is then | |
37 | * the most efficient representation. | |
38 | */ | |
39 | ||
40 | /* {Options} | |
41 | */ | |
42 | ||
33b97402 | 43 | /* scm_debug_opts is defined in eval.c. |
5e8d7fd4 MD |
44 | */ |
45 | ||
c7ecd529 | 46 | |
c7ecd529 | 47 | |
c7ecd529 MD |
48 | /* {Evaluator} |
49 | */ | |
50 | ||
92c2555f | 51 | typedef union scm_t_debug_info |
c7ecd529 MD |
52 | { |
53 | struct { SCM exp, env; } e; | |
54 | struct { SCM proc, args; } a; | |
473c250d | 55 | SCM id; |
92c2555f | 56 | } scm_t_debug_info; |
c7ecd529 | 57 | |
92c2555f | 58 | typedef struct scm_t_debug_frame |
c7ecd529 | 59 | { |
92c2555f | 60 | struct scm_t_debug_frame *prev; |
c7ecd529 | 61 | long status; |
92c2555f MV |
62 | scm_t_debug_info *vect; |
63 | scm_t_debug_info *info; | |
64 | } scm_t_debug_frame; | |
1be6b49c | 65 | |
77debe3c MD |
66 | #define SCM_EVALFRAME (0L << 11) |
67 | #define SCM_APPLYFRAME (1L << 11) | |
68 | #define SCM_VOIDFRAME (3L << 11) | |
69 | #define SCM_MACROEXPF (1L << 10) | |
fcbb26b2 MD |
70 | #define SCM_TAILREC (1L << 9) |
71 | #define SCM_TRACED_FRAME (1L << 8) | |
5e8d7fd4 | 72 | #define SCM_ARGS_READY (1L << 7) |
fcbb26b2 | 73 | #define SCM_DOVERFLOW (1L << 6) |
020c890c | 74 | #define SCM_MAX_FRAME_SIZE 63 |
5e8d7fd4 | 75 | |
77debe3c | 76 | #define SCM_FRAMETYPE (3L << 11) |
fcbb26b2 | 77 | |
77debe3c | 78 | #define SCM_EVALFRAMEP(x) (((x).status & SCM_FRAMETYPE) == SCM_EVALFRAME) |
fcbb26b2 | 79 | #define SCM_APPLYFRAMEP(x) (((x).status & SCM_FRAMETYPE) == SCM_APPLYFRAME) |
473c250d | 80 | #define SCM_VOIDFRAMEP(x) (((x).status & SCM_FRAMETYPE) == SCM_VOIDFRAME) |
5e8d7fd4 MD |
81 | #define SCM_OVERFLOWP(x) (((x).status & SCM_DOVERFLOW) != 0) |
82 | #define SCM_ARGS_READY_P(x) (((x).status & SCM_ARGS_READY) != 0) | |
83 | #define SCM_TRACED_FRAME_P(x) (((x).status & SCM_TRACED_FRAME) != 0) | |
84 | #define SCM_TAILRECP(x) (((x).status & SCM_TAILREC) != 0) | |
77debe3c | 85 | #define SCM_MACROEXPP(x) (((x).status & SCM_MACROEXPF) != 0) |
5e8d7fd4 MD |
86 | #define SCM_SET_OVERFLOW(x) ((x).status |= SCM_DOVERFLOW) |
87 | #define SCM_SET_ARGSREADY(x) ((x).status |= SCM_ARGS_READY) | |
88 | #define SCM_CLEAR_ARGSREADY(x) ((x).status &= ~SCM_ARGS_READY) | |
89 | #define SCM_SET_TRACED_FRAME(x) ((x).status |= SCM_TRACED_FRAME) | |
90 | #define SCM_CLEAR_TRACED_FRAME(x) ((x).status &= ~SCM_TRACED_FRAME) | |
91 | #define SCM_SET_TAILREC(x) ((x).status |= SCM_TAILREC) | |
77debe3c MD |
92 | #define SCM_SET_MACROEXP(x) ((x).status |= SCM_MACROEXPF) |
93 | #define SCM_CLEAR_MACROEXP(x) ((x).status &= ~SCM_MACROEXPF) | |
5e8d7fd4 | 94 | |
fcbb26b2 MD |
95 | /* {Debug Objects} |
96 | */ | |
97 | ||
33b001fd | 98 | SCM_API scm_t_bits scm_tc16_debugobj; |
fcbb26b2 | 99 | |
13dcb666 DH |
100 | #define SCM_DEBUGOBJP(x) \ |
101 | SCM_TYP16_PREDICATE (scm_tc16_debugobj, x) | |
102 | #define SCM_DEBUGOBJ_FRAME(x) \ | |
103 | ((scm_t_debug_frame *) SCM_CELL_WORD_1 (x)) | |
e841c3e0 | 104 | #define SCM_SET_DEBUGOBJ_FRAME(x, f) SCM_SET_CELL_WORD_1 (x, f) |
fcbb26b2 | 105 | |
c7ecd529 MD |
106 | \f |
107 | ||
33b001fd | 108 | SCM_API SCM scm_debug_object_p (SCM obj); |
33b001fd | 109 | SCM_API SCM scm_reverse_lookup (SCM env, SCM data); |
107139ea | 110 | SCM_API SCM scm_sys_start_stack (SCM info_id, SCM thunk); |
4e237f14 | 111 | SCM_API SCM scm_procedure_module (SCM proc); |
33b001fd MV |
112 | SCM_API SCM scm_procedure_source (SCM proc); |
113 | SCM_API SCM scm_procedure_name (SCM proc); | |
33b001fd MV |
114 | SCM_API SCM scm_with_traps (SCM thunk); |
115 | SCM_API SCM scm_evaluator_traps (SCM setting); | |
116 | SCM_API SCM scm_debug_options (SCM setting); | |
33b001fd | 117 | SCM_API SCM scm_make_debugobj (scm_t_debug_frame *debug); |
9fcf3cbb | 118 | |
102dbb6f LC |
119 | SCM_INTERNAL SCM scm_i_unmemoize_expr (SCM memoized); |
120 | SCM_INTERNAL void scm_init_debug (void); | |
c7ecd529 | 121 | |
f3667f52 | 122 | #ifdef GUILE_DEBUG |
33b001fd | 123 | SCM_API SCM scm_debug_hang (SCM obj); |
f3667f52 JB |
124 | #endif /*GUILE_DEBUG*/ |
125 | ||
5132eef0 | 126 | #if SCM_ENABLE_DEPRECATED == 1 |
434f2f7a | 127 | |
5132eef0 DH |
128 | #define CHECK_ENTRY scm_check_entry_p |
129 | #define CHECK_APPLY scm_check_apply_p | |
130 | #define CHECK_EXIT scm_check_exit_p | |
434f2f7a DH |
131 | |
132 | /* Deprecated in guile 1.7.0 on 2004-03-29. */ | |
133 | #define SCM_DEBUGGINGP scm_debug_mode_p | |
134 | #define scm_debug_mode scm_debug_mode_p | |
135 | ||
5132eef0 DH |
136 | #endif |
137 | ||
b29058ff | 138 | #endif /* SCM_DEBUG_H */ |
89e00824 ML |
139 | |
140 | /* | |
141 | Local Variables: | |
142 | c-file-style: "gnu" | |
143 | End: | |
144 | */ |