summaryrefslogtreecommitdiffstats
path: root/debug.c
Commit message (Collapse)AuthorAgeFilesLines
* 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.