summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-12-18 06:46:31 -0800
committerKaz Kylheku <kaz@kylheku.com>2015-12-18 06:46:31 -0800
commit9e7cb4f19473571d76bf4b7b5ddc772ef8375a4e (patch)
tree50c4c631fcfbf1e7254e027e131e160bb219ec11
parenta574f6c3f0d30b59cd0a0778e4e83e9cb0b4c724 (diff)
downloadtxr-9e7cb4f19473571d76bf4b7b5ddc772ef8375a4e.tar.gz
txr-9e7cb4f19473571d76bf4b7b5ddc772ef8375a4e.tar.bz2
txr-9e7cb4f19473571d76bf4b7b5ddc772ef8375a4e.zip
New --debug-expansion option.
* txr.c (opt_dbg_expansion): New global variable. (help): Print summary for --debug-expansion. (txr_main): Recognize new option and set flag. * parser.y (parse_once): Suppress debug stepping around parser if opt_dbg_expansion is false. * txr.1 (opt_dbg_expansion): Declared. * txr.1: Documented new option.
-rw-r--r--parser.y10
-rw-r--r--txr.18
-rw-r--r--txr.c11
-rw-r--r--txr.h1
4 files changed, 29 insertions, 1 deletions
diff --git a/parser.y b/parser.y
index b22a7280..7fb42fec 100644
--- a/parser.y
+++ b/parser.y
@@ -52,6 +52,8 @@
#include "gc.h"
#include "args.h"
#include "cadr.h"
+#include "debug.h"
+#include "txr.h"
#include "parser.h"
static val sym_helper(parser_t *parser, wchar_t *lexeme, val meta_allowed);
@@ -1556,12 +1558,17 @@ void yybadtoken(parser_t *parser, int tok, val context)
int parse_once(val stream, val name, parser_t *parser)
{
int res = 0;
+#if CONFIG_DEBUG_SUPPORT
+ debug_state_t ds = debug_set_state(opt_dbg_expansion ? 0 : -1,
+ opt_dbg_expansion);
+#endif
parser_common_init(parser);
parser->stream = stream;
parser->name = name;
+
uw_catch_begin(cons(error_s, nil), esym, eobj);
res = yyparse(parser->scanner, parser);
@@ -1573,6 +1580,9 @@ int parse_once(val stream, val name, parser_t *parser)
uw_unwind {
parser_cleanup(parser);
+#if CONFIG_DEBUG_SUPPORT
+ debug_restore_state(ds);
+#endif
}
uw_catch_end;
diff --git a/txr.1 b/txr.1
index 0fd199c8..1c8f20c3 100644
--- a/txr.1
+++ b/txr.1
@@ -687,10 +687,16 @@ function for a description.
.meIP --debug-autoload
This option turns on debugging, like
.code --debugger
-but also arranges for stepping into the auto-load processing of
+but also requests stepping into the auto-load processing of
\*(TL library code. Normally, debugging through the evaluations
triggered by auto-loading is suppressed.
+.meIP --debug-expansion
+This option turns on debugging, like
+.code --debugger
+but also requests stepping into the parse-time macro-expansion
+of \*(TL code embedded in \*(TX queries. Normally, this is suppressed.
+
.coIP --help
Prints usage summary on standard output, and terminates successfully.
diff --git a/txr.c b/txr.c
index 991666bb..c1b3a838 100644
--- a/txr.c
+++ b/txr.c
@@ -63,6 +63,7 @@ static const char *progname_u8;
static val progpath = nil;
int opt_noninteractive;
int opt_compat;
+int opt_dbg_expansion;
val stdlib_path;
/*
@@ -154,6 +155,7 @@ static void help(void)
"--gc-delta=N Invoke garbage collection when malloc activity\n"
" increments by N megabytes since last collection.\n"
"--debug-autoload Allow debugger to step through library auto-loading.\n"
+"--debug-expansion Allow debugger to step through macro-expansion of query.\n"
"--yydebug Debug Yacc parser, if compiled with YYDEBUG support.\n"
"--gc-debug Enable a garbage collector stress test (slow).\n"
"--vg-debug Enable Valgrind integration, if compiled in.\n"
@@ -570,6 +572,15 @@ int txr_main(int argc, char **argv)
no_dbg_support(opt);
return EXIT_FAILURE;
#endif
+ } else if (equal(opt, lit("debug-expansion"))) {
+#if CONFIG_DEBUG_SUPPORT
+ opt_debugger = 1;
+ opt_dbg_expansion = 1;
+ continue;
+#else
+ no_dbg_support(opt);
+ return EXIT_FAILURE;
+#endif
} else if (equal(opt, lit("yydebug"))) {
if (have_yydebug) {
yydebug_onoff(1);
diff --git a/txr.h b/txr.h
index 0fe34df4..6d9d82ce 100644
--- a/txr.h
+++ b/txr.h
@@ -37,6 +37,7 @@ extern int opt_noninteractive;
extern int opt_compat;
extern int opt_debugger;
extern int opt_dbg_autoload;
+extern int opt_dbg_expansion;
extern alloc_bytes_t opt_gc_delta;
extern const wchli_t *version;
extern const wchar_t *progname;