X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=boehm-gc%2Ffinalize.c;h=893f825976f65e9f0493a8178d86524c2b2dabbc;hb=84a755ae423fff9e4b03255fa62bd71576d2b4ca;hp=3b9d9f5ea1ee3804cfbcd17177999c38e6cba500;hpb=341281013a7334da0896c950d9c254e42692c479;p=pf3gnuchains%2Fgcc-fork.git diff --git a/boehm-gc/finalize.c b/boehm-gc/finalize.c index 3b9d9f5ea1e..893f825976f 100644 --- a/boehm-gc/finalize.c +++ b/boehm-gc/finalize.c @@ -809,6 +809,36 @@ static GC_word last_finalizer_notification = 0; void GC_notify_or_invoke_finalizers GC_PROTO((void)) { + /* This is a convenient place to generate backtraces if appropriate, */ + /* since that code is not callable with the allocation lock. */ +# if defined(KEEP_BACK_PTRS) || defined(MAKE_BACK_GRAPH) + static word last_back_trace_gc_no = 1; /* Skip first one. */ + + if (GC_gc_no > last_back_trace_gc_no) { + word i; + +# ifdef KEEP_BACK_PTRS + LOCK(); + /* Stops when GC_gc_no wraps; that's OK. */ + last_back_trace_gc_no = (word)(-1); /* disable others. */ + for (i = 0; i < GC_backtraces; ++i) { + /* FIXME: This tolerates concurrent heap mutation, */ + /* which may cause occasional mysterious results. */ + /* We need to release the GC lock, since GC_print_callers */ + /* acquires it. It probably shouldn't. */ + UNLOCK(); + GC_generate_random_backtrace_no_gc(); + LOCK(); + } + last_back_trace_gc_no = GC_gc_no; + UNLOCK(); +# endif +# ifdef MAKE_BACK_GRAPH + if (GC_print_back_height) + GC_print_back_graph_stats(); +# endif + } +# endif if (GC_finalize_now == 0) return; if (!GC_finalize_on_demand) { (void) GC_invoke_finalizers();