format message flags in the sync debug output

now that we can do it cheaply, make copious use of it.
This commit is contained in:
Oswald Buddenhagen 2021-12-12 14:51:30 +01:00
parent a49017f481
commit c902f69c6f
4 changed files with 26 additions and 6 deletions

View File

@ -41,6 +41,20 @@ fmt_flags( uchar flags )
return buf;
}
flag_str_t
fmt_lone_flags( uchar flags )
{
flag_str_t buf;
if (!flags) {
buf.str[0] = '-';
buf.str[1] = 0;
} else {
make_flags( flags, buf.str );
}
return buf;
}
uint
count_generic_messages( message_t *msgs )
{

View File

@ -48,6 +48,7 @@ BIT_ENUM(
extern const char MsgFlags[F__NUM_BITS];
typedef struct { char str[F__NUM_BITS + 1]; } flag_str_t;
flag_str_t ATTR_OPTIMIZE /* force RVO */ fmt_flags( uchar flags );
flag_str_t ATTR_OPTIMIZE /* force RVO */ fmt_lone_flags( uchar flags );
/* For message->status */
BIT_ENUM(

View File

@ -1035,7 +1035,9 @@ box_loaded( int sts, message_t *msgs, int total_msgs, int recent_msgs, void *aux
srec->pflags = ((srec->msg[t]->flags & ~(F_SEEN|F_FLAGGED)) | srec->aflags[t]) & ~srec->dflags[t];
// Consequently, the srec's flags are committed right away as well.
srec->flags = (srec->flags | srec->aflags[t]) & ~srec->dflags[t];
JLOG( "^ %u %u %u %u", (srec->uid[F], srec->uid[N], srec->pflags, srec->flags), "upgrading placeholder" );
JLOG( "^ %u %u %u %u", (srec->uid[F], srec->uid[N], srec->pflags, srec->flags),
"upgrading placeholder, dummy's flags %s, srec flags %s",
(fmt_lone_flags( srec->pflags ).str, fmt_lone_flags( srec->flags ).str) );
nsrec = upgrade_srec( svars, srec );
}
}
@ -1360,7 +1362,8 @@ msg_copied( int sts, uint uid, copy_vars_t *vars )
case SYNC_OK:
if (!(srec->status & S_UPGRADE) && vars->msg->flags != srec->flags) {
srec->flags = vars->msg->flags;
JLOG( "* %u %u %u", (srec->uid[F], srec->uid[N], srec->flags), "%sed with flags", str_hl[t] );
JLOG( "* %u %u %u", (srec->uid[F], srec->uid[N], srec->flags),
"%sed with flags %s", (str_hl[t], fmt_lone_flags( srec->flags ).str) );
}
if (!uid) // Stored to a non-UIDPLUS mailbox
svars->state[t] |= ST_FIND_NEW;
@ -1494,7 +1497,8 @@ flags_set_p2( sync_vars_t *svars, sync_rec_t *srec, int t )
} else {
uchar nflags = (srec->flags | srec->aflags[t]) & ~srec->dflags[t];
if (srec->flags != nflags) {
JLOG( "* %u %u %u", (srec->uid[F], srec->uid[N], nflags), "%sed flags; were %u", (str_hl[t], srec->flags) );
JLOG( "* %u %u %u", (srec->uid[F], srec->uid[N], nflags), "%sed flags %s; were %s",
(str_hl[t], fmt_lone_flags( nflags ).str, fmt_lone_flags( srec->flags ).str) );
srec->flags = nflags;
}
if (t == N) {

View File

@ -208,7 +208,7 @@ load_state( sync_vars_t *svars )
srec->status = S_SKIPPED;
}
srec->flags = parse_flags( s );
debug( " entry (%u,%u,%u,%s%s)\n", srec->uid[F], srec->uid[N], srec->flags,
debug( " entry (%u,%u,%s,%s%s)\n", srec->uid[F], srec->uid[N], fmt_flags( srec->flags ).str,
(srec->status & S_SKIPPED) ? "SKIP" : (srec->status & S_EXPIRED) ? "XPIRE" : "",
(srec->status & S_DUMMY(F)) ? ",F-DUMMY" : (srec->status & S_DUMMY(N)) ? ",N-DUMMY" : "" );
*svars->srecadd = srec;
@ -372,8 +372,8 @@ load_state( sync_vars_t *svars )
assign_uid( svars, srec, N, t3 );
break;
case '*':
debug( "flags now %u\n", t3 );
srec->flags = (uchar)t3;
debug( "flags now %s\n", fmt_lone_flags( t3 ).str );
break;
case 'P':
debug( "deleted dummy\n" );
@ -391,9 +391,10 @@ load_state( sync_vars_t *svars )
srec->status = S_PENDING | (!srec->uid[F] ? S_DUMMY(F) : S_DUMMY(N));
break;
case '^':
debug( "is being upgraded, flags %u, srec flags %u\n", t3, t4 );
srec->pflags = (uchar)t3;
srec->flags = (uchar)t4;
debug( "is being upgraded, dummy's flags %s, srec flags %s\n",
fmt_lone_flags( t3 ).str, fmt_lone_flags( t4 ).str );
srec = upgrade_srec( svars, srec );
break;
default: