Module Name:    src
Committed By:   rillig
Date:           Sun Nov 22 21:34:34 UTC 2020

Modified Files:
        src/usr.bin/make: make.h suff.c
        src/usr.bin/make/unit-tests: suff-incomplete.exp suff-lookup.exp
            suff-rebuild.exp

Log Message:
make(1): add more debugging for searching transformation rules


To generate a diff of this commit:
cvs rdiff -u -r1.213 -r1.214 src/usr.bin/make/make.h
cvs rdiff -u -r1.300 -r1.301 src/usr.bin/make/suff.c
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/suff-incomplete.exp
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/suff-lookup.exp \
    src/usr.bin/make/unit-tests/suff-rebuild.exp

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/make.h
diff -u src/usr.bin/make/make.h:1.213 src/usr.bin/make/make.h:1.214
--- src/usr.bin/make/make.h:1.213	Sun Nov 22 10:48:11 2020
+++ src/usr.bin/make/make.h	Sun Nov 22 21:34:34 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.h,v 1.213 2020/11/22 10:48:11 rillig Exp $	*/
+/*	$NetBSD: make.h,v 1.214 2020/11/22 21:34:34 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -279,7 +279,8 @@ typedef enum GNodeType {
      * this node will be saved on the .END node instead, to be executed at
      * the very end. */
     OP_SAVE_CMDS	= 1 << 25,
-    /* Already processed by Suff_FindDeps */
+    /* Already processed by Suff_FindDeps, to find dependencies from suffix
+     * transformation rules. */
     OP_DEPS_FOUND	= 1 << 24,
     /* Node found while expanding .ALLSRC */
     OP_MARK		= 1 << 23,

Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.300 src/usr.bin/make/suff.c:1.301
--- src/usr.bin/make/suff.c:1.300	Sun Nov 22 20:29:53 2020
+++ src/usr.bin/make/suff.c	Sun Nov 22 21:34:34 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.300 2020/11/22 20:29:53 rillig Exp $	*/
+/*	$NetBSD: suff.c,v 1.301 2020/11/22 21:34:34 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -114,7 +114,7 @@
 #include "dir.h"
 
 /*	"@(#)suff.c	8.4 (Berkeley) 3/21/94"	*/
-MAKE_RCSID("$NetBSD: suff.c,v 1.300 2020/11/22 20:29:53 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.301 2020/11/22 21:34:34 rillig Exp $");
 
 #define SUFF_DEBUG0(text) DEBUG0(SUFF, text)
 #define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1)
@@ -893,8 +893,10 @@ CandidateList_PrintAddrs(CandidateList *
 {
     CandidateListNode *ln;
 
-    for (ln = list->first; ln != NULL; ln = ln->next)
-	debug_printf(" %p", ln->datum);
+    for (ln = list->first; ln != NULL; ln = ln->next) {
+	Candidate *cand = ln->datum;
+	debug_printf(" %p:%s", cand, cand->file);
+    }
     debug_printf("\n");
 }
 #endif
@@ -929,8 +931,8 @@ CandidateList_Add(CandidateList *list, c
 
 #ifdef DEBUG_SRC
     Lst_Append(targ->childrenList, cand);
-    debug_printf("%s add suff %p candidate %p to list %p:",
-		 debug_tag, targ, cand, list);
+    debug_printf("%s add suff %p:%s candidate %p:%s to list %p:",
+		 debug_tag, targ, targ->file, cand, cand->file, list);
     CandidateList_PrintAddrs(list);
 #endif
 }
@@ -988,8 +990,8 @@ RemoveCandidate(CandidateList *srcs)
 		src->parent->numChildren--;
 	    }
 #ifdef DEBUG_SRC
-	    debug_printf("free: list %p src %p children %d\n",
-			 srcs, src, src->numChildren);
+	    debug_printf("free: list %p src %p:%s children %d\n",
+			 srcs, src, src->file, src->numChildren);
 	    Lst_Free(src->childrenList);
 #endif
 	    Lst_Remove(srcs, ln);
@@ -998,8 +1000,8 @@ RemoveCandidate(CandidateList *srcs)
 	}
 #ifdef DEBUG_SRC
 	else {
-	    debug_printf("keep: list %p src %p children %d:",
-			 srcs, src, src->numChildren);
+	    debug_printf("keep: list %p src %p:%s children %d:",
+			 srcs, src, src->file, src->numChildren);
 	    CandidateList_PrintAddrs(src->childrenList);
 	}
 #endif
@@ -1026,7 +1028,8 @@ FindThem(CandidateList *srcs, CandidateL
 	 */
 	if (Targ_FindNode(src->file) != NULL) {
 #ifdef DEBUG_SRC
-	    debug_printf("remove from list %p src %p\n", srcs, src);
+	    debug_printf("remove from list %p src %p:%s\n",
+			 srcs, src, src->file);
 #endif
 	    retsrc = src;
 	    break;
@@ -1037,7 +1040,8 @@ FindThem(CandidateList *srcs, CandidateL
 	    if (file != NULL) {
 		retsrc = src;
 #ifdef DEBUG_SRC
-		debug_printf("remove from list %p src %p\n", srcs, src);
+		debug_printf("remove from list %p src %p:%s\n",
+			     srcs, src, src->file);
 #endif
 		free(file);
 		break;
@@ -1119,7 +1123,8 @@ FindCmds(Candidate *targ, CandidateList 
     ret = Candidate_New(bmake_strdup(sgn->name), targ->prefix, suff, targ, sgn);
     targ->numChildren++;
 #ifdef DEBUG_SRC
-    debug_printf("3 add targ %p ret %p\n", targ, ret);
+    debug_printf("3 add targ %p:%s ret %p:%s\n",
+		 targ, targ->file, ret, ret->file);
     Lst_Append(targ->childrenList, ret);
 #endif
     Lst_Append(slst, ret);
@@ -1741,6 +1746,10 @@ FindDepsRegular(GNode *gn, CandidateList
     const char *name = gn->name;
     size_t nameLen = strlen(name);
 
+#ifdef DEBUG_SRC
+    DEBUG1(SUFF, "FindDepsRegular \"%s\"\n", gn->name);
+#endif
+
     /*
      * Begin at the beginning...
      */
@@ -1918,9 +1927,9 @@ sfnd_return:
 
 /* Find implicit sources for the target.
  *
- * Nodes are added to the graph below the passed-in node. The nodes are
- * marked to have their IMPSRC variable filled in. The PREFIX variable is set
- * for the given node and all its implied children.
+ * Nodes are added to the graph as children of the passed-in node. The nodes
+ * are marked to have their IMPSRC variable filled in. The PREFIX variable
+ * is set for the given node and all its implied children.
  *
  * The path found by this target is the shortest path in the transformation
  * graph, which may pass through non-existent targets, to an existing target.
@@ -1957,7 +1966,7 @@ FindDeps(GNode *gn, CandidateList *slst)
     Var_Set(TARGET, GNode_Path(gn), gn);
     Var_Set(PREFIX, gn->name, gn);
 
-    SUFF_DEBUG1("SuffFindDeps (%s)\n", gn->name);
+    SUFF_DEBUG1("SuffFindDeps \"%s\"\n", gn->name);
 
     if (gn->type & OP_ARCHV)
 	FindDepsArchive(gn, slst);

Index: src/usr.bin/make/unit-tests/suff-incomplete.exp
diff -u src/usr.bin/make/unit-tests/suff-incomplete.exp:1.2 src/usr.bin/make/unit-tests/suff-incomplete.exp:1.3
--- src/usr.bin/make/unit-tests/suff-incomplete.exp:1.2	Sat Nov 21 10:36:01 2020
+++ src/usr.bin/make/unit-tests/suff-incomplete.exp	Sun Nov 22 21:34:34 2020
@@ -26,16 +26,16 @@ ParseDoDependency(.DEFAULT:)
 ParseReadLine (24): '	: Making ${.TARGET} from ${.IMPSRC} all ${.ALLSRC} by default.'
 transformation .DEFAULT complete
 Wildcard expanding "all"...
-SuffFindDeps (all)
+SuffFindDeps "all"
 	No known suffix on all. Using .NULL suffix
 adding suffix rules
 Wildcard expanding "suff-incomplete.c"...suffix is ".c"...
-SuffFindDeps (suff-incomplete.c)
+SuffFindDeps "suff-incomplete.c"
 	trying suff-incomplete.a...not there
 Wildcard expanding "suff-incomplete.c"...suffix is ".c"...
 : Making suff-incomplete.c from suff-incomplete.c all  by default.
 Wildcard expanding "all"...
-SuffFindDeps (.END)
+SuffFindDeps ".END"
 	No known suffix on .END. Using .NULL suffix
 adding suffix rules
 Wildcard expanding ".END"...

Index: src/usr.bin/make/unit-tests/suff-lookup.exp
diff -u src/usr.bin/make/unit-tests/suff-lookup.exp:1.5 src/usr.bin/make/unit-tests/suff-lookup.exp:1.6
--- src/usr.bin/make/unit-tests/suff-lookup.exp:1.5	Sat Nov 21 10:36:01 2020
+++ src/usr.bin/make/unit-tests/suff-lookup.exp	Sun Nov 22 21:34:34 2020
@@ -42,11 +42,11 @@ Adding suffix ".dead-end"
 inserting ".dead-end" (6) at end of list
 inserting ".short" (4) at end of list
 Wildcard expanding "all"...
-SuffFindDeps (all)
+SuffFindDeps "all"
 	No known suffix on all. Using .NULL suffix
 adding suffix rules
 Wildcard expanding "suff-lookup.cc"...suffix is ".cc"...
-SuffFindDeps (suff-lookup.cc)
+SuffFindDeps "suff-lookup.cc"
 	trying suff-lookup.ccc...not there
 	trying suff-lookup.c...not there
 	trying suff-lookup.short...not there
@@ -57,14 +57,14 @@ SuffFindDeps (suff-lookup.cc)
 suffix is ".ccc"...
 suffix is ".c"...
 suffix is ".sho"...
-SuffFindDeps (suff-lookup.sho)
+SuffFindDeps "suff-lookup.sho"
 suffix is ".sho"...
 : 'Making suff-lookup.sho out of nothing.'
 : 'Making suff-lookup.c from suff-lookup.sho.'
 : 'Making suff-lookup.ccc from suff-lookup.c.'
 : 'Making suff-lookup.cc from suff-lookup.ccc.'
 Wildcard expanding "all"...
-SuffFindDeps (.END)
+SuffFindDeps ".END"
 	No known suffix on .END. Using .NULL suffix
 adding suffix rules
 Wildcard expanding ".END"...
Index: src/usr.bin/make/unit-tests/suff-rebuild.exp
diff -u src/usr.bin/make/unit-tests/suff-rebuild.exp:1.5 src/usr.bin/make/unit-tests/suff-rebuild.exp:1.6
--- src/usr.bin/make/unit-tests/suff-rebuild.exp:1.5	Sat Nov 21 12:01:16 2020
+++ src/usr.bin/make/unit-tests/suff-rebuild.exp	Sun Nov 22 21:34:34 2020
@@ -35,14 +35,14 @@ transformation .c complete
 ParseDoDependency(.SUFFIXES: .c .b .a)
 Adding ".END" to all targets.
 Wildcard expanding "all"...
-SuffFindDeps (all)
+SuffFindDeps "all"
 	No known suffix on all. Using .NULL suffix
 adding suffix rules
 	trying all.c...not there
 	trying all.b...not there
 	trying all.a...not there
 Wildcard expanding "suff-rebuild-example"...
-SuffFindDeps (suff-rebuild-example)
+SuffFindDeps "suff-rebuild-example"
 	No known suffix on suff-rebuild-example. Using .NULL suffix
 adding suffix rules
 	trying suff-rebuild-example.c...not there
@@ -56,14 +56,14 @@ Adding "suff-rebuild-example.c" to all t
 suffix is ".c"...
 suffix is ".b"...
 suffix is ".a"...
-SuffFindDeps (suff-rebuild-example.a)
+SuffFindDeps "suff-rebuild-example.a"
 suffix is ".a"...
 : Making suff-rebuild-example.a out of nothing.
 : Making suff-rebuild-example.b from suff-rebuild-example.a.
 : Making suff-rebuild-example.c from suff-rebuild-example.b.
 : Making suff-rebuild-example from suff-rebuild-example.c.
 Wildcard expanding "all"...
-SuffFindDeps (.END)
+SuffFindDeps ".END"
 	No known suffix on .END. Using .NULL suffix
 adding suffix rules
 	trying .END.c...not there

Reply via email to