diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-08-06 22:10:18 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-08-06 22:10:18 -0700 |
commit | c9a8bbd7f5308b9d165b0d21ff9b49bcd4fc070e (patch) | |
tree | 8faf588326a83c0d99b050a847e95b9a80dcd8a8 | |
parent | f93b24ace00a1800dd9540fa5268ce1c3bb6e61d (diff) | |
download | txr-c9a8bbd7f5308b9d165b0d21ff9b49bcd4fc070e.tar.gz txr-c9a8bbd7f5308b9d165b0d21ff9b49bcd4fc070e.tar.bz2 txr-c9a8bbd7f5308b9d165b0d21ff9b49bcd4fc070e.zip |
Suppress debug stepping into auto-loaded library code.
* debug.c (debug_set_state, debug_restore_state): New functions.
* debug.h (debug_state_t): New type.
(debug_set_state, debug_restore_state): Declared, and defined
as dummy macros in non-debug-support build.
* lisplib.c (opt_dbg_autoload): New global variable.
(lisplib_try_load): Disable or enable debugging around
library loading based on opt_dbg_autoload option.
* lisplib.h (opt_dbg_autoload): Declared.
* txr.c (help): List --debug-autoload option.
(no_dbg_support): New static function to avoid repeated code.
(txr_main): Add debugger option. Change duplicate no debug support
error messages into calls to no_dbg_support.
* txr.1: Document --debug-autoload
-rw-r--r-- | ChangeLog | 23 | ||||
-rw-r--r-- | debug.c | 14 | ||||
-rw-r--r-- | debug.h | 12 | ||||
-rw-r--r-- | lisplib.c | 8 | ||||
-rw-r--r-- | lisplib.h | 2 | ||||
-rw-r--r-- | txr.1 | 7 | ||||
-rw-r--r-- | txr.c | 28 |
7 files changed, 86 insertions, 8 deletions
@@ -1,5 +1,28 @@ 2015-08-06 Kaz Kylheku <kaz@kylheku.com> + Suppress debug stepping into auto-loaded library code. + + * debug.c (debug_set_state, debug_restore_state): New functions. + + * debug.h (debug_state_t): New type. + (debug_set_state, debug_restore_state): Declared, and defined + as dummy macros in non-debug-support build. + + * lisplib.c (opt_dbg_autoload): New global variable. + (lisplib_try_load): Disable or enable debugging around + library loading based on opt_dbg_autoload option. + + * lisplib.h (opt_dbg_autoload): Declared. + + * txr.c (help): List --debug-autoload option. + (no_dbg_support): New static function to avoid repeated code. + (txr_main): Add debugger-autoload option. Change duplicate no debug + support error messages into calls to no_dbg_support. + + * txr.1: Document --debug-autoload + +2015-08-06 Kaz Kylheku <kaz@kylheku.com> + * txr.c (txr_main): Bugfix: debugger long option nonfunctional. 2015-08-06 Kaz Kylheku <kaz@kylheku.com> @@ -241,6 +241,20 @@ val debug(val form, val bindings, val data, val line, val pos, val base) } } +debug_state_t debug_set_state(int depth, int step) +{ + debug_state_t old = { next_depth, step_mode }; + next_depth = depth; + step_mode = step; + return old; +} + +void debug_restore_state(debug_state_t state) +{ + next_depth = state.next_depth; + step_mode = state.step_mode; +} + void debug_init(void) { step_mode = 1; @@ -31,6 +31,11 @@ val debug(val form, val bindings, val data, val line, val pos, val base); #if CONFIG_DEBUG_SUPPORT +typedef struct { + int next_depth; + int step_mode; +} debug_state_t; + #define debug_enter \ { \ int debug_depth_save = debug_depth++; \ @@ -55,6 +60,8 @@ INLINE val debug_check(val form, val bindings, val data, val line, return (opt_debugger) ? debug(form, bindings, data, line, pos, base) : nil; } +debug_state_t debug_set_state(int depth, int step); +void debug_restore_state(debug_state_t); void debug_init(void); #define debug_frame(FUNC, ARGS, UBP, \ @@ -77,6 +84,8 @@ void debug_init(void); #else +typedef int debug_state_t; + #define debug_enter { #define debug_leave } @@ -98,6 +107,9 @@ INLINE val debug_check(val form, val bindings, val data, val line, #define debug_end \ } while (0) +#define debug_set_state(D, S) (0) +#define debug_restore_state(S) ((void) 0) + INLINE void debug_init(void) { } @@ -35,10 +35,12 @@ #include "stream.h" #include "hash.h" #include "gc.h" +#include "debug.h" #include "txr.h" #include "lisplib.h" val dl_table; +int opt_dbg_autoload; void set_dlt_entries(val dlt, val *name, val fun) { @@ -186,5 +188,9 @@ void lisplib_init(void) val lisplib_try_load(val sym) { val fun = gethash(dl_table, sym); - return if3(fun, (funcall(fun), t), nil); + debug_state_t ds; + return if3(fun, (ds = debug_set_state(opt_dbg_autoload ? 0 : -1, + opt_dbg_autoload), + funcall(fun), + debug_restore_state(ds), t), nil); } @@ -25,7 +25,7 @@ */ extern val dl_table; - +extern int opt_dbg_autoload; void lisplib_init(void); val lisplib_try_load(val sym); void set_dlt_entries(val dlt, val *name, val fun); @@ -671,6 +671,13 @@ See the .code gc-set-delta 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 +\*(TL library code. Normally, debugging through the evaluations +triggered by auto-loading is suppressed. + .coIP --help Prints usage summary on standard output, and terminates successfully. @@ -52,6 +52,7 @@ #include "eval.h" #include "regex.h" #include "arith.h" +#include "lisplib.h" #include "txr.h" const wchli_t *version = wli(TXR_VER); @@ -144,6 +145,7 @@ static void help(void) "--compat=N Synonym for -C N\n" "--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" "\n" "Options that take no argument can be combined. The -q and -v options\n" "are mutually exclusive; the right-most one dominates.\n" @@ -366,6 +368,15 @@ static int gc_delta(val optval) return 1; } +#ifndef CONFIG_DEBUG_SUPPORT +static void no_dbg_support(val arg) +{ + format(std_error, + lit("~a: option ~a requires debug support compiled in\n"), + prog_string, arg, nao); +} +#endif + int txr_main(int argc, char **argv) { val specstring = nil; @@ -500,9 +511,16 @@ int txr_main(int argc, char **argv) opt_debugger = 1; continue; #else - format(std_error, - lit("~a: option ~a requires debug support compiled in\n"), - prog_string, arg, nao); + no_dbg_support(arg); + return EXIT_FAILURE; +#endif + } else if (equal(opt, lit("debug-autoload"))) { +#if CONFIG_DEBUG_SUPPORT + opt_debugger = 1; + opt_dbg_autoload = 1; + continue; +#else + no_dbg_support(opt); return EXIT_FAILURE; #endif } else if (equal(opt, lit("noninteractive"))) { @@ -591,9 +609,7 @@ int txr_main(int argc, char **argv) #if CONFIG_DEBUG_SUPPORT opt_debugger = 1; #else - format(std_error, - lit("~a: option ~a requires debug support compiled in\n"), - prog_string, opch, nao); + no_dbg_support(opch); return EXIT_FAILURE; #endif break; |