diff options
| author | rillig <rillig@NetBSD.org> | 2023-06-01 09:02:14 +0000 |
|---|---|---|
| committer | rillig <rillig@NetBSD.org> | 2023-06-01 09:02:14 +0000 |
| commit | 0d23c8c7ea8517bddf560192a82443c92741b84b (patch) | |
| tree | d9e5a632fd82bba674610c8c929b3d12c0adb011 /usr.bin/make | |
| parent | 0632fad62882d4e7c08faa9800260bfbe40126ce (diff) | |
make: add more details to debug logging of .for loops
Diffstat (limited to 'usr.bin/make')
| -rw-r--r-- | usr.bin/make/for.c | 11 | ||||
| -rw-r--r-- | usr.bin/make/unit-tests/directive-for-empty.exp | 2 | ||||
| -rw-r--r-- | usr.bin/make/unit-tests/directive-for-escape.exp | 75 | ||||
| -rw-r--r-- | usr.bin/make/unit-tests/directive-for-escape.mk | 8 | ||||
| -rw-r--r-- | usr.bin/make/unit-tests/directive-for.exp | 4 | ||||
| -rw-r--r-- | usr.bin/make/unit-tests/opt-debug-for.exp | 12 |
6 files changed, 60 insertions, 52 deletions
diff --git a/usr.bin/make/for.c b/usr.bin/make/for.c index e211c22fab7..38fd1c44720 100644 --- a/usr.bin/make/for.c +++ b/usr.bin/make/for.c @@ -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 *body) 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 --git a/usr.bin/make/unit-tests/directive-for-empty.exp b/usr.bin/make/unit-tests/directive-for-empty.exp index b9764b3196a..b20a3d3e9a1 100644 --- a/usr.bin/make/unit-tests/directive-for-empty.exp +++ b/usr.bin/make/unit-tests/directive-for-empty.exp @@ -3,7 +3,7 @@ make: "directive-for-empty.mk" line 34: Missing argument for ".error" 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 --git a/usr.bin/make/unit-tests/directive-for-escape.exp b/usr.bin/make/unit-tests/directive-for-escape.exp index 0326b62377f..e12c7226906 100644 --- a/usr.bin/make/unit-tests/directive-for-escape.exp +++ b/usr.bin/make/unit-tests/directive-for-escape.exp @@ -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: eight and no cents. 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-dir> ${.PARSEFILE} = `directive-for-escape 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 --git a/usr.bin/make/unit-tests/directive-for-escape.mk b/usr.bin/make/unit-tests/directive-for-escape.mk index 7fbd09131d2..5bb676eb1ea 100644 --- a/usr.bin/make/unit-tests/directive-for-escape.mk +++ b/usr.bin/make/unit-tests/directive-for-escape.mk @@ -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 --git a/usr.bin/make/unit-tests/directive-for.exp b/usr.bin/make/unit-tests/directive-for.exp index 97878ee49f4..e3184ebe7b8 100644 --- a/usr.bin/make/unit-tests/directive-for.exp +++ b/usr.bin/make/unit-tests/directive-for.exp @@ -28,13 +28,13 @@ make: "directive-for.mk" line 257: if-less endif 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 --git a/usr.bin/make/unit-tests/opt-debug-for.exp b/usr.bin/make/unit-tests/opt-debug-for.exp index ea811b9bfcf..a8f63b85fec 100644 --- a/usr.bin/make/unit-tests/opt-debug-for.exp +++ b/usr.bin/make/unit-tests/opt-debug-for.exp @@ -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 |
