summaryrefslogtreecommitdiffstats
path: root/debug.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2012-01-21 00:59:38 -0800
committerKaz Kylheku <kaz@kylheku.com>2012-01-21 00:59:38 -0800
commitb7bdc308cd6ce4dd4d3dd68c16eec792652f8c39 (patch)
tree07c7ebb1f183b60d2e838981fe2eaa6b307eebff /debug.h
parent3315a83172c4178176d1cf7634dfc69a8fd29edc (diff)
downloadtxr-b7bdc308cd6ce4dd4d3dd68c16eec792652f8c39.tar.gz
txr-b7bdc308cd6ce4dd4d3dd68c16eec792652f8c39.tar.bz2
txr-b7bdc308cd6ce4dd4d3dd68c16eec792652f8c39.zip
Improved debugging. Debug nesting depth counter maintained
and used for next/step/finish stepping. * Makefile (OBJS): debug.o moved to OBJS-y or OBJS-. (OBJS-y, OBJS-): New variables. $(PROG): Depends on OBJS-y also. clean: clean $(OBJS-y). depend: include $(OBJS-y) in dependency generation. * configure: Underscores and dashes are interchangeable in configure variables. (yaccname_given, yacc_given): Default value is y, not yes. (debug_support): New config variable. (CONFIG_DEBUG_SUPPORT): New config.h symbol. * debug.c (debug_depth): New global variable. (debug_block_s): New symbol variable. (next_depth): New static variable. (debug): Renamed some commands. Introduced separate next, step and finish. (debug_init): debug_block_s initialized. * debug.h (debug_depth, debug_block_s): Declared. (debug_enter, debug_leave, debug_return): New macros. (debug_check, debug_init): Conditionally defined based on if this is a debug build. * dep.mk: Regenerated. * eval.c (eval): Instrumented with debug_enter, debug_leave, debug_return. * match.c (match_line, v_fun, match_files): Likewise. * txr.c (txr_main): Bail if -d or --debug used in build that lacks debug support.
Diffstat (limited to 'debug.h')
-rw-r--r--debug.h57
1 files changed, 55 insertions, 2 deletions
diff --git a/debug.h b/debug.h
index b7248459..935746da 100644
--- a/debug.h
+++ b/debug.h
@@ -25,9 +25,32 @@
*/
extern int opt_debugger;
+extern int debug_depth;
+extern val debug_block_s;
val debug(val form, val bindings, val data, val line, val chr);
+#ifdef CONFIG_DEBUG_SUPPORT
+
+#define debug_enter \
+ { \
+ int debug_depth_save = debug_depth++; \
+ uw_block_begin(debug_block_s, debug_result); \
+ uw_simple_catch_begin {
+
+#define debug_leave \
+ } \
+ uw_unwind { \
+ debug_depth = debug_depth_save; \
+ } \
+ uw_catch_end; \
+ uw_block_end; \
+ return debug_result; \
+ }
+
+#define debug_return(VAL) \
+ uw_block_return(debug_block_s, VAL)
+
INLINE val debug_check(val form, val bindings, val data, val line, val chr)
{
return (opt_debugger) ? debug(form, bindings, data, line, chr) : nil;
@@ -40,13 +63,43 @@ void debug_init(void);
LINE, CHR) \
do { \
uw_frame_t db_env; \
- if (opt_debugger) \
+ if (opt_debugger) { \
uw_push_debug(&db_env, FUNC, ARGS,\
UBP, BINDINGS, DATA,\
LINE, CHR); \
+ } \
(void) 0
#define debug_end \
- if (opt_debugger) \
+ if (opt_debugger) { \
uw_pop_frame(&db_env); \
+ } \
} while (0)
+
+#else
+
+#define debug_enter {
+
+#define debug_leave }
+
+#define debug_return(VAL) return VAL
+
+INLINE val debug_check(val form, val bindings, val data, val line, val chr)
+{
+ return nil;
+}
+
+#define debug_begin(FUNC, ARGS, UBP, \
+ BINDINGS, DATA, \
+ LINE, CHR) \
+ do { \
+ (void) 0
+
+#define debug_end \
+ } while (0)
+
+INLINE void debug_init(void)
+{
+}
+
+#endif