From 265cefe07900a40f1ba15ba82e69e1bd1678a5a9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Anders=20F=20Bj=C3=B6rklund?= Date: Sun, 12 Aug 2018 16:24:54 +0200 Subject: [PATCH] Add section markers, to the text file --- src/ccache.c | 3 +++ src/ccache.h | 1 + src/hash.c | 9 +++++++++ 3 files changed, 13 insertions(+) diff --git a/src/ccache.c b/src/ccache.c index 1c597ad14..6aac782c5 100644 --- a/src/ccache.c +++ b/src/ccache.c @@ -3390,11 +3390,13 @@ ccache(int argc, char *argv[]) struct mdfour common_hash; hash_start(&common_hash); mdfour_identify(&common_hash, 'c'); + hash_section(&common_hash, "COMMON"); calculate_common_hash(preprocessor_args, &common_hash); // Try to find the hash using the manifest. struct mdfour direct_hash = common_hash; mdfour_identify(&direct_hash, 'd'); + hash_section(&direct_hash, "DIRECT MODE"); bool put_object_in_manifest = false; struct file_hash *object_hash = NULL; struct file_hash *object_hash_from_manifest = NULL; @@ -3426,6 +3428,7 @@ ccache(int argc, char *argv[]) // Find the hash using the preprocessed output. Also updates included_files. struct mdfour cpp_hash = common_hash; mdfour_identify(&cpp_hash, 'p'); + hash_section(&cpp_hash, "PREPROCESSOR MODE"); object_hash = calculate_object_hash(preprocessor_args, &cpp_hash, 0); if (!object_hash) { fatal("internal error: object hash from cpp returned NULL"); diff --git a/src/ccache.h b/src/ccache.h index a7730fea6..a767ef323 100644 --- a/src/ccache.h +++ b/src/ccache.h @@ -121,6 +121,7 @@ bool args_equal(struct args *args1, struct args *args2); void hash_debug_init(const char *bin, const char *txt); void hash_debug_end(void); void hash_start(struct mdfour *md); +void hash_section(struct mdfour *md, const char *name); void hash_buffer(struct mdfour *md, const void *s, size_t len); char *hash_result(struct mdfour *md); void hash_result_as_bytes(struct mdfour *md, unsigned char *out); diff --git a/src/hash.c b/src/hash.c index f49dfd7f8..4b3cdeea8 100644 --- a/src/hash.c +++ b/src/hash.c @@ -83,6 +83,15 @@ hash_start(struct mdfour *md) mdfour_begin(md); } +void +hash_section(struct mdfour *md, const char *name) +{ + hash_debug_buffer(md, "=== ", 4); + hash_debug_buffer(md, name, strlen(name)); + hash_debug_buffer(md, " ===", 4); + hash_debug_buffer(md, "\n", 1); +} + void hash_buffer(struct mdfour *md, const void *s, size_t len) { -- 2.47.2