From 34d666d0d91f2feb29b3b9a52229cc0296d57698 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Anders=20F=20Bj=C3=B6rklund?= Date: Sat, 25 Aug 2018 19:26:38 +0200 Subject: [PATCH] Add ccache debugging option, for included files To be able to compare the preprocessor and depend modes. --- src/ccache.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/ccache.c b/src/ccache.c index 106226fb2..6dd11854d 100644 --- a/src/ccache.c +++ b/src/ccache.c @@ -696,6 +696,16 @@ ignore: free(path); } +static void +print_included_files(FILE *fp) +{ + struct hashtable_itr *iter = hashtable_iterator(included_files); + do { + char *path = hashtable_iterator_key(iter); + fprintf(fp, "%s\n", path); + } while (hashtable_iterator_advance(iter)); +} + // Make a relative path from current working directory to path if path is under // the base directory. Takes over ownership of path. Caller frees. static char * @@ -946,6 +956,11 @@ process_preprocessed_file(struct mdfour *hash, const char *path, bool pump) remember_include_file(path, hash, false, NULL); } + bool debug_included = getenv("CCACHE_DEBUG_INCLUDED"); + if (debug_included) { + print_included_files(stdout); + } + return true; } @@ -1058,6 +1073,11 @@ object_hash_from_depfile(const char *depfile, struct mdfour *hash) { } } + bool debug_included = getenv("CCACHE_DEBUG_INCLUDED"); + if (debug_included) { + print_included_files(stdout); + } + struct file_hash *result = x_malloc(sizeof(*result)); hash_result_as_bytes(hash, result->hash); result->size = hash->totalN; -- 2.47.3