diff --git a/boehm-gc/ChangeLog b/boehm-gc/ChangeLog
index 9ce395c754623f0264cc30b5dec823daf1db9133..4d48b580265607dbed74f292a599ca5143cdfa3d 100644
--- a/boehm-gc/ChangeLog
+++ b/boehm-gc/ChangeLog
@@ -1,3 +1,15 @@
+2004-08-27  Hans Boehm  <Hans.Boehm@hp.com>
+
+	* backgraph.c, gc_priv.h (GC_traverse_back_graph,
+	GC_print_back_graph_stats): split GC_traverse_back_graph.
+	* backgraph.c: Dynamically grow in_progress_space.
+	* finalize.c (GC_notify_or_invoke_finalizers): also call
+	GC_print_back_graph_stats.
+	* alloc.c, finalize.c, gc_priv.h (GC_generate_random_backtrace_no_gc,
+	GC_print_back_height): Move delarations to header file.
+	* configure.ac: rename --enable-full-debug to --enable-gc-debug.
+	* configure: Regenerate.
+	
 2004-08-23  Hans Boehm  <Hans.Boehm@hp.com>
 
 	* aix_irix_threads.c: Move _THREADS checks after gc_priv.h include.
diff --git a/boehm-gc/alloc.c b/boehm-gc/alloc.c
index 1ac6ff8111f923f208683bacb9895b13f1313565..45c71d3fd06dce6267b0d4a7d9c9ac08e71dd7f9 100644
--- a/boehm-gc/alloc.c
+++ b/boehm-gc/alloc.c
@@ -104,8 +104,6 @@ word GC_free_space_divisor = 3;
 extern GC_bool GC_collection_in_progress();
 		/* Collection is in progress, or was abandoned.	*/
 
-extern GC_bool GC_print_back_height;
-
 int GC_never_stop_func GC_PROTO((void)) { return(0); }
 
 unsigned long GC_time_limit = TIME_LIMIT;
diff --git a/boehm-gc/backgraph.c b/boehm-gc/backgraph.c
index 7baf5b103e4084a25c2d42c4a7e19d2a8c01ae47..94757c89158a573669b0875ecf212dc26eeaa7da 100644
--- a/boehm-gc/backgraph.c
+++ b/boehm-gc/backgraph.c
@@ -87,7 +87,7 @@ static back_edges * new_back_edges(void)
 {
   if (0 == back_edge_space) {
     back_edge_space = (back_edges *)
-	    		sbrk(MAX_BACK_EDGE_STRUCTS*sizeof(back_edges));
+	    		GET_MEM(MAX_BACK_EDGE_STRUCTS*sizeof(back_edges));
   }
   if (0 != avail_back_edges) {
     back_edges * result = avail_back_edges;
@@ -115,17 +115,31 @@ static void deallocate_back_edges(back_edges *p)
 /* Table of objects that are currently on the depth-first search	*/
 /* stack.  Only objects with in-degree one are in this table.		*/
 /* Other objects are identified using HEIGHT_IN_PROGRESS.		*/
-/* This data structure NEEDS IMPROVEMENT.				*/
-#define MAX_IN_PROGRESS 10000
+/* FIXME: This data structure NEEDS IMPROVEMENT.			*/
+#define INITIAL_IN_PROGRESS 10000
 static ptr_t * in_progress_space = 0;
-static int n_in_progress = 0;
+static size_t in_progress_size = 0;
+static size_t n_in_progress = 0;
 
 static void push_in_progress(ptr_t p)
 {
+  if (n_in_progress >= in_progress_size) 
+    if (in_progress_size == 0) {
+      in_progress_size = INITIAL_IN_PROGRESS;
+      in_progress_space = (ptr_t *)GET_MEM(in_progress_size * sizeof(ptr_t));
+    } else {
+      ptr_t * new_in_progress_space;
+      in_progress_size *= 2;
+      new_in_progress_space = (ptr_t *)
+	      			GET_MEM(in_progress_size * sizeof(ptr_t));
+      BCOPY(in_progress_space, new_in_progress_space,
+	    n_in_progress * sizeof(ptr_t));
+      in_progress_space = new_in_progress_space;
+      /* FIXME: This just drops the old space.	*/
+    }
   if (in_progress_space == 0)
-      in_progress_space = sbrk(MAX_IN_PROGRESS * sizeof(ptr_t));
-  if (n_in_progress == MAX_IN_PROGRESS)
-      ABORT("Exceeded MAX_IN_PROGRESS");
+      ABORT("MAKE_BACK_GRAPH: Out of in-progress space: "
+	    "Huge linear data structure?");
   in_progress_space[n_in_progress++] = p;
 }
 
@@ -320,8 +334,8 @@ static void add_back_edges(ptr_t p, word n_words, word gc_descr)
   }
 }
 
-/* Rebuild the reprentation of the backward reachability graph.	*/
-/* Does not examine mark bits.  Can be called before GC.	*/
+/* Rebuild the representation of the backward reachability graph.	*/
+/* Does not examine mark bits.  Can be called before GC.		*/
 void GC_build_back_graph(void)
 {
   GC_apply_to_each_object(add_back_edges);
@@ -426,15 +440,20 @@ static void update_max_height(ptr_t p, word n_words, word gc_descr)
   }
 }
 
+word GC_max_max_height = 0;
+
 void GC_traverse_back_graph(void)
 {
-  static word max_max_height = 0;
   GC_max_height = 0;
   GC_apply_to_each_object(update_max_height);
+}
+
+void GC_print_back_graph_stats(void)
+{
   GC_printf2("Maximum backwards height of reachable objects at GC %lu is %ld\n",
 	     (unsigned long) GC_gc_no, GC_max_height);
-  if (GC_max_height > max_max_height) {
-    max_max_height = GC_max_height;
+  if (GC_max_height > GC_max_max_height) {
+    GC_max_max_height = GC_max_height;
     GC_printf0("The following unreachable object is last in a longest chain "
 	       "of unreachable objects:\n");
     GC_print_heap_obj(GC_deepest_obj);
diff --git a/boehm-gc/configure b/boehm-gc/configure
index d746215432d7dc6d4af81faf3c6f5bfcb54b4330..7cbcb5f2ac01bac87eeab9e7caf7187764ab5980 100755
--- a/boehm-gc/configure
+++ b/boehm-gc/configure
@@ -852,7 +852,7 @@ Optional Features:
   --enable-fast-install=PKGS  optimize for fast installation default=yes
   --disable-libtool-lock  avoid locking (might break parallel builds)
   --enable-parallel-mark	parallelize marking and free list construction
-  --enable-full-debug	include full support for pointer backtracing etc.
+  --enable-gc-debug	include full support for pointer backtracing etc.
 
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
@@ -6495,10 +6495,10 @@ _ACEOF
 
 fi
 
-# Check whether --enable-full-debug or --disable-full-debug was given.
-if test "${enable_full_debug+set}" = set; then
-  enableval="$enable_full_debug"
-   if test "$enable_full_debug" = "yes"; then
+# Check whether --enable-gc-debug or --disable-gc-debug was given.
+if test "${enable_gc_debug+set}" = set; then
+  enableval="$enable_gc_debug"
+   if test "$enable_gc_debug" = "yes"; then
     { echo "$as_me:$LINENO: WARNING: \"Must define GC_DEBUG and use debug alloc. in clients.\"" >&5
 echo "$as_me: WARNING: \"Must define GC_DEBUG and use debug alloc. in clients.\"" >&2;}
     cat >>confdefs.h <<\_ACEOF
diff --git a/boehm-gc/configure.ac b/boehm-gc/configure.ac
index d14b48b4a86c17c8b99dc20975c774139eb68b6c..b98d8fbbc008051869e64867a532af5351e5f5e1 100644
--- a/boehm-gc/configure.ac
+++ b/boehm-gc/configure.ac
@@ -426,9 +426,9 @@ if test -n "${with_cross_host}"; then
    AC_DEFINE(NO_DEBUGGING)
 fi
 
-AC_ARG_ENABLE(full-debug,
-[  --enable-full-debug	include full support for pointer backtracing etc.],
-[ if test "$enable_full_debug" = "yes"; then
+AC_ARG_ENABLE(gc-debug,
+[  --enable-gc-debug	include full support for pointer backtracing etc.],
+[ if test "$enable_gc_debug" = "yes"; then
     AC_MSG_WARN("Must define GC_DEBUG and use debug alloc. in clients.")
     AC_DEFINE(KEEP_BACK_PTRS)
     AC_DEFINE(DBG_HDRS_ALL)
@@ -444,8 +444,8 @@ AC_ARG_ENABLE(full-debug,
       i[3456]86-*-dgux*)
 	AC_DEFINE(MAKE_BACK_GRAPH)
       ;;
-    esac ]
-  fi)
+    esac 
+  fi])
 
 if test -n "$with_cross_host" &&
    test x"$with_cross_host" != x"no"; then
diff --git a/boehm-gc/finalize.c b/boehm-gc/finalize.c
index e103228c2af135f5a4ae596f7163d849ad105b8f..893f825976f65e9f0493a8178d86524c2b2dabbc 100644
--- a/boehm-gc/finalize.c
+++ b/boehm-gc/finalize.c
@@ -807,24 +807,21 @@ void (* GC_finalizer_notifier)() = (void (*) GC_PROTO((void)))0;
 
 static GC_word last_finalizer_notification = 0;
 
-#ifdef KEEP_BACK_PTRS
-void GC_generate_random_backtrace_no_gc(void);
-#endif
-
 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.	 */
-#   ifdef KEEP_BACK_PTRS
-      if (GC_backtraces > 0) {
-	static word last_back_trace_gc_no = 3;	/* Skip early ones. */
-	long i;
+#   if defined(KEEP_BACK_PTRS) || defined(MAKE_BACK_GRAPH)
+      static word last_back_trace_gc_no = 1;	/* Skip first one. */
 
-	LOCK();
-	if (GC_gc_no > last_back_trace_gc_no) {
+      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) {
+	  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	*/
@@ -832,10 +829,14 @@ void GC_notify_or_invoke_finalizers GC_PROTO((void))
 	      UNLOCK();
 	      GC_generate_random_backtrace_no_gc();
 	      LOCK();
-	    }
-	    last_back_trace_gc_no = GC_gc_no;
-	}
-	UNLOCK();
+	  }
+	  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;
diff --git a/boehm-gc/include/private/gc_priv.h b/boehm-gc/include/private/gc_priv.h
index 08dd8ea247b1083543c2a2d889d7d2bc8bb1de64..561e40326282ded2cb3925c2b902b628b283ee10 100644
--- a/boehm-gc/include/private/gc_priv.h
+++ b/boehm-gc/include/private/gc_priv.h
@@ -1725,6 +1725,13 @@ extern GC_bool GC_print_stats;	/* Produce at least some logging output	*/
 
 #ifdef KEEP_BACK_PTRS
   extern long GC_backtraces;
+  void GC_generate_random_backtrace_no_gc(void);
+#endif
+
+extern GC_bool GC_print_back_height;
+
+#ifdef MAKE_BACK_GRAPH
+  void GC_print_back_graph_stats(void);
 #endif
 
 /* Macros used for collector internal allocation.	*/