--- cleanup.c.orig	2010-07-18 18:28:48.425812281 +0200
+++ cleanup.c	2010-07-18 18:40:53.145197926 +0200
@@ -93,17 +93,24 @@
 	files[num_files]->mtime = st->st_mtime;
 	files[num_files]->size = file_size(st) / 1024;
 	cache_size += files[num_files]->size;
+	if (getenv("CCACHE_DEBUG")) fprintf(stderr, "  DEBUG: detected %s\n", fname);
 	files_in_cache++;
 	num_files++;
 }
 
 static void delete_file(const char *path, size_t size)
 {
+	int debug = getenv("CCACHE_DEBUG") != NULL;
+	if (debug) fprintf(stderr, "  DEBUG: deleting %s: ", path);
 	if (unlink(path) == 0) {
+		if (debug) fprintf(stderr, "OK\n");
 		cache_size -= size;
 		files_in_cache--;
 	} else if (errno != ENOENT) {
 		cc_log("Failed to unlink %s (%s)", path, strerror(errno));
+		if (debug) fprintf(stderr, "errno != ENOENT\n");
+	} else {
+		if (debug) fprintf(stderr, "errno == ENOENT\n");
 	}
 }
 
--- test.sh.orig	2010-07-18 18:11:18.155226600 +0200
+++ test.sh	2010-07-18 18:25:38.257588533 +0200
@@ -1431,7 +1431,7 @@
     checkfilecount 160 '*.d' $CCACHE_DIR
     checkfilecount 160 '*.stderr' $CCACHE_DIR
     checkstat 'files in cache' 480
-    $CCACHE $COMPILER -c empty.c -o empty.o
+    CCACHE_DEBUG=1 $CCACHE $COMPILER -c empty.c -o empty.o
     # floor(0.8 * 9) = 7
     checkfilecount 157 '*.o' $CCACHE_DIR
     checkfilecount 156 '*.d' $CCACHE_DIR
