From 3d7808ffb335b1b01fe49a2fcba5ddad62375109 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 20 Mar 2012 18:10:36 -0700 Subject: * debug.c (debug): Breakpointing now takes into account the module file name, not only the line number. Breakpoints work on source locations rather than line numbers. Boy, this was easy. Keep the breakpoint list free of duplicates. Issue a message if a nonexistent breakpoint is asked to be deleted. --- ChangeLog | 8 ++++++++ debug.c | 29 +++++++++++++++++++---------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6ea80d12..715cee67 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2012-03-20 Kaz Kylheku + + * debug.c (debug): Breakpointing now takes into account + the module file name, not only the line number. Breakpoints work on + source locations rather than line numbers. Boy, this was easy. + Keep the breakpoint list free of duplicates. Issue a message + if a nonexistent breakpoint is asked to be deleted. + 2012-03-18 Kaz Kylheku * eval.c (eval_init): url_decode has two parameters now, diff --git a/debug.c b/debug.c index 05e56d7e..980b8eb3 100644 --- a/debug.c +++ b/debug.c @@ -89,9 +89,10 @@ static void show_bindings(val env, val stream) val debug(val form, val bindings, val data, val line, val pos, val base) { uses_or2; - val lineno = car(source_loc(form)); + val loc = source_loc(form); + cons_bind (lineno, file, loc); - if (!step_mode && !memqual(lineno, breakpoints) + if (!step_mode && !memqual(loc, breakpoints) && (debug_depth > next_depth)) { return nil; @@ -103,7 +104,8 @@ val debug(val form, val bindings, val data, val line, val pos, val base) val input, command; if (print_form) { - format(std_debug, lit("stopped at ~a\n"), source_loc_str(form), nao); + format(std_debug, lit("stopped at line ~a of ~a\n"), + lineno, file, nao); format(std_debug, lit("form: ~s\n"), form, nao); format(std_debug, lit("depth: ~s\n"), num(debug_depth), nao); print_form = nil; @@ -175,22 +177,29 @@ val debug(val form, val bindings, val data, val line, val pos, val base) equal(command, lit("g"))) { if (!rest(input)) { - format(std_debug, lit("~s needs argument\n"), command, nao); + format(std_debug, lit("~s needs arguments\n"), command, nao); continue; } else { val n = int_str(second(input), num(10)); + val l = cons(n, or2(third(input), file)); if (!n) { - format(std_debug, lit("~s needs numeric argument\n"), command, nao); + format(std_debug, lit("~s needs [ ]\n"), + command, nao); continue; } - if (equal(command, lit("b"))) - push(n, &breakpoints); - else if (equal(command, lit("d"))) - breakpoints = remql(n, breakpoints); - else + if (equal(command, lit("b"))) { + breakpoints = remqual(l, breakpoints); + push(l, &breakpoints); + } else if (equal(command, lit("d"))) { + val breakpoints_old = breakpoints; + breakpoints = remqual(l, breakpoints); + if (breakpoints == breakpoints_old) + format(std_debug, lit("no such breakpoint\n")); + } else { opt_loglevel = c_num(n); + } } } else if (equal(command, lit("l"))) { format(std_debug, lit("breakpoints: ~s\n"), breakpoints, nao); -- cgit v1.2.3