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): extend debug logging to error values



details:   https://anonhg.NetBSD.org/src/rev/27f437caaa11
branches:  trunk
changeset: 937074:27f437caaa11
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Aug 08 14:28:46 2020 +0000

description:
make(1): extend debug logging to error values

The error marker var_Error is just an empty string.  In the debug log
this empty string was not distinguishable from an otherwise empty
string.

Having this distinction helps in understanding the exact data flow.

diffstat:

 usr.bin/make/unit-tests/vardebug.exp |   9 ++++++++-
 usr.bin/make/unit-tests/vardebug.mk  |  16 +++++++++++++++-
 usr.bin/make/var.c                   |  14 ++++++++------
 3 files changed, 31 insertions(+), 8 deletions(-)

diffs (89 lines):

diff -r f45196a14467 -r 27f437caaa11 usr.bin/make/unit-tests/vardebug.exp
--- a/usr.bin/make/unit-tests/vardebug.exp      Sat Aug 08 13:50:23 2020 +0000
+++ b/usr.bin/make/unit-tests/vardebug.exp      Sat Aug 08 14:28:46 2020 +0000
@@ -57,5 +57,12 @@
 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
+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})
+make: "vardebug.mk" line 53: Malformed conditional (${UNDEFINED})
 Global:RELEVANT = no
-exit status 0
+exit status 1
diff -r f45196a14467 -r 27f437caaa11 usr.bin/make/unit-tests/vardebug.mk
--- a/usr.bin/make/unit-tests/vardebug.mk       Sat Aug 08 13:50:23 2020 +0000
+++ b/usr.bin/make/unit-tests/vardebug.mk       Sat Aug 08 14:28:46 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: vardebug.mk,v 1.2 2020/08/08 12:22:10 rillig Exp $
+# $NetBSD: vardebug.mk,v 1.3 2020/08/08 14:28:46 rillig Exp $
 #
 # Demonstrates the debugging output for var.c.
 
@@ -39,6 +39,20 @@
 
 .undef ${:UVAR}                        # Var_Delete
 
+# When ApplyModifiers results in an error, this appears in the debug log
+# as "is error", without surrounding quotes.
+.if ${:Uvariable:unknown}
+.endif
+
+# XXX: The error message is "Malformed conditional", which is wrong.
+# The condition is syntactically fine, it just contains an undefined variable.
+#
+# There is a specialized error message for "Undefined variable", but as of
+# 2020-08-08, that is not covered by any unit tests.  It might even be
+# unreachable.
+.if ${UNDEFINED}
+.endif
+
 RELEVANT=      no
 
 all:
diff -r f45196a14467 -r 27f437caaa11 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Sat Aug 08 13:50:23 2020 +0000
+++ b/usr.bin/make/var.c        Sat Aug 08 14:28:46 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.430 2020/08/08 13:50:23 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.431 2020/08/08 14:28:46 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.430 2020/08/08 13:50:23 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.431 2020/08/08 14:28:46 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.430 2020/08/08 13:50:23 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.431 2020/08/08 14:28:46 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -3212,10 +3212,12 @@
        if (DEBUG(VAR)) {
            char eflags_str[VarEvalFlags_ToStringSize];
            char vflags_str[VarFlags_ToStringSize];
-
-           VAR_DEBUG("Result of ${%s:%.*s} is \"%s\" "
+           const char *q = st.newVal == var_Error ? "" : "\"";
+           const char *newVal = st.newVal == var_Error ? "error" : st.newVal;
+
+           VAR_DEBUG("Result of ${%s:%.*s} is %s%s%s "
                      "(eflags = %s, vflags = %s)\n",
-                     st.v->name, (int)(p - mod), mod, st.newVal,
+                     st.v->name, (int)(p - mod), mod, q, newVal, q,
                      Enum_ToString(eflags_str, sizeof eflags_str, st.eflags,
                                    VarEvalFlags_ToStringSpecs),
                      Enum_ToString(vflags_str, sizeof vflags_str, st.v->flags,



Home | Main Index | Thread Index | Old Index