From: Jeremy Harris Date: Sun, 23 Aug 2020 10:40:32 +0000 (+0100) Subject: Debug: minor updates X-Git-Url: https://git.exim.org/users/heiko/exim.git/commitdiff_plain/afade5fc02622ab0f6c545c723eed0eabaa75284?hp=e0ae68c8ee6788508da4989ee0d6fcbaf40c7b97 Debug: minor updates --- diff --git a/src/src/debug.c b/src/src/debug.c index 6d6132e39..90c48dde4 100644 --- a/src/src/debug.c +++ b/src/src/debug.c @@ -30,7 +30,15 @@ const uschar * rc_names[] = { /* Mostly for debug output */ [UNEXPECTED] = US"UNEXPECTED", [CANCELLED] = US"CANCELLED", [FAIL_SEND] = US"FAIL_SEND", - [FAIL_DROP] = US"FAIL_DROP" + [FAIL_DROP] = US"FAIL_DROP", +}; + +const uschar * dns_rc_names[] = { + [DNS_SUCCEED] = US"DNS_SUCCEED", + [DNS_NOMATCH] = US"DNS_NOMATCH", + [DNS_NODATA] = US"DNS_NODATA", + [DNS_AGAIN] = US"DNS_AGAIN", + [DNS_FAIL] = US"DNS_FAIL", }; @@ -43,8 +51,8 @@ hold the line-drawing characters that need to be printed on every line as it moves down the page. This function is used only in debugging circumstances. The output is done via debug_printf(). */ -#define tree_printlinesize 132 /* line size for printing */ -static uschar tree_printline[tree_printlinesize]; +#define TREE_PRINTLINESIZE 132 /* line size for printing */ +static uschar tree_printline[TREE_PRINTLINESIZE]; /* Internal recursive subroutine. @@ -57,12 +65,12 @@ Returns: nothing */ static void -tree_printsub(tree_node *p, int pos, int barswitch) +tree_printsub(tree_node * p, int pos, int barswitch) { if (p->right) tree_printsub(p->right, pos+2, 1); -for (int i = 0; i <= pos-1; i++) debug_printf("%c", tree_printline[i]); -debug_printf("-->%s [%d]\n", p->name, p->balance); -tree_printline[pos] = barswitch? '|' : ' '; +for (int i = 0; i <= pos-1; i++) debug_printf_indent(" %c", tree_printline[i]); +debug_printf_indent(" -->%s [%d]\n", p->name, p->balance); +tree_printline[pos] = barswitch ? '|' : ' '; if (p->left) { tree_printline[pos+2] = '|'; @@ -73,11 +81,12 @@ if (p->left) /* The external function, with just a tree node argument. */ void -debug_print_tree(tree_node *p) +debug_print_tree(const char * title, tree_node * p) { -for (int i = 0; i < tree_printlinesize; i++) tree_printline[i] = ' '; -if (!p) debug_printf("Empty Tree\n"); else tree_printsub(p, 0, 0); -debug_printf("---- End of tree ----\n"); +debug_printf_indent("%s:\n", title); +for (int i = 0; i < TREE_PRINTLINESIZE; i++) tree_printline[i] = ' '; +if (!p) debug_printf_indent(" Empty Tree\n"); else tree_printsub(p, 0, 0); +debug_printf_indent("---- End of tree ----\n"); } diff --git a/src/src/dns.c b/src/src/dns.c index 98c44b9f2..a636f076d 100644 --- a/src/src/dns.c +++ b/src/src/dns.c @@ -671,13 +671,10 @@ e = previous->data.ptr; val = e->data.val; rc = e->expiry && e->expiry <= time(NULL) ? -1 : val; -DEBUG(D_dns) debug_printf("DNS lookup of %.255s-%s: %scached value %s%s\n", +DEBUG(D_dns) debug_printf("DNS lookup of %.255s (%s): %scached value %s%s\n", name, dns_text_type(type), rc == -1 ? "" : "using ", - val == DNS_NOMATCH ? "DNS_NOMATCH" : - val == DNS_NODATA ? "DNS_NODATA" : - val == DNS_AGAIN ? "DNS_AGAIN" : - val == DNS_FAIL ? "DNS_FAIL" : "??", + dns_rc_names[val], rc == -1 ? " past valid time" : ""); return rc; diff --git a/src/src/functions.h b/src/src/functions.h index e5cf7f140..e7f643110 100644 --- a/src/src/functions.h +++ b/src/src/functions.h @@ -182,7 +182,7 @@ extern void debug_print_argv(const uschar **); extern void debug_print_ids(uschar *); extern void debug_printf_indent(const char *, ...) PRINTF_FUNCTION(1,2); extern void debug_print_string(uschar *); -extern void debug_print_tree(tree_node *); +extern void debug_print_tree(const char *, tree_node *); extern void debug_vprintf(int, const char *, va_list); extern void debug_print_socket(int); diff --git a/src/src/globals.h b/src/src/globals.h index 962da137f..47b4b5226 100644 --- a/src/src/globals.h +++ b/src/src/globals.h @@ -544,6 +544,7 @@ extern int dns_dane_ok; /* Ok to use DANE when checking TLS authe extern int dns_retrans; /* Retransmission time setting */ extern int dns_retry; /* Number of retries */ extern int dns_dnssec_ok; /* When constructing DNS query, set DO flag */ +extern const uschar * dns_rc_names[]; /* Mostly for debug output */ extern uschar *dns_trust_aa; /* DNSSEC trust AA as AD */ extern int dns_use_edns0; /* Coerce EDNS0 support on/off in resolver. */ extern uschar *dnslist_domain; /* DNS (black) list domain */ diff --git a/src/src/host.c b/src/src/host.c index 99bbba7a3..7408286ec 100644 --- a/src/src/host.c +++ b/src/src/host.c @@ -3197,7 +3197,7 @@ BOOL sec; rc = dns_lookup_timerwrap(dnsa, buffer, T_TLSA, &fullname); sec = dns_is_secure(dnsa); DEBUG(D_transport) - debug_printf("TLSA lookup ret %d %sDNSSEC\n", rc, sec ? "" : "not "); + debug_printf("TLSA lookup ret %s %sDNSSEC\n", dns_rc_names[rc], sec ? "" : "not "); switch (rc) { diff --git a/src/src/macros.h b/src/src/macros.h index baac435ec..5c3fa06f6 100644 --- a/src/src/macros.h +++ b/src/src/macros.h @@ -313,7 +313,7 @@ Use rc_names[] for debug strings. */ #define DELIVER_MUA_FAILED 2 /* Failure when mua_wrapper is set */ #define DELIVER_NOT_ATTEMPTED 3 /* Not tried (no msg or is locked */ -/* Returns from DNS lookup functions. */ +/* Returns from DNS lookup functions. Use dns_rc_names[] for debug strings */ enum { DNS_SUCCEED, DNS_NOMATCH, DNS_NODATA, DNS_AGAIN, DNS_FAIL }; diff --git a/src/src/spool_in.c b/src/src/spool_in.c index 4b70780bc..a2d3b8914 100644 --- a/src/src/spool_in.c +++ b/src/src/spool_in.c @@ -727,11 +727,7 @@ if (Ustrncmp(big_buffer, "XX\n", 3) != 0 && goto SPOOL_FORMAT_ERROR; #ifndef COMPILE_UTILITY -DEBUG(D_deliver) - { - debug_printf("Non-recipients:\n"); - debug_print_tree(tree_nonrecipients); - } +DEBUG(D_deliver) debug_print_tree("Non-recipients", tree_nonrecipients); #endif /* COMPILE_UTILITY */ /* After reading the tree, the next line has not yet been read into the diff --git a/test/stderr/0183 b/test/stderr/0183 index de7f5ab45..3ffdf28ea 100644 --- a/test/stderr/0183 +++ b/test/stderr/0183 @@ -62,7 +62,7 @@ calling lookuphost router lookuphost router called for abcd@test.again.dns domain = test.again.dns test.again.dns in "*"? yes (matched "*") -DNS lookup of test.again.dns-MX: using cached value DNS_AGAIN +DNS lookup of test.again.dns (MX): using cached value DNS_AGAIN lookuphost router: defer for abcd@test.again.dns message: host lookup did not complete >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> @@ -166,7 +166,7 @@ expanded list of hosts = 'test.again.dns' options = 'bydns' finding IP address for test.again.dns doing DNS lookup test.again.dns in "*"? yes (matched "*") -DNS lookup of test.again.dns-A: using cached value DNS_AGAIN +DNS lookup of test.again.dns (A): using cached value DNS_AGAIN useryz router: defer for userz@test.again.dns message: host lookup for test.again.dns did not complete (DNS timeout?) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> @@ -193,7 +193,7 @@ calling lookuphost router lookuphost router called for xyz@ten-1.test.ex domain = ten-1.test.ex ten-1.test.ex in "*"? yes (matched "*") -DNS lookup of ten-1.test.ex-MX: using cached value DNS_NODATA +DNS lookup of ten-1.test.ex (MX): using cached value DNS_NODATA DNS lookup of ten-1.test.ex (A) using fakens DNS lookup of ten-1.test.ex (A) succeeded fully qualified name = ten-1.test.ex @@ -271,7 +271,7 @@ calling lookuphost router lookuphost router called for abcd@test.fail.dns domain = test.fail.dns test.fail.dns in "*"? yes (matched "*") -DNS lookup of test.fail.dns-MX: using cached value DNS_FAIL +DNS lookup of test.fail.dns (MX): using cached value DNS_FAIL lookuphost router: defer for abcd@test.fail.dns message: host lookup did not complete >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> @@ -374,7 +374,7 @@ expanded list of hosts = 'test.fail.dns' options = 'bydns' finding IP address for test.fail.dns doing DNS lookup test.fail.dns in "*"? yes (matched "*") -DNS lookup of test.fail.dns-A: using cached value DNS_FAIL +DNS lookup of test.fail.dns (A): using cached value DNS_FAIL useryz router: defer for userz@test.fail.dns message: host lookup for test.fail.dns did not complete (DNS timeout?) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> @@ -401,7 +401,7 @@ calling lookuphost router lookuphost router called for xyz@ten-1.test.ex domain = ten-1.test.ex ten-1.test.ex in "*"? yes (matched "*") -DNS lookup of ten-1.test.ex-MX: using cached value DNS_NODATA +DNS lookup of ten-1.test.ex (MX): using cached value DNS_NODATA DNS lookup of ten-1.test.ex (A) using fakens DNS lookup of ten-1.test.ex (A) succeeded fully qualified name = ten-1.test.ex @@ -481,7 +481,7 @@ calling lookuphost router lookuphost router called for abcd@nonexist.test.ex domain = nonexist.test.ex nonexist.test.ex in "*"? yes (matched "*") -DNS lookup of nonexist.test.ex-MX: using cached value DNS_NOMATCH +DNS lookup of nonexist.test.ex (MX): using cached value DNS_NOMATCH lookuphost router declined for abcd@nonexist.test.ex "more" is false: skipping remaining routers no more routers @@ -586,7 +586,7 @@ expanded list of hosts = 'nonexist.test.ex' options = 'bydns' finding IP address for nonexist.test.ex doing DNS lookup nonexist.test.ex in "*"? yes (matched "*") -DNS lookup of nonexist.test.ex-A: using cached value DNS_NOMATCH +DNS lookup of nonexist.test.ex (A): using cached value DNS_NOMATCH useryz router: defer for userz@nonexist.test.ex message: lookup of host "nonexist.test.ex" failed in useryz router >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> @@ -613,7 +613,7 @@ calling lookuphost router lookuphost router called for xyz@ten-1.test.ex domain = ten-1.test.ex ten-1.test.ex in "*"? yes (matched "*") -DNS lookup of ten-1.test.ex-MX: using cached value DNS_NODATA +DNS lookup of ten-1.test.ex (MX): using cached value DNS_NODATA DNS lookup of ten-1.test.ex (A) using fakens DNS lookup of ten-1.test.ex (A) succeeded fully qualified name = ten-1.test.ex @@ -769,7 +769,7 @@ calling delay router delay router called for userd@nonexist.example.com domain = nonexist.example.com nonexist.example.com in "*"? yes (matched "*") -DNS lookup of nonexist.example.com-MX: cached value DNS_NOMATCH past valid time +DNS lookup of nonexist.example.com (MX): cached value DNS_NOMATCH past valid time DNS lookup of nonexist.example.com (MX) using fakens DNS lookup of nonexist.example.com (MX) gave HOST_NOT_FOUND returning DNS_NOMATCH diff --git a/test/stderr/0264 b/test/stderr/0264 index d8e96191c..f572148f1 100644 --- a/test/stderr/0264 +++ b/test/stderr/0264 @@ -17,7 +17,7 @@ reading spool file 10HmbJ-0005vi-00-H user=CALLER uid=CALLER_UID gid=CALLER_GID sender=CALLER@test.ex sender_local=1 ident=CALLER Non-recipients: -Empty Tree + Empty Tree ---- End of tree ---- recipients_count=1 **** SPOOL_IN - No additional fields diff --git a/test/stderr/0275 b/test/stderr/0275 index 35f1e4442..a39ab10b3 100644 --- a/test/stderr/0275 +++ b/test/stderr/0275 @@ -159,7 +159,7 @@ reading spool file 10HmaX-0005vi-00-H user=CALLER uid=CALLER_UID gid=CALLER_GID sender=CALLER@test.ex sender_local=1 ident=CALLER Non-recipients: -Empty Tree + Empty Tree ---- End of tree ---- recipients_count=1 **** SPOOL_IN - No additional fields diff --git a/test/stderr/0278 b/test/stderr/0278 index 23b0ba9c6..634c3facc 100644 --- a/test/stderr/0278 +++ b/test/stderr/0278 @@ -118,7 +118,7 @@ reading spool file 10HmaX-0005vi-00-H user=CALLER uid=CALLER_UID gid=CALLER_GID sender=CALLER@test.ex sender_local=1 ident=CALLER Non-recipients: -Empty Tree + Empty Tree ---- End of tree ---- recipients_count=1 **** SPOOL_IN - No additional fields diff --git a/test/stderr/0361 b/test/stderr/0361 index 5a57d3322..1eb948586 100644 --- a/test/stderr/0361 +++ b/test/stderr/0361 @@ -64,7 +64,7 @@ reading spool file 10HmaY-0005vi-00-H user=CALLER uid=CALLER_UID gid=CALLER_GID sender=CALLER@test.ex sender_local=1 ident=CALLER Non-recipients: -Empty Tree + Empty Tree ---- End of tree ---- recipients_count=1 **** SPOOL_IN - No additional fields diff --git a/test/stderr/0386 b/test/stderr/0386 index b136548b7..fb7382b21 100644 --- a/test/stderr/0386 +++ b/test/stderr/0386 @@ -260,7 +260,7 @@ sender_fullhost = [V4NET.11.12.13] sender_rcvhost = [V4NET.11.12.13] (ident=CALLER) sender_local=0 ident=CALLER Non-recipients: -Empty Tree + Empty Tree ---- End of tree ---- recipients_count=1 **** SPOOL_IN - No additional fields @@ -449,7 +449,7 @@ sender_fullhost = [V4NET.11.12.13] sender_rcvhost = [V4NET.11.12.13] (ident=CALLER) sender_local=0 ident=CALLER Non-recipients: -Empty Tree + Empty Tree ---- End of tree ---- recipients_count=1 **** SPOOL_IN - No additional fields diff --git a/test/stderr/0402 b/test/stderr/0402 index 1f6bf19c7..2fe542bb7 100644 --- a/test/stderr/0402 +++ b/test/stderr/0402 @@ -189,7 +189,7 @@ reading spool file 10HmaX-0005vi-00-H user=CALLER uid=CALLER_UID gid=CALLER_GID sender=CALLER@test.ex sender_local=1 ident=CALLER Non-recipients: -Empty Tree + Empty Tree ---- End of tree ---- recipients_count=5 **** SPOOL_IN - No additional fields diff --git a/test/stderr/0403 b/test/stderr/0403 index 16bf13b5e..c71e924fe 100644 --- a/test/stderr/0403 +++ b/test/stderr/0403 @@ -58,7 +58,7 @@ reading spool file 10HmaX-0005vi-00-H user=CALLER uid=CALLER_UID gid=CALLER_GID sender=CALLER@test.ex sender_local=1 ident=CALLER Non-recipients: -Empty Tree + Empty Tree ---- End of tree ---- recipients_count=1 **** SPOOL_IN - No additional fields diff --git a/test/stderr/0404 b/test/stderr/0404 index b1a78c9fa..4d5aeaf3e 100644 --- a/test/stderr/0404 +++ b/test/stderr/0404 @@ -159,7 +159,7 @@ reading spool file 10HmaX-0005vi-00-H user=CALLER uid=CALLER_UID gid=CALLER_GID sender=CALLER@test.ex sender_local=1 ident=CALLER Non-recipients: -Empty Tree + Empty Tree ---- End of tree ---- recipients_count=1 **** SPOOL_IN - No additional fields @@ -925,7 +925,7 @@ reading spool file 10HmaY-0005vi-00-H user=CALLER uid=CALLER_UID gid=CALLER_GID sender= sender_local=1 ident=CALLER Non-recipients: -Empty Tree + Empty Tree ---- End of tree ---- recipients_count=608 **** SPOOL_IN - No additional fields diff --git a/test/stderr/0408 b/test/stderr/0408 index 3fbd0f2a6..6320691f3 100644 --- a/test/stderr/0408 +++ b/test/stderr/0408 @@ -58,7 +58,7 @@ reading spool file 10HmaX-0005vi-00-H user=CALLER uid=CALLER_UID gid=CALLER_GID sender=CALLER@test.ex sender_local=1 ident=CALLER Non-recipients: -Empty Tree + Empty Tree ---- End of tree ---- recipients_count=1 **** SPOOL_IN - No additional fields diff --git a/test/stderr/0487 b/test/stderr/0487 index 83d243a54..e8e9dcb75 100644 --- a/test/stderr/0487 +++ b/test/stderr/0487 @@ -86,7 +86,7 @@ reading spool file 10HmaX-0005vi-00-H user=CALLER uid=CALLER_UID gid=CALLER_GID sender=x@y sender_local=0 ident=CALLER Non-recipients: -Empty Tree + Empty Tree ---- End of tree ---- recipients_count=1 **** SPOOL_IN - No additional fields diff --git a/test/stderr/0514 b/test/stderr/0514 index 0c24042f8..ab55c9a2e 100644 --- a/test/stderr/0514 +++ b/test/stderr/0514 @@ -11,7 +11,7 @@ reading spool file 10HmaX-0005vi-00-H user=spaced user uid=CALLER_UID gid=CALLER_GID sender="spaced user"@myhost.test.ex sender_local=1 ident=spaced user Non-recipients: -Empty Tree + Empty Tree ---- End of tree ---- recipients_count=1 **** SPOOL_IN - No additional fields diff --git a/test/stderr/0545 b/test/stderr/0545 index da669b580..96f235c76 100644 --- a/test/stderr/0545 +++ b/test/stderr/0545 @@ -52,7 +52,7 @@ alias-eximtesthost.test.ex in "*"? yes (matched "*") DNS lookup of alias-eximtesthost.test.ex (MX) using fakens DNS lookup of alias-eximtesthost.test.ex (MX) succeeded CNAME found: change to eximtesthost.test.ex -DNS lookup of eximtesthost.test.ex-MX: using cached value DNS_NODATA +DNS lookup of eximtesthost.test.ex (MX): using cached value DNS_NODATA DNS lookup of alias-eximtesthost.test.ex (A) using fakens DNS lookup of alias-eximtesthost.test.ex (A) succeeded CNAME found: change to eximtesthost.test.ex diff --git a/test/stderr/2600 b/test/stderr/2600 index 93bb7fa1b..0f29c58fd 100644 --- a/test/stderr/2600 +++ b/test/stderr/2600 @@ -469,7 +469,7 @@ reading spool file 10HmaX-0005vi-00-H user=CALLER uid=CALLER_UID gid=CALLER_GID sender=CALLER@myhost.test.ex sender_local=1 ident=CALLER Non-recipients: -Empty Tree + Empty Tree ---- End of tree ---- recipients_count=1 **** SPOOL_IN - No additional fields diff --git a/test/stderr/2610 b/test/stderr/2610 index 7ed300aff..8bd7810b0 100644 --- a/test/stderr/2610 +++ b/test/stderr/2610 @@ -467,7 +467,7 @@ reading spool file 10HmaX-0005vi-00-H user=CALLER uid=CALLER_UID gid=CALLER_GID sender=CALLER@myhost.test.ex sender_local=1 ident=CALLER Non-recipients: -Empty Tree + Empty Tree ---- End of tree ---- recipients_count=1 **** SPOOL_IN - No additional fields diff --git a/test/stderr/2620 b/test/stderr/2620 index 2595070e3..7875ec24b 100644 --- a/test/stderr/2620 +++ b/test/stderr/2620 @@ -524,7 +524,7 @@ reading spool file 10HmaX-0005vi-00-H user=CALLER uid=CALLER_UID gid=CALLER_GID sender=CALLER@myhost.test.ex sender_local=1 ident=CALLER Non-recipients: -Empty Tree + Empty Tree ---- End of tree ---- recipients_count=1 **** SPOOL_IN - No additional fields diff --git a/test/stderr/5004 b/test/stderr/5004 index 0ec996f90..4d0ac7735 100644 --- a/test/stderr/5004 +++ b/test/stderr/5004 @@ -62,7 +62,7 @@ reading spool file 10HmaX-0005vi-00-H user=CALLER uid=CALLER_UID gid=CALLER_GID sender=CALLER@test.ex sender_local=1 ident=CALLER Non-recipients: -Empty Tree + Empty Tree ---- End of tree ---- recipients_count=1 **** SPOOL_IN - No additional fields diff --git a/test/stderr/5005 b/test/stderr/5005 index 324d30d9e..417ddaec9 100644 --- a/test/stderr/5005 +++ b/test/stderr/5005 @@ -58,7 +58,7 @@ reading spool file 10HmaX-0005vi-00-H user=CALLER uid=CALLER_UID gid=CALLER_GID sender=CALLER@test.ex sender_local=1 ident=CALLER Non-recipients: -Empty Tree + Empty Tree ---- End of tree ---- recipients_count=1 **** SPOOL_IN - No additional fields @@ -243,7 +243,7 @@ reading spool file 10HmaY-0005vi-00-H user=CALLER uid=CALLER_UID gid=CALLER_GID sender=CALLER@test.ex sender_local=1 ident=CALLER Non-recipients: -Empty Tree + Empty Tree ---- End of tree ---- recipients_count=1 **** SPOOL_IN - No additional fields @@ -429,7 +429,7 @@ reading spool file 10HmaZ-0005vi-00-H user=CALLER uid=CALLER_UID gid=CALLER_GID sender=CALLER@test.ex sender_local=1 ident=CALLER Non-recipients: -Empty Tree + Empty Tree ---- End of tree ---- recipients_count=1 **** SPOOL_IN - No additional fields @@ -621,7 +621,7 @@ reading spool file 10HmbA-0005vi-00-H user=CALLER uid=CALLER_UID gid=CALLER_GID sender=CALLER@test.ex sender_local=1 ident=CALLER Non-recipients: -Empty Tree + Empty Tree ---- End of tree ---- recipients_count=1 **** SPOOL_IN - No additional fields diff --git a/test/stderr/5006 b/test/stderr/5006 index d7f3b1872..18dd1491d 100644 --- a/test/stderr/5006 +++ b/test/stderr/5006 @@ -58,7 +58,7 @@ reading spool file 10HmaX-0005vi-00-H user=CALLER uid=CALLER_UID gid=CALLER_GID sender=CALLER@test.ex sender_local=1 ident=CALLER Non-recipients: -Empty Tree + Empty Tree ---- End of tree ---- recipients_count=1 **** SPOOL_IN - No additional fields