summaryrefslogtreecommitdiffstats
path: root/debug.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2012-03-20 18:10:36 -0700
committerKaz Kylheku <kaz@kylheku.com>2012-03-20 18:10:36 -0700
commit3d7808ffb335b1b01fe49a2fcba5ddad62375109 (patch)
tree93f1d65bf707879bdd3c645b95d9f440073e0dfe /debug.c
parent9d06c8e9b36e94295c62eb0598cff7afae0c5a45 (diff)
downloadtxr-3d7808ffb335b1b01fe49a2fcba5ddad62375109.tar.gz
txr-3d7808ffb335b1b01fe49a2fcba5ddad62375109.tar.bz2
txr-3d7808ffb335b1b01fe49a2fcba5ddad62375109.zip
* 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.
Diffstat (limited to 'debug.c')
-rw-r--r--debug.c29
1 files changed, 19 insertions, 10 deletions
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 <line> [ <file> ]\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);