From b3ee9cdddd521d0ee87a114269fc683f93d215e0 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 30 Nov 2011 14:15:28 -0800 Subject: * configure (extra_debugging): New variable. EXTRA_DEBUGGING conditionally generated in config.h. * gc.c (break_obj): New static variable. (mark_obj): Debugging feature: if the object is the one stored in break_obj and not yet reached, then call breakpt. (deheap): New debugging function for viewing regions of the heaps. * lib.c (breakpt): New function. * lib.h (breakpt): Declared. --- ChangeLog | 14 ++++++++++++++ configure | 15 +++++++++++++++ gc.c | 18 ++++++++++++++++++ lib.c | 10 ++++++++++ lib.h | 1 + 5 files changed, 58 insertions(+) diff --git a/ChangeLog b/ChangeLog index e79a1d2d..94bebc0e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2011-11-30 Kaz Kylheku + + * configure (extra_debugging): New variable. EXTRA_DEBUGGING + conditionally generated in config.h. + + * gc.c (break_obj): New static variable. + (mark_obj): Debugging feature: if the object is the one stored in + break_obj and not yet reached, then call breakpt. + (deheap): New debugging function for viewing regions of the heaps. + + * lib.c (breakpt): New function. + + * lib.h (breakpt): Declared. + 2011-11-30 Kaz Kylheku * hash.c (hash_process_weak): Fix regression caused by a mistake diff --git a/configure b/configure index 2b012c43..6255fc9a 100755 --- a/configure +++ b/configure @@ -135,6 +135,7 @@ lex_dbg_flags=${lex_dbg_flags-} txr_dbg_opts=${txr_dbg_opts---gc-debug} valgrind=${valgrind-} lit_align=${lit_align-} +extra_debugging=${extra_debugging-} # # If --help was given (or --help= or help=) then @@ -334,6 +335,11 @@ valgrind [$valgrind] Valgrind integration means that when the program is running under valgrind, it advises valgrind about stack memory locations accessed by the garbage collector, to suppress diagnostics about uninitialized accesses. + +extra_debugging [$extra_debugging] + + Use --extra_debugging to configure some additional debugging features, + which incur a run-time penalty. ! exit 1 fi @@ -921,6 +927,15 @@ else printf "#define HAVE_GETENVIRONMENTSTRINGS 1\n" >> config.h fi +# +# Extra debugging. +# + +if [ -n "$extra_debugging" ] ; then + printf "Configuring extra debugging, as requested ...\n" + printf "#define EXTRA_DEBUGGING 1\n" >> config.h +fi + # # Clean up # diff --git a/gc.c b/gc.c index 4f8c41bc..72b1af05 100644 --- a/gc.c +++ b/gc.c @@ -72,6 +72,10 @@ static val heap_min_bound, heap_max_bound; int gc_enabled = 1; +#if EXTRA_DEBUGGING +static val break_obj; +#endif + val prot1(val *loc) { assert (top < prot_stack_limit); @@ -243,6 +247,11 @@ tail_call: obj->t.type = (type_t) (obj->t.type | REACHABLE); +#if EXTRA_DEBUGGING + if (obj == break_obj) + breakpt(); +#endif + switch (t) { case CONS: mark_obj(obj->c.car); @@ -512,6 +521,15 @@ void unmark(void) } } +void dheap(heap_t *heap, int start, int end); + +void dheap(heap_t *heap, int start, int end) +{ + int i; + for (i = start; i < end; i++) + format(std_output, lit("(~a ~s)\n"), num(i), &heap->block[i], nao); +} + /* * This function does nothing. * gc_hint(x) just takes the address of local variable x diff --git a/lib.c b/lib.c index fdf5758e..a605a556 100644 --- a/lib.c +++ b/lib.c @@ -3228,3 +3228,13 @@ void d(val obj) { dump(obj, std_output); } + +/* + * Function for software breakpoints. + * Debugging routines call here when a breakpoint + * is requested. For this to work, set a breakpoint + * on this function. + */ +void breakpt(void) +{ +} diff --git a/lib.h b/lib.h index 732c5eb8..47cb414e 100644 --- a/lib.h +++ b/lib.h @@ -495,6 +495,7 @@ void init(const wchar_t *progname, mem_t *(*oom_realloc)(mem_t *, size_t), val *stack_bottom); void dump(val obj, val stream); void d(val obj); +void breakpt(void); #define nil ((obj_t *) 0) -- cgit v1.2.3