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): add debug logging for Var_Parse



details:   https://anonhg.NetBSD.org/src/rev/084b6c849839
branches:  trunk
changeset: 1012718:084b6c849839
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Aug 08 18:50:11 2020 +0000

description:
make(1): add debug logging for Var_Parse

This will hopefully help with tracking down why the "Undefined variable"
error message is not triggered.

There is some other non-obvious behavior nearby.  In Parse_DoVar, the !=
assignment operator evaluates the variable using VARE_UNDEFERR, but
there is not even a warning for the following line:

!= echo err ${UNDEFINED} 1>&2

diffstat:

 usr.bin/make/unit-tests/counter.exp  |  23 +++++++++++++++++++++++
 usr.bin/make/unit-tests/vardebug.exp |  12 ++++++++++++
 usr.bin/make/var.c                   |  11 ++++++++---
 3 files changed, 43 insertions(+), 3 deletions(-)

diffs (204 lines):

diff -r fa018b78d624 -r 084b6c849839 usr.bin/make/unit-tests/counter.exp
--- a/usr.bin/make/unit-tests/counter.exp       Sat Aug 08 17:03:04 2020 +0000
+++ b/usr.bin/make/unit-tests/counter.exp       Sat Aug 08 18:50:11 2020 +0000
@@ -2,28 +2,43 @@
 Global:COUNTER = 
 Global:NEXT = ${COUNTER::=${COUNTER} a}${COUNTER:[#]}
 Global:A = 
+Var_Parse: ${NEXT} with VARE_WANTRES|VARE_ASSIGN
+Var_Parse: ${COUNTER::=${COUNTER} a}${COUNTER:[#]} with VARE_WANTRES|VARE_ASSIGN
 Applying ${COUNTER::...} to "" (eflags = VARE_WANTRES|VARE_ASSIGN, vflags = none)
+Var_Parse: ${COUNTER} a}${COUNTER:[#]} with VARE_WANTRES
 Modifier part: " a"
 Global:COUNTER =  a
 Result of ${COUNTER::=${COUNTER} a} is "" (eflags = VARE_WANTRES|VARE_ASSIGN, vflags = none)
+Var_Parse: ${COUNTER} a}${COUNTER:[#]} with VARE_WANTRES|VARE_ASSIGN
+Var_Parse: ${COUNTER:[#]} with VARE_WANTRES|VARE_ASSIGN
 Applying ${COUNTER:[...} to " a" (eflags = VARE_WANTRES|VARE_ASSIGN, vflags = none)
 Modifier part: "#"
 Result of ${COUNTER:[#]} is "1" (eflags = VARE_WANTRES|VARE_ASSIGN, vflags = none)
 Global:A = ${COUNTER::= a a}1
 Global:B = 
+Var_Parse: ${NEXT} with VARE_WANTRES|VARE_ASSIGN
+Var_Parse: ${COUNTER::=${COUNTER} a}${COUNTER:[#]} with VARE_WANTRES|VARE_ASSIGN
 Applying ${COUNTER::...} to " a" (eflags = VARE_WANTRES|VARE_ASSIGN, vflags = none)
+Var_Parse: ${COUNTER} a}${COUNTER:[#]} with VARE_WANTRES
 Modifier part: " a a"
 Global:COUNTER =  a a
 Result of ${COUNTER::=${COUNTER} a} is "" (eflags = VARE_WANTRES|VARE_ASSIGN, vflags = none)
+Var_Parse: ${COUNTER} a}${COUNTER:[#]} with VARE_WANTRES|VARE_ASSIGN
+Var_Parse: ${COUNTER:[#]} with VARE_WANTRES|VARE_ASSIGN
 Applying ${COUNTER:[...} to " a a" (eflags = VARE_WANTRES|VARE_ASSIGN, vflags = none)
 Modifier part: "#"
 Result of ${COUNTER:[#]} is "2" (eflags = VARE_WANTRES|VARE_ASSIGN, vflags = none)
 Global:B = ${COUNTER::= a a a}2
 Global:C = 
+Var_Parse: ${NEXT} with VARE_WANTRES|VARE_ASSIGN
+Var_Parse: ${COUNTER::=${COUNTER} a}${COUNTER:[#]} with VARE_WANTRES|VARE_ASSIGN
 Applying ${COUNTER::...} to " a a" (eflags = VARE_WANTRES|VARE_ASSIGN, vflags = none)
+Var_Parse: ${COUNTER} a}${COUNTER:[#]} with VARE_WANTRES
 Modifier part: " a a a"
 Global:COUNTER =  a a a
 Result of ${COUNTER::=${COUNTER} a} is "" (eflags = VARE_WANTRES|VARE_ASSIGN, vflags = none)
+Var_Parse: ${COUNTER} a}${COUNTER:[#]} with VARE_WANTRES|VARE_ASSIGN
+Var_Parse: ${COUNTER:[#]} with VARE_WANTRES|VARE_ASSIGN
 Applying ${COUNTER:[...} to " a a a" (eflags = VARE_WANTRES|VARE_ASSIGN, vflags = none)
 Modifier part: "#"
 Result of ${COUNTER:[#]} is "3" (eflags = VARE_WANTRES|VARE_ASSIGN, vflags = none)
@@ -31,6 +46,8 @@
 Global:RELEVANT = no
 Global:RELEVANT = yes (run-time part)
 Result of ${RELEVANT::=yes (run-time part)} is "" (eflags = VARE_WANTRES, vflags = none)
+Var_Parse: ${A:Q} B=${B:Q} C=${C:Q} COUNTER=${COUNTER:[#]:Q} with VARE_WANTRES
+Var_Parse: ${COUNTER::= a a}1 with VARE_WANTRES
 Applying ${COUNTER::...} to " a a a" (eflags = VARE_WANTRES, vflags = none)
 Modifier part: " a a"
 Global:COUNTER =  a a
@@ -38,6 +55,8 @@
 Applying ${A:Q} to "1" (eflags = VARE_WANTRES, vflags = none)
 QuoteMeta: [1]
 Result of ${A:Q} is "1" (eflags = VARE_WANTRES, vflags = none)
+Var_Parse: ${B:Q} C=${C:Q} COUNTER=${COUNTER:[#]:Q} with VARE_WANTRES
+Var_Parse: ${COUNTER::= a a a}2 with VARE_WANTRES
 Applying ${COUNTER::...} to " a a" (eflags = VARE_WANTRES, vflags = none)
 Modifier part: " a a a"
 Global:COUNTER =  a a a
@@ -45,6 +64,8 @@
 Applying ${B:Q} to "2" (eflags = VARE_WANTRES, vflags = none)
 QuoteMeta: [2]
 Result of ${B:Q} is "2" (eflags = VARE_WANTRES, vflags = none)
+Var_Parse: ${C:Q} COUNTER=${COUNTER:[#]:Q} with VARE_WANTRES
+Var_Parse: ${COUNTER::= a a a a}3 with VARE_WANTRES
 Applying ${COUNTER::...} to " a a a" (eflags = VARE_WANTRES, vflags = none)
 Modifier part: " a a a a"
 Global:COUNTER =  a a a a
@@ -52,6 +73,7 @@
 Applying ${C:Q} to "3" (eflags = VARE_WANTRES, vflags = none)
 QuoteMeta: [3]
 Result of ${C:Q} is "3" (eflags = VARE_WANTRES, vflags = none)
+Var_Parse: ${COUNTER:[#]:Q} with VARE_WANTRES
 Applying ${COUNTER:[...} to " a a a a" (eflags = VARE_WANTRES, vflags = none)
 Modifier part: "#"
 Result of ${COUNTER:[#]} is "4" (eflags = VARE_WANTRES, vflags = none)
@@ -59,6 +81,7 @@
 QuoteMeta: [4]
 Result of ${COUNTER:Q} is "4" (eflags = VARE_WANTRES, vflags = none)
 A=1 B=2 C=3 COUNTER=4
+Var_Parse: ${RELEVANT::=no} with VARE_WANTRES
 Applying ${RELEVANT::...} to "yes (run-time part)" (eflags = VARE_WANTRES, vflags = none)
 Modifier part: "no"
 Global:RELEVANT = no
diff -r fa018b78d624 -r 084b6c849839 usr.bin/make/unit-tests/vardebug.exp
--- a/usr.bin/make/unit-tests/vardebug.exp      Sat Aug 08 17:03:04 2020 +0000
+++ b/usr.bin/make/unit-tests/vardebug.exp      Sat Aug 08 18:50:11 2020 +0000
@@ -3,9 +3,11 @@
 Global:VAR = overwritten
 Global:delete VAR
 Global:delete VAR (not found)
+Var_Parse: ${:U} with VARE_WANTRES
 Applying ${:U} to "" (eflags = VARE_WANTRES, vflags = VAR_JUNK)
 Result of ${:U} is "" (eflags = VARE_WANTRES, vflags = VAR_JUNK|VAR_KEEP)
 Var_Set("${:U}", "empty name", ...) name expands to empty string - ignored
+Var_Parse: ${:U} with VARE_WANTRES
 Applying ${:U} to "" (eflags = VARE_WANTRES, vflags = VAR_JUNK)
 Result of ${:U} is "" (eflags = VARE_WANTRES, vflags = VAR_JUNK|VAR_KEEP)
 Var_Append("${:U}", "empty name", ...) name expands to empty string - ignored
@@ -13,6 +15,7 @@
 Global:VAR = 1
 Global:VAR = 1 2
 Global:VAR = 1 2 3
+Var_Parse: ${VAR:M[2]} with VARE_UNDEFERR|VARE_WANTRES
 Applying ${VAR:M...} to "1 2 3" (eflags = VARE_UNDEFERR|VARE_WANTRES, vflags = none)
 Pattern[VAR] for [1 2 3] is [[2]]
 ModifyWords: split "1 2 3" into 3 words
@@ -20,18 +23,22 @@
 VarMatch [2] [[2]]
 VarMatch [3] [[2]]
 Result of ${VAR:M[2]} is "2" (eflags = VARE_UNDEFERR|VARE_WANTRES, vflags = none)
+Var_Parse: ${VAR:N[2]} with VARE_UNDEFERR|VARE_WANTRES
 Applying ${VAR:N...} to "1 2 3" (eflags = VARE_UNDEFERR|VARE_WANTRES, vflags = none)
 Pattern[VAR] for [1 2 3] is [[2]]
 ModifyWords: split "1 2 3" into 3 words
 Result of ${VAR:N[2]} is "1 3" (eflags = VARE_UNDEFERR|VARE_WANTRES, vflags = none)
+Var_Parse: ${VAR:S,2,two,} with VARE_UNDEFERR|VARE_WANTRES
 Applying ${VAR:S...} to "1 2 3" (eflags = VARE_UNDEFERR|VARE_WANTRES, vflags = none)
 Modifier part: "2"
 Modifier part: "two"
 ModifyWords: split "1 2 3" into 3 words
 Result of ${VAR:S,2,two,} is "1 two 3" (eflags = VARE_UNDEFERR|VARE_WANTRES, vflags = none)
+Var_Parse: ${VAR:Q} with VARE_UNDEFERR|VARE_WANTRES
 Applying ${VAR:Q} to "1 2 3" (eflags = VARE_UNDEFERR|VARE_WANTRES, vflags = none)
 QuoteMeta: [1\ 2\ 3]
 Result of ${VAR:Q} is "1\ 2\ 3" (eflags = VARE_UNDEFERR|VARE_WANTRES, vflags = none)
+Var_Parse: ${VAR:tu:tl:Q} with VARE_UNDEFERR|VARE_WANTRES
 Applying ${VAR:t...} to "1 2 3" (eflags = VARE_UNDEFERR|VARE_WANTRES, vflags = none)
 Result of ${VAR:tu} is "1 2 3" (eflags = VARE_UNDEFERR|VARE_WANTRES, vflags = none)
 Applying ${VAR:t...} to "1 2 3" (eflags = VARE_UNDEFERR|VARE_WANTRES, vflags = none)
@@ -39,8 +46,10 @@
 Applying ${VAR:Q} to "1 2 3" (eflags = VARE_UNDEFERR|VARE_WANTRES, vflags = none)
 QuoteMeta: [1\ 2\ 3]
 Result of ${VAR:Q} is "1\ 2\ 3" (eflags = VARE_UNDEFERR|VARE_WANTRES, vflags = none)
+Var_Parse: ${:Uvalue:${:UM*e}:Mvalu[e]} with VARE_UNDEFERR|VARE_WANTRES
 Applying ${:U...} to "" (eflags = VARE_UNDEFERR|VARE_WANTRES, vflags = VAR_JUNK)
 Result of ${:Uvalue} is "value" (eflags = VARE_UNDEFERR|VARE_WANTRES, vflags = VAR_JUNK|VAR_KEEP)
+Var_Parse: ${:UM*e}:Mvalu[e]} with VARE_UNDEFERR|VARE_WANTRES
 Applying ${:U...} to "" (eflags = VARE_UNDEFERR|VARE_WANTRES, vflags = VAR_JUNK)
 Result of ${:UM*e} is "M*e" (eflags = VARE_UNDEFERR|VARE_WANTRES, vflags = VAR_JUNK|VAR_KEEP)
 Indirect modifier "M*e" from "${:UM*e}"
@@ -54,15 +63,18 @@
 ModifyWords: split "value" into 1 words
 VarMatch [value] [valu[e]]
 Result of ${:Mvalu[e]} is "value" (eflags = VARE_UNDEFERR|VARE_WANTRES, vflags = VAR_JUNK|VAR_KEEP)
+Var_Parse: ${:UVAR} with VARE_WANTRES
 Applying ${:U...} to "" (eflags = VARE_WANTRES, vflags = VAR_JUNK)
 Result of ${:UVAR} is "VAR" (eflags = VARE_WANTRES, vflags = VAR_JUNK|VAR_KEEP)
 Global:delete VAR
+Var_Parse: ${:Uvariable:unknown} with VARE_UNDEFERR|VARE_WANTRES
 Applying ${:U...} to "" (eflags = VARE_UNDEFERR|VARE_WANTRES, vflags = VAR_JUNK)
 Result of ${:Uvariable} is "variable" (eflags = VARE_UNDEFERR|VARE_WANTRES, vflags = VAR_JUNK|VAR_KEEP)
 Applying ${:u...} to "variable" (eflags = VARE_UNDEFERR|VARE_WANTRES, vflags = VAR_JUNK|VAR_KEEP)
 make: Unknown modifier 'u'
 Result of ${:unknown} is error (eflags = VARE_UNDEFERR|VARE_WANTRES, vflags = VAR_JUNK|VAR_KEEP)
 make: "vardebug.mk" line 44: Malformed conditional (${:Uvariable:unknown})
+Var_Parse: ${UNDEFINED} with VARE_UNDEFERR|VARE_WANTRES
 make: "vardebug.mk" line 53: Malformed conditional (${UNDEFINED})
 Global:RELEVANT = no
 exit status 1
diff -r fa018b78d624 -r 084b6c849839 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Sat Aug 08 17:03:04 2020 +0000
+++ b/usr.bin/make/var.c        Sat Aug 08 18:50:11 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.431 2020/08/08 14:28:46 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.432 2020/08/08 18:50:11 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.431 2020/08/08 14:28:46 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.432 2020/08/08 18:50:11 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c      8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.431 2020/08/08 14:28:46 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.432 2020/08/08 18:50:11 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -3347,6 +3347,11 @@
     const char *extramodifiers;
     Var *v;
     char *nstr;
+    char eflags_str[VarEvalFlags_ToStringSize];
+
+    VAR_DEBUG("%s: %s with %s\n", __func__, str,
+             Enum_ToString(eflags_str, sizeof eflags_str, eflags,
+                           VarEvalFlags_ToStringSpecs));
 
     *freePtr = NULL;
     extramodifiers = NULL;     /* extra modifiers to apply first */



Home | Main Index | Thread Index | Old Index