From: Eric S. Raymond Date: Thu, 10 Nov 1994 19:30:39 +0000 (+0000) Subject: Four debug levels. X-Git-Tag: 1-2~50 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=42b4a1c0ccc29422a43565f6acfc9920ebf0cf08;p=cupl.git Four debug levels. --- diff --git a/cupl.h b/cupl.h index 8c8aee4..e8b5d52 100644 --- a/cupl.h +++ b/cupl.h @@ -162,6 +162,7 @@ extern bool cupl_ge(value, value); #define DEBUG_PARSEDUMP 1 #define DEBUG_CHECKDUMP 2 -#define DEBUG_ALLOCATE 3 +#define DEBUG_EXECUTE 3 +#define DEBUG_ALLOCATE 4 /* cupl.h ends here */ diff --git a/cupl.xml b/cupl.xml index b547759..448faae 100644 --- a/cupl.xml +++ b/cupl.xml @@ -96,3 +96,19 @@ at field-width precision. Also, by default, we wrap after three 20-char fields rather than 6, so as to fit on an 80-column line. Command-line options to change the line and field widths are available. +.P +.H 1 "Command-line options" +.P +The -w options sets the line width (default 80). +.P +The -f option sets the field width (default 20). +.P +The -v option enables debugging output. At level 1, the parse tree is +prettyprinted. At level 2, definition/reference counts for each +variable and label are printed after each run. At level 3, an +execution trace is displayed as the parse tree is printed. At level +4, each token intern and cons-cell allocation during parsing is also +dumped. + + + diff --git a/execute.c b/execute.c index 899cbf7..71b0238 100644 --- a/execute.c +++ b/execute.c @@ -128,7 +128,7 @@ static void eval_write(node *tp) static void display_return(node *tree, node *left, node *right, value v) /* display the returned value of a node (for tracing purposes) */ { - if (verbose >= DEBUG_ALLOCATE) + if (verbose >= DEBUG_EXECUTE) { (void) printf("eval returns: %x (%-10s of %9x, %9x) ", tree, tokdump(tree->type), left, right); @@ -164,7 +164,7 @@ static value cupl_eval(node *tree) int n; jmp_buf jmpperf; - if (verbose >= DEBUG_ALLOCATE) + if (verbose >= DEBUG_EXECUTE) (void) printf("eval begins: %x (%-10s of %9x, %9x)\n", tree, tokdump(tree->type), tree->car, tree->cdr); diff --git a/interpret.c b/interpret.c index f377be6..3656819 100644 --- a/interpret.c +++ b/interpret.c @@ -297,7 +297,19 @@ static void rewrite(node *tree) /* first, make a pointer from each label to its destination statement */ for_cdr(np, tree) if (np->car->type == LABEL) - np->car->car->syminf->target = np; + switch (np->car->cdr->type) + { + case END: + break; + + case BLOCK: + np->car->car->syminf->target = np; + break; + + default: + np->car->car->syminf->target = np; + break; + } /* figure end addresses */ for_cdr(np, tree)