Module Name:    src
Committed By:   rillig
Date:           Fri Dec  4 14:28:50 UTC 2020

Modified Files:
        src/usr.bin/make: dir.c
        src/usr.bin/make/unit-tests: Makefile opt-debug-graph1.exp
            suff-main-several.exp suff-transform-debug.exp

Log Message:
make(1): use fixed format for debug output of the directory cache

The previous output format had a %-20s conversion specifier.  This
produced different output depending on the length of the pathname, which
was too difficult to normalize.  By moving the directory name to the
end, it is no longer necessary to fill up any space, and the numbers are
always aligned properly.

As a result, 3 of the unit tests no longer need any special
postprocessing of their output.


To generate a diff of this commit:
cvs rdiff -u -r1.247 -r1.248 src/usr.bin/make/dir.c
cvs rdiff -u -r1.234 -r1.235 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/opt-debug-graph1.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/suff-main-several.exp \
    src/usr.bin/make/unit-tests/suff-transform-debug.exp

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/dir.c
diff -u src/usr.bin/make/dir.c:1.247 src/usr.bin/make/dir.c:1.248
--- src/usr.bin/make/dir.c:1.247	Tue Dec  1 20:47:52 2020
+++ src/usr.bin/make/dir.c	Fri Dec  4 14:28:50 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.247 2020/12/01 20:47:52 rillig Exp $	*/
+/*	$NetBSD: dir.c,v 1.248 2020/12/04 14:28:50 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -136,7 +136,7 @@
 #include "job.h"
 
 /*	"@(#)dir.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: dir.c,v 1.247 2020/12/01 20:47:52 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.248 2020/12/04 14:28:50 rillig Exp $");
 
 #define DIR_DEBUG0(text) DEBUG0(DIR, text)
 #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1)
@@ -1655,12 +1655,12 @@ Dir_PrintDirectories(void)
 	    "# Stats: %d hits %d misses %d near misses %d losers (%d%%)\n",
 	    hits, misses, nearmisses, bigmisses,
 	    percentage(hits, hits + bigmisses + nearmisses));
-	debug_printf("# %-20s referenced\thits\n", "directory");
+	debug_printf("#  refs  hits  directory\n");
 
 	for (ln = openDirs.list.first; ln != NULL; ln = ln->next) {
 		CachedDir *dir = ln->datum;
-		debug_printf("# %-20s %10d\t%4d\n",
-			     dir->name, dir->refCount, dir->hits);
+		debug_printf("#  %4d  %4d  %s\n",
+		    dir->refCount, dir->hits, dir->name);
 	}
 }
 

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.234 src/usr.bin/make/unit-tests/Makefile:1.235
--- src/usr.bin/make/unit-tests/Makefile:1.234	Tue Dec  1 22:16:36 2020
+++ src/usr.bin/make/unit-tests/Makefile	Fri Dec  4 14:28:50 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.234 2020/12/01 22:16:36 rillig Exp $
+# $NetBSD: Makefile,v 1.235 2020/12/04 14:28:50 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -497,12 +497,9 @@ SED_CMDS.varname-dot-shell+=	-e 's,"/[^"
 SED_CMDS.varname-dot-shell+=	-e 's,\[/[^] ]*\],[(details omitted)],g'
 
 # Some tests need an additional round of postprocessing.
-POSTPROC.deptgt-suffixes= awk '/^\#\*\*\* Suffixes/,/^never-stop/'
-POSTPROC.gnode-submake=	awk '/Input graph/, /^$$/'
-POSTPROC.opt-debug-graph1=	${STD_POSTPROC.dg1}
-POSTPROC.varname-empty=	${TOOL_SED} -n -e '/^Var_Set/p' -e '/^out:/p'
-POSTPROC.suff-main-several=	${STD_POSTPROC.dg1}
-POSTPROC.suff-transform-debug=	${STD_POSTPROC.dg1}
+POSTPROC.deptgt-suffixes=	awk '/^\#\*\*\* Suffixes/,/^never-stop/'
+POSTPROC.gnode-submake=		awk '/Input graph/, /^$$/'
+POSTPROC.varname-empty=		${TOOL_SED} -n -e '/^Var_Set/p' -e '/^out:/p'
 
 # Some tests reuse other tests, which makes them unnecessarily fragile.
 export-all.rawout: export.mk
@@ -514,16 +511,13 @@ unexport-env.rawout: export.mk
 # Some standard sed commands, to be used in the SED_CMDS above.
 
 # Omit details from the output of the -dg1 option such as process IDs.
-STD_SED_CMDS.dg1=	-e 's,${.CURDIR},<curdir>,'
+STD_SED_CMDS.dg1=	-e 's,${.CURDIR}$$,<curdir>,'
+STD_SED_CMDS.dg1+=	-e 's,  ${DEFSYSPATH:U/usr/share/mk}$$,  <defsyspath>,'
 STD_SED_CMDS.dg1+=	-e 's,^\(\.MAKE *=\) .*,\1 <details omitted>,'
 STD_SED_CMDS.dg1+=	-e 's,^\(\.MAKE\.[A-Z_]* *=\) .*,\1 <details omitted>,'
 STD_SED_CMDS.dg1+=	-e 's,^\(MACHINE[_ARCH]* *=\) .*,\1 <details omitted>,'
 STD_SED_CMDS.dg1+=	-e 's,^\(MAKE *=\) .*,\1 <details omitted>,'
 
-# The layout of the lines in the directory cache vary depending on the path
-# length, which cannot be predicted.  Therefore omit these lines.
-STD_POSTPROC.dg1=	awk '/Directory Cache/,/^$$/ { next } { print }'
-
 # End of the configuration helpers section.
 
 .MAIN: all

Index: src/usr.bin/make/unit-tests/opt-debug-graph1.exp
diff -u src/usr.bin/make/unit-tests/opt-debug-graph1.exp:1.7 src/usr.bin/make/unit-tests/opt-debug-graph1.exp:1.8
--- src/usr.bin/make/unit-tests/opt-debug-graph1.exp:1.7	Wed Nov 25 00:50:44 2020
+++ src/usr.bin/make/unit-tests/opt-debug-graph1.exp	Fri Dec  4 14:28:50 2020
@@ -43,6 +43,13 @@ MFLAGS           =   -r -k -d g1
 #*** Command-line Variables:
 .MAKE.LEVEL.ENV  = MAKELEVEL
 
+#*** Directory Cache:
+# Stats: 0 hits 2 misses 0 near misses 0 losers (0%)
+#  refs  hits  directory
+#     1     0  <curdir>
+#     1     0  .
+#     1     0  <defsyspath>
+
 #*** Suffixes:
 #*** Transformations:
 exit status 0

Index: src/usr.bin/make/unit-tests/suff-main-several.exp
diff -u src/usr.bin/make/unit-tests/suff-main-several.exp:1.2 src/usr.bin/make/unit-tests/suff-main-several.exp:1.3
--- src/usr.bin/make/unit-tests/suff-main-several.exp:1.2	Wed Nov 25 00:50:44 2020
+++ src/usr.bin/make/unit-tests/suff-main-several.exp	Fri Dec  4 14:28:50 2020
@@ -108,6 +108,13 @@ MFLAGS           =   -r -k -d mps -d 0 -
 #*** Command-line Variables:
 .MAKE.LEVEL.ENV  = MAKELEVEL
 
+#*** Directory Cache:
+# Stats: 0 hits 2 misses 0 near misses 0 losers (0%)
+#  refs  hits  directory
+#     1     0  <curdir>
+#     1     0  .
+#     1     0  <defsyspath>
+
 #*** Suffixes:
 # ".4" (num 1, ref 1)
 #	To: 
Index: src/usr.bin/make/unit-tests/suff-transform-debug.exp
diff -u src/usr.bin/make/unit-tests/suff-transform-debug.exp:1.2 src/usr.bin/make/unit-tests/suff-transform-debug.exp:1.3
--- src/usr.bin/make/unit-tests/suff-transform-debug.exp:1.2	Wed Nov 25 00:50:44 2020
+++ src/usr.bin/make/unit-tests/suff-transform-debug.exp	Fri Dec  4 14:28:50 2020
@@ -34,6 +34,13 @@ MFLAGS           =   -r -k -d g1
 #*** Command-line Variables:
 .MAKE.LEVEL.ENV  = MAKELEVEL
 
+#*** Directory Cache:
+# Stats: 0 hits 2 misses 0 near misses 0 losers (0%)
+#  refs  hits  directory
+#     1     0  <curdir>
+#     1     0  .
+#     1     0  <defsyspath>
+
 #*** Suffixes:
 # ".a" (num 1, ref 2)
 #	To: 

Reply via email to