From 950ebe833decae8617cdc53513873081e4691abb Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 10 Feb 2022 21:07:40 +0100 Subject: [PATCH] add debug messages about effective requested operations --- src/common.h | 7 +++++++ src/config.c | 9 +++++++++ src/main_sync.c | 2 ++ src/sync.h | 2 ++ 4 files changed, 20 insertions(+) diff --git a/src/common.h b/src/common.h index a0cf895..8cc4b84 100644 --- a/src/common.h +++ b/src/common.h @@ -217,6 +217,13 @@ void fmt_bits( uint bits, uint num_bits, const char *bit_str, const int *bit_off BIT_FORMATTER_RET(name, pfx) \ BIT_FORMATTER_IMPL(name, pfx, static) +#define DECL_BIT_FORMATTER_FUNCTION(name, pfx) \ + BIT_FORMATTER_RET(name, pfx) \ + BIT_FORMATTER_PROTO(name, pfx, ); + +#define DEF_BIT_FORMATTER_FUNCTION(name, pfx) \ + BIT_FORMATTER_IMPL(name, pfx, ) + void *nfmalloc( size_t sz ); void *nfzalloc( size_t sz ); void *nfrealloc( void *mem, size_t sz ); diff --git a/src/config.c b/src/config.c index eaa2ba0..ce9993c 100644 --- a/src/config.c +++ b/src/config.c @@ -5,6 +5,8 @@ * mbsync - mailbox synchronizer */ +#define DEBUG_FLAG DEBUG_MAIN + #include "config.h" #include "sync.h" @@ -20,6 +22,8 @@ char FieldDelimiter = ';'; char FieldDelimiter = ':'; #endif +DEF_BIT_FORMATTER_FUNCTION(ops, OP) + char * expand_strdup( const char *s, const conffile_t *cfile ) { @@ -310,6 +314,10 @@ merge_ops( int cops, int ops[], const char *chan_name ) int aops, op; uint i; + if (!cops && !ops[F] && !ops[N]) // Only to denoise the debug output + return 0; + debug( "merge ops (%s):\n common: %s\n far: %s\n near: %s\n", + channel_str( chan_name ), fmt_ops( cops ).str, fmt_ops( ops[F] ).str, fmt_ops( ops[N] ).str ); aops = ops[F] | ops[N]; if (ops[F] & XOP_HAVE_TYPE) { if (aops & OP_MASK_TYPE) { // PullNew, etc. @@ -377,6 +385,7 @@ merge_ops( int cops, int ops[], const char *chan_name ) ops[N] |= cops & op; } } + debug( " => far: %s\n => near: %s\n", fmt_ops( ops[F] ).str, fmt_ops( ops[N] ).str ); return 0; } diff --git a/src/main_sync.c b/src/main_sync.c index f1ea700..6134631 100644 --- a/src/main_sync.c +++ b/src/main_sync.c @@ -186,6 +186,8 @@ add_channel( chan_ent_t ***chanapp, channel_conf_t *chan, int ops[] ) merge_actions( chan, ops, XOP_HAVE_CREATE, OP_CREATE, 0 ); merge_actions( chan, ops, XOP_HAVE_REMOVE, OP_REMOVE, 0 ); merge_actions( chan, ops, XOP_HAVE_EXPUNGE, OP_EXPUNGE, 0 ); + debug( "channel ops (%s):\n far: %s\n near: %s\n", + chan->name, fmt_ops( ops[F] ).str, fmt_ops( ops[N] ).str ); for (int t = 0; t < 2; t++) { if (chan->ops[t] & OP_MASK_TYPE) diff --git a/src/sync.h b/src/sync.h index f69f172..40c90ec 100644 --- a/src/sync.h +++ b/src/sync.h @@ -41,6 +41,8 @@ BIT_ENUM( #define OP_MASK_TYPE (OP_NEW | OP_RENEW | OP_DELETE | OP_FLAGS) // Asserted in the target side ops #define XOP_MASK_DIR (XOP_PUSH | XOP_PULL) +DECL_BIT_FORMATTER_FUNCTION(ops, OP) + typedef struct channel_conf { struct channel_conf *next; const char *name;