summaryrefslogtreecommitdiffstats
path: root/debug.c
Commit message (Collapse)AuthorAgeFilesLines
* Header file cleanup.Kaz Kylheku2016-01-221-2/+0
| | | | | | | * arith.c, cadr.c, debug.c, eval.c, filter.c, gencadr.txr, glob.c, hash.c, linenoise/linenoise.c, lisplib.c, match.c, parser.c, rand.c, regex.c, signal.c, stream.c, struct.c, sysif.c, syslog.c, txr.c, unwind.c, utf8.c: Remove unncessary header files.
* Copyright year bump.Kaz Kylheku2015-12-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | * LICENSE, METALICENSE, Makefile, args.c, args.h, arith.c, arith.h, cadr.c, cadr.h, combi.c, combi.h, configure, debug.c, debug.h, eval.c, eval.h, filter.c, filter.h, gc.c, gc.h, glob.c, glob.h, hash.c, hash.h, jmp.S, lib.c, lib.h, lisplib.c, lisplib.h, match.c, match.h, parser.c, parser.h, parser.l, parser.y, rand.c, rand.h, regex.c, regex.h, share/txr/stdlib/cadr.tl, share/txr/stdlib/except.tl, share/txr/stdlib/hash.tl, share/txr/stdlib/ifa.tl, share/txr/stdlib/path-test.tl, share/txr/stdlib/place.tl, share/txr/stdlib/struct.tl, share/txr/stdlib/txr-case.tl, share/txr/stdlib/type.tl, share/txr/stdlib/with-resources.tl, share/txr/stdlib/with-stream.tl, share/txr/stdlib/yield.tl, signal.c, signal.h, stream.c, stream.h, struct.c, struct.h, sysif.c, sysif.h, syslog.c, syslog.h, txr.1, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h: Add 2016 copyright. * linenoise/LICENSE, linenoise/linenoise.c, linenoise/linenoise.h: Bump one principal author's copyright from 2014 to 2015. The code is based on a snapshot of 2015 upstream work.
* Refactor propagation of contexts in evaluator.Kaz Kylheku2015-11-301-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The context form arguments become just context objects in various places. When a context form is actually needed, or the context's symbolic name, they must be retrieved via functions applied to a context. * debug.c (debug): form argument is now a context. Use the ctx_form function to retrieve the form. * debug.h (debug_check): Rename form parameter to ctx. * eval.c (ctx_form, ctx_name): New functions. (eval_error): Leftmost parameter is a context now. Use ctx_form API to obtain the context form from this object, from which the source location info can then be retrieved as before. (abbrev_ctx): Function removed. (bind_args, bindings_helper, fbindings_helper): Convert ctx_form argument to ctx, and use the API to access name or form. (do_eval, do_eval_args, eval, eval_args_lisp1, eval_lisp1, eval_progn, eval_prog1): ctx_form param renamed to ctx. (funcall_interp): Pass the original interpreted function as the context to bind_args, not the extracted code. When ctx_name sees this object, it will compute the function name, which was not possible from the code being used as the context. This is the big reason for all these changes. * eval.h (eval_error): Declaration updated. (ctx_form, ctx_name): Declared.
* Implementing *print-base* and ~d format directive.Kaz Kylheku2015-11-141-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * debug.c (show_bindings): Use ~d for level, so as not to be influenced by *print-base*. (debug): Use ~d for line numbers. * lib.c (gensym): Use ~d conversion specifier for formatting gensym counter into symbol name. * match.c (LOG_MISMATCH, LOG_MATCH): Use ~d for line number references. (h_skip, h_coll, h_fun, h_chr, match_line_completely, v_skip, v_fuzz, v_gather, v_collect, v_output, v_filter, v_fun, v_assert, v_load, v_line, h_assert, open_data_source): Use ~d for line refs, number of iterations, errno values. * parser.c (repl): Use ~d for prompt line numbers, numbered variables and the expr-<n> string in error messages. * parser.l (yyerrorf, source_loc_str): Use ~d for line numbers. * stream.c (print_base_s): New symbol variable. (formatv): Implement *print-base*. (stdio_maybe_read_error, stdio_maybe_error, stdio_close, pipe_close, open_directory, open_file, open_fileno, open_tail, open_process, run, remove_path): Use ~d for errno values. (stream_init): Initialize print_base_s and register *print-base* special variable. sysif.c (mkdir_wrap, ensure_dir, getcwd_wrap, mknod_wrap, chmod_wrap, symlink_wrap, link_wrap, readlink_wrap, excec_wrap, stat_impl, pipe_wrap, poll_wrap, getgroups_wrap, setuid_wrap, seteuid_wrap, setgid_wrap): Use ~d for errno values and system function results. * txr.1: Documented *print-base* and ~d conversion specifier.
* Stop using C library setjmp/longjmp.Kaz Kylheku2015-10-251-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TXR is moving to custom assembly-language routines. This is mainly motivated by a very dubious thing done in the GNU C Library setjmp and longjmp in the name of security. Evidently, glibc's setjmp "mangles" certain pointer values which are stored into the jmp_buf buffer. It's been that way since 2005, evidently. This means that, firstly, all along, the use of setjmp in gc.c to get registers into a buffer so they can be scanned has not actually worked properly. More importantly, this pointer mangling in setjmp and longjmp is very hostile to a stack copying implementation of delimited continuations. The reason is that continuations contain jmp_buf buffers, which get relocated in the process of capturing and reviving a continuation. Any pointers in a jmp_buf which point into the captured stack segment have to be fixed up to point into the relocated location. Mangled pointers make this difficult, requiring hacks which are specific to glibc and the machine architecture. We might as well implement a clean, well-behaved setjmp and longjmp. * Makefile (jmp.o): New object file. (dbg/%.o, opt/%.o): New rules for .S prerequisites. * args.c, arith.c, cadr.c, combi.c, cadr.c, combi.c, debug.c, eval.c, filter.c, glob.c, hash.c, lib.c, match.c, parser.c, rand.c, regex.c, signal.c, stream.c, struct.c, sysif.c, syslog.c, txr.c, unwind.c, utf8.c: Removed <setjmp.h> include. * gc.c: Switch to struct jmp and jmp_save, instead of jmp_buf and setjmp. * jmp.S: New source file. * signal.h (struct jmp): New struct type. (jmp_save, jmp_restore): New function declarations denoting assembly language routines in jmp.S. (extended_jmp_buf): Uses struct jmp instead of setjmp. (extended_setjmp): Use jmp_save instead of setjmp. (extended_longjmp): Use jmp_restore instead of longjmp.
* Use of new args for function calls in interpreter.Kaz Kylheku2015-08-231-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * args.c (args_copy_to_list): New function. * args.h (ARGS_MIN): New preprocessor symbol. (args_add_list): New inline function. (args_copy_to_list): Declared. * debug.c (debug): Args in debug frame are now struct args *. Pull them out nondestructively for printing using args_copy_to_list. * eval.c (do_eval_args): Fill struct args argument list rather than returning evaluated list. Dot position evaluation is handled by installing the dot position value as args->list. (do_eval): Allocate args of at least ARGS_MAX for the call to do_eval_args. Then use generic_funcall to invoke the function rather than apply. (eval_args_lisp1): Modified similarly to do_eval_args. (eval_lisp1): New static function. (expand_macro): Construct struct args argument list for the sake of debug_frame. (op_dwim): Allocate args which are filled by eval_args_lisp1, and applied to the function/object with generic_funcall. The object expression is separately evaluated with eval_lisp1. * match.c (h_fun, v_fun): Construct struct args arglist for the sake of debug_frame call. * unwind.c (uw_push_debug): args argument becomes struct args *. * unwind.h (struct uw_debug): args member becomes struct args *. (uw_push_debug): Declaration updated. * txr.1: Update documentation about dot position argument in function calls. (list . a) now works, which previously didn't.
* Change to different exception for debugger quit.Kaz Kylheku2015-08-071-1/+4
| | | | | | * debug.c (debug_quit_s): New global variable. (debug): Throw debug-quit, not query-error. (debug_init): Initialize debug_quit_s.
* * debug.c (help): Rearrange menu. Show missing quit command.Kaz Kylheku2015-08-061-3/+2
|
* Suppress debug stepping into auto-loaded library code.Kaz Kylheku2015-08-061-0/+14
| | | | | | | | | | | | | | | | | | | | | * 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
* Ligher weight debug instrumentation.Kaz Kylheku2015-05-221-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This speeds up the TXR Lisp interpreter, because do_eval sets up a debug frame and uses debug_return. * debug.c (debug_block_s): Symbol removed. (debug_init): Remove initialization of debug_block_s. * debug.h (debug_block_s): Declaration removed. (debug_enter): Do not establish a named block or a catch block; no time-wasting unwind stack manipulation at all. The debug_depth variable is managed by the extended setjmp context now. Provide a return value variable, and a well-defined name to branch to to exit from the debug block. (debug_return): Do not use heavy-weight uw_block_return; simply set the return variable and branch to debug_return_out label. * signal.h (EJ_DBG_MEMB, EJ_DBG_SAVE, EJ_DBG_REST, EJ_OPT_MEMB, EJ_OPT_SAVE, EJ_OPT_REST): New macros. (extended_jmp_buf): Define optional global state variables using EJ_OPT_MEMB. (extended_setjmp): Save and restore optional globals using EJ_OPT_SAVE and EJ_OPT_RESTORE. Now debug_depth is saved and restored if debugging support is compiled in. * match.c (open_data_source): Remove bogus debug_return invocations which were uncovered here by changes to the macro. * eval.c (do_eval, expand_macro): debug_return must now be after debug_end, because it won't dynamically clean up frames that it doesn't know about. The set_dyn_env is no longer unreachable in expand_macro; it is now necessary because debug_return isn't doing the longjmp that previously restored dyn_env.
* Update copyright notices from 2014 to 2015.Kaz Kylheku2015-02-011-1/+1
| | | | | | | | | | | * arith.c, arith.h, combi.c, combi.h, debug.c, debug.h, eval.c, eval.h, filter.c, filter.h, gc.c, gc.h, hash.c, hash.h, lib.c, lib.h, match.c, match.h, parser.h, rand.c, rand.h, regex.c, regex.h, signal.c, signal.h, stream.c, stream.h, sysif.c, sysif.h, syslog.c, syslog.h, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h: Update. * LICENSE, METALICENSE: Likewise.
* * Makefile: Removing trailing spaces.Kaz Kylheku2014-10-241-2/+2
| | | | | | | | | | (GREP_CHECK): New macro. (enforce): Rewritten using GREP_CHECK, with new checks. * arith.c, combi.c, debug.c, eval.c, filter.c, gc.c, hash.c, lib.c, * lib.h, match.c, parser.l, parser.y, rand.c, regex.c, signal.c, * signal.h, stream.c, syslog.c, txr.c, unwind.c, utf8.c: Remove trailing spaces.
* Converting cast expressions to macros that are retargettedKaz Kylheku2014-10-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | to C++ style casts when compiling as C++. * lib.h (strip_qual, convert, coerce): New casting macros. (TAG_MASK, tag, type, wli_noex, auto_str, static_str, litptr, num_fast, chr, lit_noex, nil, nao): Use cast macros. * arith.c (mul, isqrt_fixnum, bit): Use cast macros. * configure (INT_PTR_MAX): Define using cast macro. * debug.c (debug_init): Use cast macro. * eval.c (do_eval, expand_macro, reg_op, reg_mac, eval_init): Use cast macros. * filter.c (filter_init): Use cast macro. * gc.c (more, mark_obj, in_heap, mark, sweep_one, unmark): Use cast macros. * hash.c (hash_double, equal_hash, eql_hash, hash_equal_op, hash_hash_op, hash_print_op, hash_mark, make_hash, make_similar_hash, copy_hash, gethash_c, gethash, gethash_f, gethash_n, remhash, hash_count, get_hash_userdata, set_hash_userdata, hash_iter_destroy, hash_iter_mark, hash_begin, hash_uni, hash_diff, hash_isec): Use cast macros. * lib.c (code2type, chk_malloc, chk_malloc_gc_more, chk_calloc, chk_realloc, chk_strdup, num, c_num, string, mkstring, mkustring, upcase_str, downcase_str, string_extend, sub_str, cat_str, trim_str, c_chr, vector, vec_set_length, copy_vec, sub_vec, cat_vec, cobj_print_op, obj_init): Likewise. * match.c (do_match_line, hv_trampoline, match_files, dir_tables_init): Likewise. * parser.l (grammar): Likewise. * parser.y (parse): Likewise. * rand.c (make_state, make_random_state, random_fixnum, random): Likewise. * regex.c (CHAR_SET_L2_LO, CHAR_SET_L2_HI, CHAR_SET_L1_LO, CHAR_SET_L1_HI, CHAR_SET_L0_LO, CHAR_SET_L0_HI, L0_full, L0_fill_range, L1_full, L1_fill_range, L1_contains, L1_free, L2_full, L2_fill_range, L2_contains, L2_free, L3_fill_range, L3_contains, L3_free, char_set_create, char_set_cobj_destroy, nfa_state_accept, nfa_state_empty, nfa_state_single, nfa_state_wild, nfa_state_set,
* * Makefile, arith.c, arith.h, combi.c, combi.h, configure, debug.c,Kaz Kylheku2014-07-231-16/+16
| | | | | | | | debug.h, eval.c, eval.h, filter.c, filter.h, gc.c, gc.h, hash.c, hash.h, lib.c, lib.h, match.c, match.h, parser.h, parser.l, parser.y, rand.c, rand.h, regex.c, regex.h, signal.c, signal.h, stream.c, stream.h, syslog.c, syslog.h, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h: Synchronize license header with LICENSE.
* * configure: Add a check, in the case that we cannot make anKaz Kylheku2014-07-221-0/+7
| | | | | | | | | | | | | | | | | executable, whether this is due to being required to use C99. For instance, the Solaris environment requires compilation using the C99 dialect if _XOPEN_SOURCE is set to 600 or higher. * debug.c: When compiling as C99, we have to obey the special C99 conventions for instantiating inline functions. * hash.c: Likewise. * lib.c: Likewise. * parser.y: Likewise. * unwind.c: Likewise.
* Change to how locations are passed around, for the sake of generationalKaz Kylheku2014-03-291-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GC. The issue being solved here is the accuracy of the gc_set function. The existing impelmentation is too conservative. It has no generation information about the memory location being stored, and so it assumes the worst: that it is a location in the middle of a gen 1 object. This is sub-optimal, creating unacceptable pressure against the checkobj array and, worse, as a consequence causing unreachable gen 0 objects to be tenured into gen 1. To solve this problem, we replace "val *" pointers with a structure of type "loc" which keeps track of the object too, which lets us discover the generation. I tried another approach: using just a pointer with a bitfield indicating the generation. This turned out to have a serious issue: such a bitfield goes stale when the object is moved to a different generation. The object holding the memory location is in gen 1, but the annotated pointer still indicates gen 0. The gc_set function then makes the wrong decision, and premature reclamation takes place. * combi.c (perm_init_common, comb_gen_fun_common, rcomb_gen_fun_common, rcomb_list_gen_fun): Update to new interfaces for managing mutation. * debug.c (debug): Update to new interfaces for managing mutation. Avoid loc variable name. * eval.c (env_fbind, env_fbind): Update to new interfaces for managing mutation. (lookup_var_l, dwim_loc): Return loc type and update to new interfaces. (apply_frob_args, op_modplace, op_dohash, transform_op, mapcarv, mappendv, repeat_infinite_func, repeat_times_func): Update to new interfaces for managing mutation. * eval.h (lookup_var_l): Declaration updated. * filter.c (trie_add, trie_compress, trie_compress_intrinsic, * build_filter, built_filter_from_list, filter_init): Update to new * interfaces. * gc.c (gc_set): Rewritten to use loc type which provides the exact generation. We do not need the in_malloc_range hack any more, since we have the backpointer to the object. (gc_push): Take loc rather than raw pointer. * gc.h (gc_set, gc_push): Declarations updated. * hash.c (struct hash): The acons* functions use loc instead of val * now. (hash_equal_op, copy_hash, gethash_c, inhash, gethash_n, pushhash, Change to how locations are passed around, for the sake of generational GC. The issue being solved here is the accuracy of the gc_set function. The existing impelmentation is too conservative. It has no generation information about the memory location being stored, and so it assumes the worst: that it is a location in the middle of a gen 1 object. This is sub-optimal, creating unacceptable pressure against the checkobj array and, worse, as a consequence causing unreachable gen 0 objects to be tenured into gen 1. To solve this problem, we replace "val *" pointers with a structure of type "loc" which keeps track of the object too, which lets us discover the generation. I tried another approach: using just a pointer with a bitfield indicating the generation. This turned out to have a serious issue: such a bitfield goes stale when the object is moved to a different generation. The object holding the memory location is in gen 1, but the annotated pointer still indicates gen 0. The gc_set function then makes the wrong decision, and premature reclamation takes place. * combi.c (perm_init_common, comb_gen_fun_common, rcomb_gen_fun_common, rcomb_list_gen_fun): Update to new interfaces for managing mutation. * debug.c (debug): Update to new interfaces for managing mutation. Avoid loc variable name. * eval.c (env_fbind, env_fbind): Update to new interfaces for managing mutation. (lookup_var_l, dwim_loc): Return loc type and update to new interfaces. (apply_frob_args, op_modplace, op_dohash, transform_op, mapcarv, mappendv, repeat_infinite_func, repeat_times_func): Update to new interfaces for managing mutation. * eval.h (lookup_var_l): Declaration updated. * filter.c (trie_add, trie_compress, trie_compress_intrinsic, * build_filter, built_filter_from_list, filter_init): Update to new * interfaces. * gc.c (gc_set): Rewritten to use loc type which provides the exact generation. We do not need the in_malloc_range hack any more, since we have the backpointer to the object. (gc_push): Take loc rather than raw pointer. * gc.h (gc_set, gc_push): Declarations updated. * hash.c (struct hash): The acons* functions use loc instead of val * now. (hash_equal_op, copy_hash, gethash_c, inhash, gethash_n, pushhash,
* * debug.c (debug): Fix 2013-12-02 regression, which leaves theKaz Kylheku2014-02-241-1/+4
| | | | debugger not printing the current line of data.
* The C function nullp is being renamed to null, and the rarelyKaz Kylheku2014-02-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | used global variable null which holds a symbol becomes null_s. A new macro called nilp is added that more efficiently checks whether an object is nil, producing a C boolean value rather than t or nil. Most of the uses of nullp in the codebase just become the more streamlined nilp. * debug.c (show_bindings): nullp to nilp * eval.c (lookup_var, lookup_var_l, lookup_fun, lookup_sym_lisp1, do_eval, expand_qquote, expand_quasi, expand_op): nullp to nilp. (op_modplace): nullp to null. (eval_init): Update registration of null and not from C function nullp to null. * filter.c (trie_compress, html_hex_continue): nullp to nil. (filter_string_tree): null to null_s. * hash.c (hash_next): nullp to nilp. * lib.c (null): Variable renamed to null_s. (code2type): null to null_s. (lazy_flatten_scan, chainv, lazy_str, lazy_str_force_upto, obj_print, obj_pprint): nullp to nilp. (obj_init): null to null_s; nullp to null. * lib.h (null): declaration changed to null_s. (nullp): Inline function renamed to null. (nilp): New macro. * match.c (do_match_line): nullp to nilp. * rand.c (make_random_state): Likewise. * regex.c (compile_regex): Likewise.
* First cut at signal handling support.Kaz Kylheku2013-12-121-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Makefile (OBJS-y): Include signal.o if have_posix_sigs is "y". * configure (have_posix_sigs): New variable, set by detecting POSIX signal stuff. * dep.mk: Regenerated. * arith.c, debug.c, eval.c, filter.c, hash.c, match.c, parser.y, parser.l, rand.c, regex.c, syslog.c, txr.c, utf8.c: Include new signal.h header, now required by unwind, and the <signal.h> system header. * eval.c (exit_wrap): New function. (eval_init): New functions registered as intrinsics: exit_wrap, set_sig_handler, get_sig_handler, sig_check. * gc.c (release): Unused functions removed. * gc.h (release): Declaration removed. * lib.c (init): Call sig_init. * stream.c (set_putc, se_getc, se_fflush): New static functions. (stdio_put_char_callback, stdio_get_char_callback, stdio_put_byte, stdio_flush, stdio_get_byte): Use new functions to enable signals when blocked on I/O. (tail_strategy): Allow signals across sleep. (pipev_close): Allow signals across waitpid. (se_pclose): New static function. (pipe_close): Use new function to enable signals across pclose. * unwind.c (uw_unwind_to_exit_point): use extended_longjmp instead of longjmp. * unwind.h (struct uw_block, struct uw_catch): jb member changes from jmp_buf to extended_jmp_buf. (uw_block_begin, uw_simple_catch_begin, uw_catch_begin): Use extended_setjmp instead of setjmp. * signal.c: New file. * signal.h: New file.
* Bumping copyrights to 2014 and expressing them as year ranges.Kaz Kylheku2013-12-101-3/+1
| | | | Fixing some errors in copyright comments.
* debug_check calls are the culprit triggering lookaheadKaz Kylheku2013-12-021-0/+2
| | | | | | | | | | | | | in lazy lists. Changing the semantics of the data argument so that it can just be the list. * debug.c (debug): If data is a cons, then replace it with the first item. * match.c (match_files): Pass c.data to debug_check, rather than the value of if2(consp(c.data), car(c.data)) which accesses car(c.data) whether or not we are debugging. (match_fun): Likewise.
* * debug.c (help): Help text updated.Kaz Kylheku2013-01-101-2/+2
| | | | | (debug): Fix conflicting command assignment. Show form is now 'o'.
* * debug.c (debug): Breakpointing now takes into accountKaz Kylheku2012-03-201-10/+19
| | | | | | | the module file name, not only the line number. Breakpoints work on source locations rather than line numbers. Boy, this was easy. Keep the breakpoint list free of duplicates. Issue a message if a nonexistent breakpoint is asked to be deleted.
* * debug.c (help, debug): New g command for tweaking log level.Kaz Kylheku2012-02-281-5/+16
|
* * debug.c: Missing d command implemented.Kaz Kylheku2012-02-281-3/+11
| | | | | | | | | | Condense the output to 8 times the screen width, for more context. Condense the output in vertical mode (when the entire input line is shown) not only character mode. * lib.c (remq, remql, remqual): New functions. * lib.h (remq, remql, remqual): Declared.
* Fix the issue properly, once and for all, of how to determineKaz Kylheku2012-02-271-15/+15
| | | | | | | | | | | | | | | | that output has taken place and suppress the printing of bindings. * debug.c (debug): std_output replaced with std_debug. * eval.c (eval_init): Registered new *stddebug* variable. * stream.c (std_debug): New variable. (stdio_put_string): Check that stream is other than std_debug, to determine that output has taken place. * stream.h (std_debug): Declared. * txr.1: Added *stddebug* to documentation stub heading.
* * arith.c: Updated copyright year.Kaz Kylheku2012-02-251-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * arith.h: Likewise. * debug.c: Added copyright header. * debug.h: Updated copyright year. * eval.c: Likewise. * eval.h: Likewise. * filter.c: Likewise. * filter.h: Likewise. * gc.c: Likewise. * gc.h: Likewise. * hash.c: Likewise. * hash.h: Likewise. * lib.c: Likewise. * lib.h: Likewise. * match.c: Likewise. * match.h: Likewise. * parser.h: Likewise. * regex.c: Likewise. * regex.h: Likewise. * stream.c: Likewise. * stream.h: Likewise. * txr.c: Likewise, and e-mail address. * txr.h: Updated copyright year. * unwind.c: Likewise. * unwind.h: Likewise.
* * debug.c (debug): Use new way of getting line number.Kaz Kylheku2012-02-241-2/+2
| | | | | | | | | | | | | | * eval.c (eval_error): Use source_loc_str to get source location. * match.c (debuglf, sem_err, file_err): Likewise. * parser.h (source_loc_str): Declared. * parser.l (parse_init): form_to_ln_hash must be equal based now. * parser.y (rl): Store new form of read-time source location info. * txr.1: Documented load.
* Introducing optional arguments.Kaz Kylheku2012-02-211-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * debug.c (help, show_bindings): put_string arguments reversed. * eval.c (bind_args): Support colon notation in interpreted function lambda lists for optional arguments. Improved error checking. (apply): Allow optional arguments to be left out. (dwim_loc): Reversed arguments to replace_str, replace_vec, replace_list. (eval_init): Numerous intrinsics now have arguments that are optional. New function rand introduced which reverses arguments relative to random. New intrinsic function hash introduced for alternative construction of hashes. * gc.c (sweep): Reversed arguments to put_char. * hash.c (weak_keys_k, weak_vals_k, equal_based_k): New keyword symbol variables. (hashv): New function. (hash_init): Intern new symbols. * hash.h (weak_keys_k, weak_vals_k, equal_based_k, hashv): Declared. * lib.c (colon_k): New keyword symbol variable. (replace_list, replace_str, replace_vec): Arguments rearranged. (tree_find): testfun becomes optional argument. (int_str): base becomes optional argument. (func_f0, func_f1, func_f2, func_f3, func_f4, func_n0, func_n1, func_n2, func_n3, func_n4, func_f0v, func_f1v, func_f2v, func_f3v, func_f4v, func_n0v, func_n1v, func_n2v, func_n3v, func_n4v, func_interp): Initialize optargs to zero. (func_n0o, func_n1o, func_n2o, func_n3o, func_n4o): New functions. (cobj_print_op): Reversed arguments to put_string. (find): testfun and keyfun become optional arguments. (replace): Parameters rearranged and arguments rearranged in calls to replace_list, replace_str and replace_vec. (obj_init): colon_k initialized. (obj_print, obj_pprint): Arguments reversed, and stream defaults to std_output. Arguments reversed in calls to put_char and put_string. (dump): Arguments reversed in call to put_char. * lib.h (struct func): sizes of minparam, fixparam bitfields adjusted. New bitfield optargs. New unnamed bitfield added so the previous ones add up to 16 bits. (colon_k): Declared. (func_n0o, func_n1o, func_n2o, func_n3o, func_n4o): Declared. (replace_list, replace_str, replace_vec, replace): Declarations updated. * match.c (debuglf, dump_shell_string, dump_byte_string, dump_var, do_output_line, extract): Reversed arguments to put_char and
* * debug.c (breakpoints, last_command): linkage changed to static.Kaz Kylheku2012-02-121-4/+21
| | | | | | | (cols): New static variable. (debug): Print context intelligently, fitting into the width of the screen. (debug_init): Try to get terminal width, from the COLUMNS variable.
* Oops, syntax error.Kaz Kylheku2012-02-121-1/+1
|
* Task #11486: continuation. Take into account base positionKaz Kylheku2012-02-121-5/+5
| | | | | | | | | | | | | | | | in debug reporting. * debug.c (debug): New argument, base. * debug.h (debug_check): New argument, base. (debug): Declaration updated. * eval.c (do_eval): Pass new argument of debug_check as nil. * match.c (LOG_MISMATCH, LOG_MATCH): Take into account base when displaying character position. (do_match_line): Pass base position to debug_check. (match_files): Pass nil as base to debug_check.
* * debug.c (help): Added missing help for w command.Kaz Kylheku2012-01-211-2/+8
| | | | | | | | | | | | | | | | | | | | (debug): In backtrace, show the renaming pairs for unbound variables (up_p_a_pairs) if they are present. * debug.h (debug_begin): Renamed to debug_frame. * eval.c (eval): Wrap debug_begin/debug_end around function dispatch, so TXR Lisp functions are included in backtraces. * match.c (h_fun): Follow rename of debug_begin to debug_frame. Pass in evaluated args, not the original ones. (v_fun): Likewise. * unwind.c (uw_push_debug): bindings argument renamed to env. Bugfix: args argument was being assigned to ub_p_a_pairs. * unwind.h (struct uw_debug): Member bindings renamed to env. (uw_push_debug): Declaration updated.
* * debug.c (last_command): Do not initialize with lit();Kaz Kylheku2012-01-211-2/+2
| | | | | this is not a constant expression in C. (debug): Handle the situation here.
* * debug.c (help): Filled in.Kaz Kylheku2012-01-211-5/+13
| | | | (debug): Some commands changed due to duplicates.
* Improved debugging. Debug nesting depth counter maintainedKaz Kylheku2012-01-211-3/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | and used for next/step/finish stepping. * Makefile (OBJS): debug.o moved to OBJS-y or OBJS-. (OBJS-y, OBJS-): New variables. $(PROG): Depends on OBJS-y also. clean: clean $(OBJS-y). depend: include $(OBJS-y) in dependency generation. * configure: Underscores and dashes are interchangeable in configure variables. (yaccname_given, yacc_given): Default value is y, not yes. (debug_support): New config variable. (CONFIG_DEBUG_SUPPORT): New config.h symbol. * debug.c (debug_depth): New global variable. (debug_block_s): New symbol variable. (next_depth): New static variable. (debug): Renamed some commands. Introduced separate next, step and finish. (debug_init): debug_block_s initialized. * debug.h (debug_depth, debug_block_s): Declared. (debug_enter, debug_leave, debug_return): New macros. (debug_check, debug_init): Conditionally defined based on if this is a debug build. * dep.mk: Regenerated. * eval.c (eval): Instrumented with debug_enter, debug_leave, debug_return. * match.c (match_line, v_fun, match_files): Likewise. * txr.c (txr_main): Bail if -d or --debug used in build that lacks debug support.
* * debug.c (last_command): Initialize to empty string ratherKaz Kylheku2012-01-191-3/+29
| | | | | | | | | | | | | than nil, otherwise hitting enter tries to repeat the nil command. (show_bindings): New function. Prints all levels of bindings. (debug): Flip the corresponding print flags after printing the current form or data, so they are not printed for every prompt. On EOF from standard input, substitute the q command. If enter is hit and there is no last command, just re-print the prompt. The v command uses show_bindings to dump the environment. * eval.c (eval): When calling debug_check, pass the env objects, rather than the bindings it contains.
* * debug.c (debug): Fix regression: repeat last command by hittingKaz Kylheku2011-12-071-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | Enter stopped working. This was broken by recent bugfixes in the string splitting functions, which introduced a semantics change. * eval.c (flip_s, vecref_s): New symbol variables. (op_modplace): New places (vecref ...) and (flip ...). Bugfix: dec operator was incrementing. (expand_place): Handle vecref and flip. Bugfix: pop has no third argument and so is now handled by the same case as flip. Bugfix: if a modify form has no third argument, then do not resynthesize it with a nil third argument. (eval_init): Initialize new symbol variables. Register new flip operator. Register new list_vectory function as intrinsic. * lib.c (rplacd): When modifying the cdr field of a lazy cons, then lapse the lazy function to nil! This is needed by user-defined lazy conses, and it makes sense to do it this way rather than put in some explicit interface. (list_vector): New function. * lib.h (list_vector): Declared.
* * lib.h (or2): Restore macro version of or2, because we needKaz Kylheku2011-11-301-0/+1
| | | | | | | | | | | | | | | | | | | | the sequencing! Making it an inline function broke the tests. But we can't have multiple evaluation either, so it's going to use a temporary lexical variable. (uses_or2): Macro which declares the lexical variable needed by or2. * debug.c (debug): add uses_or2. * eval.c (eval_intrinsic, op_modplace): Likewise. * lib.c (lazy_str, lazy_str_force_upto, lazy_str_get_trailing_list): Likewise. * match.c (h_parallel, v_freeform, v_parallel, v_output): Likewise. * parser.y (unquotes_occur): Likewise. * stream.c (format): Likewise.
* * debug.c (debug): Eliminated duplicate code.Kaz Kylheku2011-11-131-12/+21
| | | | Implemented better way of printing character context.
* Adding a debugger. This is an experimental prototype.Kaz Kylheku2011-11-131-0/+106
* Makefile (OBJS): New object file debug.o. * dep.mk: Updated. * match.c (h_fun): Use debug_begin and debug_end macros to set up a debug frame for backtracing. (match_line, match_files): Call debug_check to give debugger a chance to instrument call. (v_fun): Use debug_begin and debug_end macros to set up a debug frame for backtracing. Call debug_check to give debugger a chance to instrument call. * stream.c (struct strm_ops): New function pointer, flush. (stdio_maybe_write_error): Wrong word in error message corrected. (stdio_flush): New static function. (stdio_ops, pipe_ops): New function entered into tables. (flush_stream): New function. * stream.h (flush_stream): Declared. * txr.c (help): New options documented. (main): call to debug_init added. New debug options parsed and opt_debugger set accordingly. * unwind.c (uw_push_debug, uw_current_frame): New function. * unwind.h (uw_frtype): New enumeration member UW_DBG. (struct uw_debug): New frame variant. (union uw_frame): New member, db. (uw_push_debug, uw_current_frame): Declared, * debug.c: New file. * debug.h: New file.