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: add more details to debug logging of .for...



details:   https://anonhg.NetBSD.org/src/rev/fca1bcb9a0b4
branches:  trunk
changeset: 376107:fca1bcb9a0b4
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Jun 01 09:02:14 2023 +0000

description:
make: add more details to debug logging of .for loops

diffstat:

 usr.bin/make/for.c                               |  11 ++-
 usr.bin/make/unit-tests/directive-for-empty.exp  |   2 +-
 usr.bin/make/unit-tests/directive-for-escape.exp |  75 ++++++++++++-----------
 usr.bin/make/unit-tests/directive-for-escape.mk  |   8 +-
 usr.bin/make/unit-tests/directive-for.exp        |   4 +-
 usr.bin/make/unit-tests/opt-debug-for.exp        |  12 +-
 6 files changed, 60 insertions(+), 52 deletions(-)

diffs (285 lines):

diff -r 3257d20adf34 -r fca1bcb9a0b4 usr.bin/make/for.c
--- a/usr.bin/make/for.c        Thu Jun 01 08:20:10 2023 +0000
+++ b/usr.bin/make/for.c        Thu Jun 01 09:02:14 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: for.c,v 1.175 2023/06/01 07:44:10 rillig Exp $ */
+/*     $NetBSD: for.c,v 1.176 2023/06/01 09:02:14 rillig Exp $ */
 
 /*
  * Copyright (c) 1992, The Regents of the University of California.
@@ -58,7 +58,7 @@
 #include "make.h"
 
 /*     "@(#)for.c      8.1 (Berkeley) 6/6/93"  */
-MAKE_RCSID("$NetBSD: for.c,v 1.175 2023/06/01 07:44:10 rillig Exp $");
+MAKE_RCSID("$NetBSD: for.c,v 1.176 2023/06/01 09:02:14 rillig Exp $");
 
 
 typedef struct ForLoop {
@@ -513,7 +513,12 @@ For_NextIteration(ForLoop *f, Buffer *bo
 
        f->nextItem += (unsigned int)f->vars.len;
        ForLoop_SubstBody(f, f->nextItem - (unsigned int)f->vars.len, body);
-       DEBUG1(FOR, "For: loop body:\n%s", body->data);
+       if (DEBUG(FOR)) {
+               char *details = ForLoop_Details(f);
+               debug_printf("For: loop body with %s:\n%s",
+                   details, body->data);
+               free(details);
+       }
        return true;
 }
 
diff -r 3257d20adf34 -r fca1bcb9a0b4 usr.bin/make/unit-tests/directive-for-empty.exp
--- a/usr.bin/make/unit-tests/directive-for-empty.exp   Thu Jun 01 08:20:10 2023 +0000
+++ b/usr.bin/make/unit-tests/directive-for-empty.exp   Thu Jun 01 09:02:14 2023 +0000
@@ -3,7 +3,7 @@ make: "directive-for-empty.mk" line 34: 
 make: "directive-for-empty.mk" line 34: Missing argument for ".error"
 make: "directive-for-empty.mk" line 34: Missing argument for ".error"
 For: end for 1
-For: loop body:
+For: loop body with i = value:
 # The identifier 'empty' can only be used in conditions such as .if, .ifdef or
 # .elif.  In other lines the string 'empty(' must be preserved.
 CPPFLAGS+=     -Dmessage="empty(i)"
diff -r 3257d20adf34 -r fca1bcb9a0b4 usr.bin/make/unit-tests/directive-for-escape.exp
--- a/usr.bin/make/unit-tests/directive-for-escape.exp  Thu Jun 01 08:20:10 2023 +0000
+++ b/usr.bin/make/unit-tests/directive-for-escape.exp  Thu Jun 01 09:02:14 2023 +0000
@@ -1,52 +1,52 @@
 For: end for 1
-For: loop body:
+For: loop body with chars = !"#$%&'()*+,-./0-9:;<=>?@A-Z[\]_^a-z{|}~:
 .  info ${:U!"#$%&'()*+,-./0-9\:;<=>?@A-Z[\\]_^a-z{|\}~}
 make: Unclosed variable expression, expecting '}' for modifier "U!"" of variable "" with value "!""
 make: "directive-for-escape.mk" line 21: !"
 For: end for 1
-For: loop body:
+For: loop body with chars = !"\\#$%&'()*+,-./0-9:;<=>?@A-Z[\]_^a-z{|}~:
 .  info ${:U!"\\\\#$%&'()*+,-./0-9\:;<=>?@A-Z[\\]_^a-z{|\}~}
 make: Unclosed variable expression, expecting '}' for modifier "U!"\\\\" of variable "" with value "!"\\"
 make: "directive-for-escape.mk" line 32: !"\\
 For: end for 1
-For: loop body:
+For: loop body with i = $:
 .  info ${:U\$}
 make: "directive-for-escape.mk" line 47: $
-For: loop body:
+For: loop body with i = ${V}:
 .  info ${:U${V}}
 make: "directive-for-escape.mk" line 47: value
-For: loop body:
+For: loop body with i = ${V:=-with-modifier}:
 .  info ${:U${V:=-with-modifier}}
 make: "directive-for-escape.mk" line 47: value-with-modifier
-For: loop body:
+For: loop body with i = $(V):
 .  info ${:U$(V)}
 make: "directive-for-escape.mk" line 47: value
-For: loop body:
+For: loop body with i = $(V:=-with-modifier):
 .  info ${:U$(V:=-with-modifier)}
 make: "directive-for-escape.mk" line 47: value-with-modifier
 For: end for 1
-For: loop body:
+For: loop body with i = ${UNDEF:U\$\$:
 # ${:U\${UNDEF\:U\\$\\$}
-For: loop body:
+For: loop body with i = {{}}:
 # ${:U{{\}\}}
-For: loop body:
+For: loop body with i = end}:
 # ${:Uend\}}
 For: end for 1
-For: loop body:
+For: loop body with i = ${UNDEF:U\$\$:
 .  info ${:U\${UNDEF\:U\\$\\$}
 make: "directive-for-escape.mk" line 101: ${UNDEF:U\backslash$
-For: loop body:
+For: loop body with i = {{}}:
 .  info ${:U{{\}\}}
 make: "directive-for-escape.mk" line 101: {{}}
-For: loop body:
+For: loop body with i = end}:
 .  info ${:Uend\}}
 make: "directive-for-escape.mk" line 101: end}
 For: end for 1
-For: loop body:
+For: loop body with i = begin<${UNDEF:Ufallback:N{{{}}}}>end:
 .  info ${:Ubegin<${UNDEF:Ufallback:N{{{}}}}>end}
 make: "directive-for-escape.mk" line 122: begin<fallback>end
 For: end for 1
-For: loop body:
+For: loop body with i = $:
 .  info ${:U\$}
 make: "directive-for-escape.mk" line 131: $
 make: "directive-for-escape.mk" line 140: invalid character ':' in .for loop variable name
@@ -54,7 +54,7 @@ For: end for 1
 make: "directive-for-escape.mk" line 150: invalid character '}' in .for loop variable name
 For: end for 1
 For: end for 1
-For: loop body:
+For: loop body with i = inner:
 .  info .        $$i: ${:Uinner}
 .  info .      $${i}: ${:Uinner}
 .  info .   $${i:M*}: ${:Uinner:M*}
@@ -81,19 +81,22 @@ make: "directive-for-escape.mk" line 199
 For: end for 1
 make: "directive-for-escape.mk" line 212: newline in .for value
 make: "directive-for-escape.mk" line 212: newline in .for value
-For: loop body:
+For: loop body with i = "
+":
 .  info short: ${:U" "}
 .  info long: ${:U" "}
 make: "directive-for-escape.mk" line 213: short: " "
 make: "directive-for-escape.mk" line 214: long: " "
 For: end for 1
-For: loop body:
+For: loop body with i = "
+":
 For: end for 1
 Parse_PushInput: .for loop in directive-for-escape.mk, line 230
 make: "directive-for-escape.mk" line 230: newline in .for value
        in .for loop from directive-for-escape.mk:230 with i = "
 "
-For: loop body:
+For: loop body with i = "
+":
 : ${:U" "}
 SetFilenameVars: ${.PARSEDIR} = <some-dir> ${.PARSEFILE} = `directive-for-escape.mk'
 Parsing line 231: : ${:U" "}
@@ -103,42 +106,42 @@ SetFilenameVars: ${.PARSEDIR} = <some-di
 Parsing line 233: .MAKEFLAGS: -d0
 ParseDependency(.MAKEFLAGS: -d0)
 For: end for 1
-For: loop body:
+For: loop body with i = #:
 # ${:U#}
-For: loop body:
+For: loop body with i = \\#:
 # ${:U\\\\#}
 For: end for 1
-For: loop body:
+For: loop body with i = $:
 # ${:U\$}
-For: loop body:
+For: loop body with i = $i:
 # ${:U$i}
-For: loop body:
+For: loop body with i = $(i):
 # ${:U$(i)}
-For: loop body:
+For: loop body with i = ${i}:
 # ${:U${i}}
-For: loop body:
+For: loop body with i = $$:
 # ${:U$$}
-For: loop body:
+For: loop body with i = $$$$:
 # ${:U$$$$}
-For: loop body:
+For: loop body with i = ${:U\$\$}:
 # ${:U${:U\$\$}}
 For: end for 1
-For: loop body:
+For: loop body with i = ${.TARGET}:
 # ${:U${.TARGET}}
-For: loop body:
+For: loop body with i = ${.TARGET}:
 # ${:U${.TARGET}}
-For: loop body:
+For: loop body with i = $${.TARGET}:
 # ${:U$${.TARGET\}}
-For: loop body:
+For: loop body with i = $${.TARGET}:
 # ${:U$${.TARGET\}}
 For: end for 1
-For: loop body:
+For: loop body with i = (((:
 # ${:U(((}
-For: loop body:
+For: loop body with i = {{{:
 # ${:U{{{}
-For: loop body:
+For: loop body with i = ))):
 # ${:U)))}
-For: loop body:
+For: loop body with i = }}}:
 # ${:U\}\}\}}
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
diff -r 3257d20adf34 -r fca1bcb9a0b4 usr.bin/make/unit-tests/directive-for-escape.mk
--- a/usr.bin/make/unit-tests/directive-for-escape.mk   Thu Jun 01 08:20:10 2023 +0000
+++ b/usr.bin/make/unit-tests/directive-for-escape.mk   Thu Jun 01 09:02:14 2023 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: directive-for-escape.mk,v 1.18 2023/05/09 19:43:12 rillig Exp $
+# $NetBSD: directive-for-escape.mk,v 1.19 2023/06/01 09:02:14 rillig Exp $
 #
 # Test escaping of special characters in the iteration values of a .for loop.
 # These values get expanded later using the :U variable modifier, and this
@@ -74,11 +74,11 @@ VALUES=             $${UNDEF:U\$$\$$ {{}} end}
 # When these words are injected into the body of the .for loop, each inside a
 # '${:U...}' expression, the result is:
 #
-# expect: For: loop body:
+# expect: For: loop body with i = ${UNDEF:U\$\$:
 # expect: # ${:U\${UNDEF\:U\\$\\$}
-# expect: For: loop body:
+# expect: For: loop body with i = {{}}:
 # expect: # ${:U{{\}\}}
-# expect: For: loop body:
+# expect: For: loop body with i = end}:
 # expect: # ${:Uend\}}
 # expect: For: end for 1
 #
diff -r 3257d20adf34 -r fca1bcb9a0b4 usr.bin/make/unit-tests/directive-for.exp
--- a/usr.bin/make/unit-tests/directive-for.exp Thu Jun 01 08:20:10 2023 +0000
+++ b/usr.bin/make/unit-tests/directive-for.exp Thu Jun 01 09:02:14 2023 +0000
@@ -28,13 +28,13 @@ make: "directive-for.mk" line 257: if-le
 For: new loop 2
 For: end for 2
 For: end for 1
-For: loop body:
+For: loop body with outer = o:
 .\
    for inner in i
 .\
    endfor
 For: end for 1
-For: loop body:
+For: loop body with inner = i:
 make: "directive-for.mk" line 305: newline-item=(a)
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
diff -r 3257d20adf34 -r fca1bcb9a0b4 usr.bin/make/unit-tests/opt-debug-for.exp
--- a/usr.bin/make/unit-tests/opt-debug-for.exp Thu Jun 01 08:20:10 2023 +0000
+++ b/usr.bin/make/unit-tests/opt-debug-for.exp Thu Jun 01 09:02:14 2023 +0000
@@ -1,22 +1,22 @@
 For: new loop 2
 For: end for 2
 For: end for 1
-For: loop body:
+For: loop body with outer = a:
 .  for inner in 1 2
 VAR.${:Ua}${inner}=    value
 .  endfor
 For: end for 1
-For: loop body:
+For: loop body with inner = 1:
 VAR.${:Ua}${:U1}=      value
-For: loop body:
+For: loop body with inner = 2:
 VAR.${:Ua}${:U2}=      value
-For: loop body:
+For: loop body with outer = b:
 .  for inner in 1 2
 VAR.${:Ub}${inner}=    value
 .  endfor
 For: end for 1
-For: loop body:
+For: loop body with inner = 1:
 VAR.${:Ub}${:U1}=      value
-For: loop body:
+For: loop body with inner = 2:
 VAR.${:Ub}${:U2}=      value
 exit status 0



Home | Main Index | Thread Index | Old Index