Index: /trunk/xcache.c
===================================================================
--- /trunk/xcache.c	(revision 227)
+++ /trunk/xcache.c	(revision 230)
@@ -2,4 +2,5 @@
 #if 0
 #define DEBUG
+#define SHOW_DPRINT
 #endif
 
@@ -1015,4 +1016,7 @@
 	xc_redo_pass_two(php.op_array TSRMLS_CC);
 	/* }}} */
+#ifdef SHOW_DPRINT
+	xc_dprint(&xce, 0 TSRMLS_CC);
+#endif
 	ENTER_LOCK_EX(cache) { /* {{{ store/add entry */
 		stored_xce = xc_entry_store_dmz(&xce TSRMLS_CC);
@@ -1075,4 +1079,7 @@
 #endif
 	xc_processor_restore_xc_entry_t(&xce, stored_xce, xc_readonly_protection TSRMLS_CC);
+#ifdef SHOW_DPRINT
+	xc_dprint(&xce, 0 TSRMLS_CC);
+#endif
 
 	catched = 0;
Index: /trunk/config.w32
===================================================================
--- /trunk/config.w32	(revision 148)
+++ /trunk/config.w32	(revision 230)
@@ -119,7 +119,12 @@
 		ADD_FLAG("XCACHE_ENABLE_TEST", "");
 	}
-
+	// }}}
 	XCACHE_PROC_SOURCES=glob(srcdir + "\\processor\\*.m4").join(' ');
 	ADD_FLAG("XCACHE_PROC_SOURCES", XCACHE_PROC_SOURCES);
+	// {{{ check for xcache-test
+	ARG_ENABLE("xcache-dprint", "XCache: Enable self debug print functions - FOR DEVELOPERS ONLY!!", "no");
+	if (PHP_XCACHE_TEST != "no") {
+		AC_DEFINE("HAVE_XCACHE_TEST", 1, "Define to enable XCache debug print functions");
+	}
 	// }}}
 	// {{{ check for opcode_spec_def.h
Index: /trunk/config.m4
===================================================================
--- /trunk/config.m4	(revision 186)
+++ /trunk/config.m4	(revision 230)
@@ -57,4 +57,10 @@
   fi
   PHP_SUBST([XCACHE_ENABLE_TEST])
+
+  PHP_ARG_ENABLE(xcache-dprint, for XCache self test,
+  [  --enable-xcache-dprint          XCache: Enable debug print functions - FOR DEVELOPERS ONLY!!], no, no)
+  if test "$PHP_XCACHE_DPRINT" != "no"; then
+    AC_DEFINE([HAVE_XCACHE_DPRINT], 1, [Define to enable XCache debug print functions])
+  fi
 
   AC_PATH_PROGS([AWK], [gawk awk])
Index: /trunk/processor/head.m4
===================================================================
--- /trunk/processor/head.m4	(revision 220)
+++ /trunk/processor/head.m4	(revision 230)
@@ -77,5 +77,5 @@
 };
 /* }}} */
-#ifdef XCACHE_HAVE_DPRINT
+#ifdef HAVE_XCACHE_DPRINT
 static void xc_dprint_indent(int indent) /* {{{ */
 {
@@ -85,6 +85,20 @@
 	}
 }
-#endif
-/* }}} */
+/* }}} */
+static void xc_dprint_str_len(const char *str, int len) /* {{{ */
+{
+	const unsigned char *p = str;
+	int i;
+	for (i = 0; i < len; i ++) {
+		if (p[i] < 32 || p[i] == 127) {
+			fprintf(stderr, "\\%03o", (unsigned int) p[i]);
+		}
+		else {
+			fputc(p[i], stderr);
+		}
+	}
+}
+/* }}} */
+#endif
 /* {{{ xc_zstrlen_char */
 static inline int xc_zstrlen_char(zstr s)
@@ -402,5 +416,5 @@
 /* }}} */
 /* export: void xc_dprint(xc_entry_t *src, int indent TSRMLS_DC); :export {{{ */
-#ifdef XCACHE_HAVE_DPRINT
+#ifdef HAVE_XCACHE_DPRINT
 void xc_dprint(xc_entry_t *src, int indent TSRMLS_DC) {
 	IFDPRINT(`INDENT()`'fprintf(stderr, "xc_entry_t:src");')
Index: /trunk/processor/struct.m4
===================================================================
--- /trunk/processor/struct.m4	(revision 178)
+++ /trunk/processor/struct.m4	(revision 230)
@@ -146,10 +146,10 @@
 	DBG(`$0($*)')
 	if (src->$2) {
+		IFDPRINT(`INDENT()`'fprintf(stderr, "$1:$2");')
 		STRUCT_P_EX(`$1', `dst->$2', `src->$2', `$2', `$3')
-		IFDPRINT(`INDENT()`'fprintf(stderr, "$1:$2");')
 	}
 	else {
+		IFDPRINT(`INDENT()`'fprintf(stderr, "$1:$2:\tNULL\n");')
 		COPYNULL_EX(`dst->$2', `$2')
-		IFDPRINT(`INDENT()`'fprintf(stderr, "$1:$2:\tNULL\n");')
 	}
 	DONE(`$2')
Index: /trunk/processor/string.m4
===================================================================
--- /trunk/processor/string.m4	(revision 103)
+++ /trunk/processor/string.m4	(revision 230)
@@ -41,5 +41,7 @@
 				ZVAL_UNICODEL(&zv, (UChar *) ($2), $3 - 1, 1);
 				zend_make_printable_zval(&zv, &reszv, &usecopy);
-				fprintf(stderr, "string:%s:\t\"%s\" len=%d\n", "$1", reszv.value.str.val, $3 - 1);
+				fprintf(stderr, "string:%s:\t\"", "$1");
+				xc_dprint_str_len(Z_STRVAL(reszv), Z_STRLEN(reszv));
+				fprintf(stderr, "\" len=%d\n", $3 - 1);
 				if (usecopy) {
 					zval_dtor(&reszv);
@@ -49,5 +51,7 @@
 #endif
 			', `
-			fprintf(stderr, "string:%s:\t\"%s\" len=%d\n", "$1", SRCPTR, $3 - 1);
+			fprintf(stderr, "string:%s:\t\"", "$1");
+			xc_dprint_str_len(SRCPTR, $3 - 1);
+			fprintf(stderr, "\" len=%d\n", $3 - 1);
 			')
 		')
Index: /trunk/processor/hashtable.m4
===================================================================
--- /trunk/processor/hashtable.m4	(revision 200)
+++ /trunk/processor/hashtable.m4	(revision 230)
@@ -119,4 +119,10 @@
 				dst->arBuckets[n] = pnew;
 			')
+			IFDPRINT(`
+				INDENT()
+				fprintf(stderr, "$2:\"");
+				xc_dprint_str_len(BUCKET_KEY_S(b), BUCKET_KEY_SIZE(b));
+				fprintf(stderr, "\" %d:h=%lu", BUCKET_KEY_SIZE(b), b->h);
+			')
 			if (sizeof(void *) == sizeof($2)) {
 				IFCOPY(`pnew->pData = &pnew->pDataPtr;')
Index: /trunk/processor/processor.m4
===================================================================
--- /trunk/processor/processor.m4	(revision 221)
+++ /trunk/processor/processor.m4	(revision 230)
@@ -196,4 +196,5 @@
 				dnl fprintf(stderr, "copy from %p to %p\n", src[0], dst[0]);
 			')
+			IFDPRINT(`INDENT()`'fprintf(stderr, "[%p]", src[0]);')
 			STRUCT_P_EX(zval, dst[0], src[0], `[0]', `', ` ')
 		} while (0);
@@ -747,4 +748,5 @@
 		}
 	')
+	IFDPRINT(`INDENT()`'fprintf(stderr, "zval:value");')
 	STRUCT_P_EX(zval_ptr, dst->value, src->value, `value', `', `&')
 	DONE(value)
