summaryrefslogtreecommitdiffstats
path: root/match.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2011-11-13 21:19:43 -0800
committerKaz Kylheku <kaz@kylheku.com>2011-11-13 21:19:43 -0800
commit1232f5dbf8e68f9c3a7fe77360c0b950ecff3eac (patch)
tree18cb4ab7caf1d2b42139f98c80691e641a76efdd /match.c
parentcc0f30f375914382e9e94e5bba26b14b2a734499 (diff)
downloadtxr-1232f5dbf8e68f9c3a7fe77360c0b950ecff3eac.tar.gz
txr-1232f5dbf8e68f9c3a7fe77360c0b950ecff3eac.tar.bz2
txr-1232f5dbf8e68f9c3a7fe77360c0b950ecff3eac.zip
Adding a debugger. This is an experimental prototype.
* Makefile (OBJS): New object file debug.o. * dep.mk: Updated. * match.c (h_fun): Use debug_begin and debug_end macros to set up a debug frame for backtracing. (match_line, match_files): Call debug_check to give debugger a chance to instrument call. (v_fun): Use debug_begin and debug_end macros to set up a debug frame for backtracing. Call debug_check to give debugger a chance to instrument call. * stream.c (struct strm_ops): New function pointer, flush. (stdio_maybe_write_error): Wrong word in error message corrected. (stdio_flush): New static function. (stdio_ops, pipe_ops): New function entered into tables. (flush_stream): New function. * stream.h (flush_stream): Declared. * txr.c (help): New options documented. (main): call to debug_init added. New debug options parsed and opt_debugger set accordingly. * unwind.c (uw_push_debug, uw_current_frame): New function. * unwind.h (uw_frtype): New enumeration member UW_DBG. (struct uw_debug): New frame variant. (union uw_frame): New member, db. (uw_push_debug, uw_current_frame): Declared, * debug.c: New file. * debug.h: New file.
Diffstat (limited to 'match.c')
-rw-r--r--match.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/match.c b/match.c
index a26f8191..0948ce37 100644
--- a/match.c
+++ b/match.c
@@ -43,6 +43,7 @@
#include "utf8.h"
#include "filter.h"
#include "hash.h"
+#include "debug.h"
#include "match.h"
int output_produced;
@@ -928,9 +929,11 @@ static val h_fun(match_line_ctx c, match_line_ctx *cout)
{
uw_block_begin(nil, result);
uw_env_begin;
+ debug_begin(sym, args, ub_p_a_pairs, c.bindings, c.dataline, c.data_lineno, c.pos);
result = match_line(ml_bindings_specline(c, bindings_cp, body));
+ debug_end;
uw_env_end;
uw_block_end;
@@ -995,6 +998,8 @@ static val match_line(match_line_ctx c)
elem = first(c.specline);
+ debug_check(elem, c.bindings, c.dataline, c.data_lineno, c.pos);
+
switch (elem ? type(elem) : 0) {
case CONS: /* directive */
{
@@ -2844,6 +2849,8 @@ static val v_fun(match_files_ctx *c)
val piter, aiter;
val bindings_cp = copy_alist(c->bindings);
+ debug_check(specline, c->bindings, if2(consp(c->data), car(c->data)), c->data_lineno, nil);
+
if (!equal(length(args), length(params)))
sem_error(specline, lit("function ~a takes ~a argument(s)"),
sym, length(params), nao);
@@ -2873,7 +2880,10 @@ static val v_fun(match_files_ctx *c)
{
uw_block_begin(nil, result);
uw_env_begin;
+ debug_begin(sym, args, ub_p_a_pairs, c->bindings, if2(consp(c->data), car(c->data)),
+ c->data_lineno, nil);
result = match_files(mf_spec_bindings(*c, body, bindings_cp));
+ debug_end;
uw_env_end;
uw_block_end;
@@ -2979,7 +2989,11 @@ repeat_spec_same_data:
if (entry) {
v_match_func vmf = (v_match_func) cptr_get(entry);
- val result = vmf(&c);
+ val result;
+
+ debug_check(first_spec, c.bindings, if2(consp(c.data), car(c.data)), c.data_lineno, nil);
+
+ result = vmf(&c);
if (result == next_spec_k) {
if ((c.spec = rest(c.spec)) == nil)