diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-12-18 06:46:31 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-12-18 06:46:31 -0800 |
commit | 9e7cb4f19473571d76bf4b7b5ddc772ef8375a4e (patch) | |
tree | 50c4c631fcfbf1e7254e027e131e160bb219ec11 | |
parent | a574f6c3f0d30b59cd0a0778e4e83e9cb0b4c724 (diff) | |
download | txr-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.y | 10 | ||||
-rw-r--r-- | txr.1 | 8 | ||||
-rw-r--r-- | txr.c | 11 | ||||
-rw-r--r-- | txr.h | 1 |
4 files changed, 29 insertions, 1 deletions
@@ -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; @@ -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. @@ -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); @@ -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; |