From 9e7cb4f19473571d76bf4b7b5ddc772ef8375a4e Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 18 Dec 2015 06:46:31 -0800 Subject: 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. --- parser.y | 10 ++++++++++ txr.1 | 8 +++++++- txr.c | 11 +++++++++++ txr.h | 1 + 4 files changed, 29 insertions(+), 1 deletion(-) 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" @@ -569,6 +571,15 @@ int txr_main(int argc, char **argv) #else 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) { 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; -- cgit v1.2.3