MINOR: debug: add a new DEBUG_FD build option

When DEBUG_FD is set at build time, we'll keep a counter of per-FD events
in the fdtab. This counter is reported in "show fd" even for closed FDs if
not zero. The purpose is to help spot situations where an apparently closed
FD continues to be reported in loops, or where some events are dismissed.
diff --git a/src/cli.c b/src/cli.c
index b8fac13..b9afc1b 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -1002,7 +1002,14 @@
 
 		fdt = fdtab[fd];
 
-		if (!fdt.owner)
+		/* When DEBUG_FD is set, we also report closed FDs that have a
+		 * non-null event count to detect stuck ones.
+		 */
+		if (!fdt.owner
+#ifdef DEBUG_FD
+		    && !fdt.event_count
+#endif
+		    )
 			goto skip; // closed
 
 		if (fdt.iocb == conn_fd_handler) {
@@ -1038,7 +1045,10 @@
 			     fdt.iocb);
 		resolve_sym_name(&trash, NULL, fdt.iocb);
 
-		if (fdt.iocb == conn_fd_handler) {
+		if (!fdt.owner) {
+			chunk_appendf(&trash, ")");
+		}
+		else if (fdt.iocb == conn_fd_handler) {
 			chunk_appendf(&trash, ") back=%d cflg=0x%08x", is_back, conn_flags);
 			if (px)
 				chunk_appendf(&trash, " px=%s", px->id);
@@ -1061,6 +1071,9 @@
 			              li->bind_conf->frontend->id);
 		}
 
+#ifdef DEBUG_FD
+		chunk_appendf(&trash, " evcnt=%u", fdtab[fd].event_count);
+#endif
 		chunk_appendf(&trash, ")\n");
 
 		if (ci_putchk(si_ic(si), &trash) == -1) {