Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make make(1): use fixed format for debug output of t...



details:   https://anonhg.NetBSD.org/src/rev/59ee110c12d8
branches:  trunk
changeset: 946603:59ee110c12d8
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Dec 04 14:28:50 2020 +0000

description:
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.

diffstat:

 usr.bin/make/dir.c                               |  10 +++++-----
 usr.bin/make/unit-tests/Makefile                 |  18 ++++++------------
 usr.bin/make/unit-tests/opt-debug-graph1.exp     |   7 +++++++
 usr.bin/make/unit-tests/suff-main-several.exp    |   7 +++++++
 usr.bin/make/unit-tests/suff-transform-debug.exp |   7 +++++++
 5 files changed, 32 insertions(+), 17 deletions(-)

diffs (129 lines):

diff -r 57216a87bd8d -r 59ee110c12d8 usr.bin/make/dir.c
--- a/usr.bin/make/dir.c        Fri Dec 04 08:29:11 2020 +0000
+++ b/usr.bin/make/dir.c        Fri Dec 04 14:28:50 2020 +0000
@@ -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 @@
            "# 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);
        }
 }
 
diff -r 57216a87bd8d -r 59ee110c12d8 usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile  Fri Dec 04 08:29:11 2020 +0000
+++ b/usr.bin/make/unit-tests/Makefile  Fri Dec 04 14:28:50 2020 +0000
@@ -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,\[/[^] ]*\],[(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 @@
 # 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
diff -r 57216a87bd8d -r 59ee110c12d8 usr.bin/make/unit-tests/opt-debug-graph1.exp
--- a/usr.bin/make/unit-tests/opt-debug-graph1.exp      Fri Dec 04 08:29:11 2020 +0000
+++ b/usr.bin/make/unit-tests/opt-debug-graph1.exp      Fri Dec 04 14:28:50 2020 +0000
@@ -43,6 +43,13 @@
 #*** 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
diff -r 57216a87bd8d -r 59ee110c12d8 usr.bin/make/unit-tests/suff-main-several.exp
--- a/usr.bin/make/unit-tests/suff-main-several.exp     Fri Dec 04 08:29:11 2020 +0000
+++ b/usr.bin/make/unit-tests/suff-main-several.exp     Fri Dec 04 14:28:50 2020 +0000
@@ -108,6 +108,13 @@
 #*** 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: 
diff -r 57216a87bd8d -r 59ee110c12d8 usr.bin/make/unit-tests/suff-transform-debug.exp
--- a/usr.bin/make/unit-tests/suff-transform-debug.exp  Fri Dec 04 08:29:11 2020 +0000
+++ b/usr.bin/make/unit-tests/suff-transform-debug.exp  Fri Dec 04 14:28:50 2020 +0000
@@ -34,6 +34,13 @@
 #*** 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: 



Home | Main Index | Thread Index | Old Index