diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2012-01-21 00:59:38 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2012-01-21 00:59:38 -0800 |
commit | b7bdc308cd6ce4dd4d3dd68c16eec792652f8c39 (patch) | |
tree | 07c7ebb1f183b60d2e838981fe2eaa6b307eebff /debug.c | |
parent | 3315a83172c4178176d1cf7634dfc69a8fd29edc (diff) | |
download | txr-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.c')
-rw-r--r-- | debug.c | 22 |
1 files changed, 19 insertions, 3 deletions
@@ -15,7 +15,10 @@ #include "parser.h" int opt_debugger; +int debug_depth; +val debug_block_s; static int step_mode; +static int next_depth = -1; val breakpoints; val last_command = lit(""); @@ -49,7 +52,9 @@ val debug(val form, val bindings, val data, val line, val chr) uses_or2; val lineno = source_loc(form); - if (!step_mode && !memqual(lineno, breakpoints)) { + if (!step_mode && !memqual(lineno, breakpoints) + && (debug_depth > next_depth)) + { return nil; } else { val print_form = t; @@ -61,6 +66,7 @@ val debug(val form, val bindings, val data, val line, val chr) if (print_form) { format(std_output, lit("stopped at line ~a\n"), lineno, nao); format(std_output, lit("form: ~s\n"), form, nao); + format(std_output, lit("depth: ~s\n"), num(debug_depth), nao); print_form = nil; } @@ -92,13 +98,22 @@ val debug(val form, val bindings, val data, val line, val chr) continue; } else if (equal(command, lit("c"))) { step_mode = 0; + next_depth = -1; return nil; - } else if (equal(command, lit("n"))) { + } else if (equal(command, lit("s"))) { step_mode = 1; return nil; + } else if (equal(command, lit("n"))) { + step_mode = 0; + next_depth = debug_depth; + return nil; + } else if (equal(command, lit("f"))) { + step_mode = 0; + next_depth = debug_depth - 1; + return nil; } else if (equal(command, lit("v"))) { show_bindings(bindings, std_output); - } else if (equal(command, lit("f"))) { + } else if (equal(command, lit("i"))) { print_form = t; } else if (equal(command, lit("d"))) { print_data = t; @@ -139,4 +154,5 @@ void debug_init(void) { step_mode = 1; protect(&breakpoints, &last_command, (val *) 0); + debug_block_s = intern(lit("debug-block"), system_package); } |