enable libstdc++ debug mode with --enable-dbgutil

diff --git a/configure.in b/configure.in
index 20ece15..f49952f 100755
--- a/configure.in
+++ b/configure.in
@@ -2293,6 +2293,17 @@ if test -n "$enable_dbgutil" && test "$enable_dbgutil" != "no"; then
     PRODUCT=""
     PROFULLSWITCH=""
     AC_MSG_RESULT([yes])
+    # cppunit and graphite expose STL in public headers
+    if test "$with_system_cppunit" = "yes"; then
+        AC_MSG_ERROR([--with-system-cppunit conflicts with DBG_UTIL build])
+    else
+        with_system_cppunit=no
+    fi
+    if test "$with_system_graphite" = "yes"; then
+        AC_MSG_ERROR([--with-system-graphite conflicts with DBG_UTIL build])
+    else
+        with_system_graphite=no
+    fi
     if test $_os = WINNT -a \( "$enable_mozilla" = yes -o "$enable_build_mozilla" = yes \); then
         # We can't build against the Mozilla stuff if using _DEBUG, will get linking errors
         # See connectivity/drivers/mozab
diff --git a/cppunit/makefile.mk b/cppunit/makefile.mk
index 7fba665..c29ac62 100644
--- a/cppunit/makefile.mk
+++ b/cppunit/makefile.mk
@@ -119,6 +119,14 @@ MY_LIBS = -lm
 
 CONFIGURE_ACTION = ./configure
 
+# FIXME TODO not for all platforms, just unxgcc!
+.IF "$(COM)" == "GCC"
+.IF "$(PRODUCT)"!="full"
+# enable debug STL
+EXTRA_CDEFS += -D_GLIBCXX_DEBUG
+.ENDIF # !PRODUCT
+.ENDIF # GCC
+
 .IF "$(debug)"!=""
 DEBUGFLAG=-g
 .ENDIF
diff --git a/solenv/gbuild/platform/unxgcc.mk b/solenv/gbuild/platform/unxgcc.mk
index 362b378..851cc75 100644
--- a/solenv/gbuild/platform/unxgcc.mk
+++ b/solenv/gbuild/platform/unxgcc.mk
@@ -107,6 +107,13 @@ endif
 
 endif
 
+# enable debug STL
+ifeq ($(gb_PRODUCT),$(false))
+gb_COMPILERDEFS += \
+	-D_GLIBCXX_DEBUG \
+
+endif
+
 gb_CCVER := $(shell $(gb_CC) -dumpversion | $(gb_AWK) -F. -- '{ print $$1*10000+$$2*100+$$3 }')
 gb_StrictAliasingUnsafe := $(shell expr $(gb_CCVER) \< 40600)
 
diff --git a/solenv/inc/unxgcc.mk b/solenv/inc/unxgcc.mk
index 752de80..f34f12b 100644
--- a/solenv/inc/unxgcc.mk
+++ b/solenv/inc/unxgcc.mk
@@ -91,6 +91,11 @@ CFLAGSCXX+=-fvisibility-inlines-hidden
 CFLAGSCXX+=-std=c++0x -Wno-deprecated-declarations
 .ENDIF # "$(HAVE_CXX0X)" == "TRUE"
 
+.IF "$(PRODUCT)"!="full"
+# enable debug STL
+CFLAGSCXX += -D_GLIBCXX_DEBUG
+.ENDIF # !PRODUCT
+
 CFLAGS_CREATE_PCH=-x c++-header -I$(INCPCH) -DPRECOMPILED_HEADERS
 CFLAGS_USE_PCH=-I$(SLO)$/pch -DPRECOMPILED_HEADERS -Winvalid-pch
 CFLAGS_USE_EXCEPTIONS_PCH=-I$(SLO)$/pch_ex -DPRECOMPILED_HEADERS -Winvalid-pch