Module Name: src
Committed By: rillig
Date: Tue Feb 2 17:47:56 UTC 2021
Modified Files:
src/usr.bin/make: compat.c
src/usr.bin/make/unit-tests: opt-debug-graph2.exp opt-debug-graph2.mk
opt-debug-graph3.exp opt-debug-graph3.mk
Log Message:
make: when exiting due to an error, print graph information
The code now does what the manual page has been promising since at least
1993.
To generate a diff of this commit:
cvs rdiff -u -r1.221 -r1.222 src/usr.bin/make/compat.c
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/opt-debug-graph2.exp \
src/usr.bin/make/unit-tests/opt-debug-graph2.mk \
src/usr.bin/make/unit-tests/opt-debug-graph3.exp \
src/usr.bin/make/unit-tests/opt-debug-graph3.mk
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/compat.c
diff -u src/usr.bin/make/compat.c:1.221 src/usr.bin/make/compat.c:1.222
--- src/usr.bin/make/compat.c:1.221 Mon Feb 1 21:04:10 2021
+++ src/usr.bin/make/compat.c Tue Feb 2 17:47:56 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: compat.c,v 1.221 2021/02/01 21:04:10 rillig Exp $ */
+/* $NetBSD: compat.c,v 1.222 2021/02/02 17:47:56 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -96,7 +96,7 @@
#include "pathnames.h"
/* "@(#)compat.c 8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: compat.c,v 1.221 2021/02/01 21:04:10 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.222 2021/02/02 17:47:56 rillig Exp $");
static GNode *curTarg = NULL;
static pid_t compatChild;
@@ -749,6 +749,10 @@ Compat_Run(GNodeList *targs)
}
if (errorNode != NULL) {
+ if (DEBUG(GRAPH2))
+ Targ_PrintGraph(2);
+ else if (DEBUG(GRAPH3))
+ Targ_PrintGraph(3);
PrintOnError(errorNode, "\nStop.");
exit(1);
}
Index: src/usr.bin/make/unit-tests/opt-debug-graph2.exp
diff -u src/usr.bin/make/unit-tests/opt-debug-graph2.exp:1.2 src/usr.bin/make/unit-tests/opt-debug-graph2.exp:1.3
--- src/usr.bin/make/unit-tests/opt-debug-graph2.exp:1.2 Tue Feb 2 17:27:35 2021
+++ src/usr.bin/make/unit-tests/opt-debug-graph2.exp Tue Feb 2 17:47:56 2021
@@ -4,6 +4,89 @@ false
false
*** Error code 1 (continuing)
`all' not remade because of errors.
+#*** Input graph:
+# made-target, made MADE, type OP_DEPENDS|OP_PHONY|OP_HAS_COMMANDS|OP_DEPS_FOUND|OP_MARK, flags REMAKE|DONE_ALLSRC
+#
+# *** MAIN TARGET ***
+# No unmade children
+# last modified <timestamp>: made
+# parents: all
+made-target :
+ (null)
+
+
+# error-target, made ERROR, type OP_DEPENDS|OP_PHONY|OP_HAS_COMMANDS|OP_DEPS_FOUND|OP_MARK, flags REMAKE|DONE_ALLSRC
+#
+# No unmade children
+# nonexistent (maybe): error when made
+# parents: all
+error-target :
+ (null)
+
+
+# aborted-target, made ABORTED, type OP_DEPENDS|OP_PHONY|OP_DEPS_FOUND|OP_MARK, flags none
+# aborted-target-dependency, made ERROR, type OP_DEPENDS|OP_PHONY|OP_HAS_COMMANDS|OP_DEPS_FOUND|OP_MARK, flags REMAKE|DONE_ALLSRC
+#
+# No unmade children
+# nonexistent (maybe): error when made
+# parents: aborted-target
+aborted-target-dependency:
+ (null)
+
+
+# all, made ABORTED, type OP_DEPENDS|OP_DEPS_FOUND, flags CHILDMADE|FORCE
+#
+# 3 unmade children
+# nonexistent (maybe): aborted
+all : made-target error-target aborted-target
+
+
+# .END, made UNMADE, type OP_SPECIAL, flags none
+
+
+#
+# Files that are only sources:
+# .END [.END]
+#*** Global Variables:
+.ALLTARGETS = made-target error-target aborted-target aborted-target-dependency all .END
+.CURDIR = <curdir>
+.INCLUDES =
+.LIBS =
+.MAKE = <details omitted>
+.MAKE.DEPENDFILE = <details omitted>
+.MAKE.GID = <details omitted>
+.MAKE.LEVEL = <details omitted>
+.MAKE.MAKEFILES = <details omitted>
+.MAKE.MAKEFILE_PREFERENCE = <details omitted>
+.MAKE.OS = <details omitted>
+.MAKE.PATH_FILEMON = <details omitted>
+.MAKE.PID = <details omitted>
+.MAKE.PPID = <details omitted>
+.MAKE.UID = <details omitted>
+.MAKEFLAGS = -r -k -d g2
+.MAKEOVERRIDES =
+.OBJDIR = <curdir>
+.PATH = . <curdir>
+.TARGETS = all
+.newline =
+
+MACHINE = <details omitted>
+MACHINE_ARCH = <details omitted>
+MAKE = <details omitted>
+MFLAGS = -r -k -d g2
+#*** Command-line Variables:
+.MAKE.LEVEL.ENV = MAKELEVEL
+.SHELL = <details omitted>
+
+#*** Directory Cache:
+# Stats: 0 hits 4 misses 0 near misses 0 losers (0%)
+# refs hits directory
+# 1 0 <curdir>
+# 1 0 .
+# 1 0 <defsyspath>
+
+#*** Suffixes:
+#*** Transformations:
Stop.
make: stopped in unit-tests
Index: src/usr.bin/make/unit-tests/opt-debug-graph2.mk
diff -u src/usr.bin/make/unit-tests/opt-debug-graph2.mk:1.2 src/usr.bin/make/unit-tests/opt-debug-graph2.mk:1.3
--- src/usr.bin/make/unit-tests/opt-debug-graph2.mk:1.2 Tue Feb 2 17:27:35 2021
+++ src/usr.bin/make/unit-tests/opt-debug-graph2.mk Tue Feb 2 17:47:56 2021
@@ -1,9 +1,9 @@
-# $NetBSD: opt-debug-graph2.mk,v 1.2 2021/02/02 17:27:35 rillig Exp $
+# $NetBSD: opt-debug-graph2.mk,v 1.3 2021/02/02 17:47:56 rillig Exp $
#
# Tests for the -dg2 command line option, which prints the input
# graph after making everything, or before exiting on error.
#
-# FIXME: The documentation is wrong. There is no debug output despite
+# Before compat.c 1.222 from 2021-02-02, there was no debug output despite
# the error.
.MAKEFLAGS: -dg2
Index: src/usr.bin/make/unit-tests/opt-debug-graph3.exp
diff -u src/usr.bin/make/unit-tests/opt-debug-graph3.exp:1.2 src/usr.bin/make/unit-tests/opt-debug-graph3.exp:1.3
--- src/usr.bin/make/unit-tests/opt-debug-graph3.exp:1.2 Tue Feb 2 17:27:35 2021
+++ src/usr.bin/make/unit-tests/opt-debug-graph3.exp Tue Feb 2 17:47:56 2021
@@ -4,6 +4,89 @@ false
false
*** Error code 1 (continuing)
`all' not remade because of errors.
+#*** Input graph:
+# made-target, made MADE, type OP_DEPENDS|OP_PHONY|OP_HAS_COMMANDS|OP_DEPS_FOUND|OP_MARK, flags REMAKE|DONE_ALLSRC
+#
+# *** MAIN TARGET ***
+# No unmade children
+# last modified <timestamp>: made
+# parents: all
+made-target :
+ (null)
+
+
+# error-target, made ERROR, type OP_DEPENDS|OP_PHONY|OP_HAS_COMMANDS|OP_DEPS_FOUND|OP_MARK, flags REMAKE|DONE_ALLSRC
+#
+# No unmade children
+# nonexistent (maybe): error when made
+# parents: all
+error-target :
+ (null)
+
+
+# aborted-target, made ABORTED, type OP_DEPENDS|OP_PHONY|OP_DEPS_FOUND|OP_MARK, flags none
+# aborted-target-dependency, made ERROR, type OP_DEPENDS|OP_PHONY|OP_HAS_COMMANDS|OP_DEPS_FOUND|OP_MARK, flags REMAKE|DONE_ALLSRC
+#
+# No unmade children
+# nonexistent (maybe): error when made
+# parents: aborted-target
+aborted-target-dependency:
+ (null)
+
+
+# all, made ABORTED, type OP_DEPENDS|OP_DEPS_FOUND, flags CHILDMADE|FORCE
+#
+# 3 unmade children
+# nonexistent (maybe): aborted
+all : made-target error-target aborted-target
+
+
+# .END, made UNMADE, type OP_SPECIAL, flags none
+
+
+#
+# Files that are only sources:
+# .END [.END]
+#*** Global Variables:
+.ALLTARGETS = made-target error-target aborted-target aborted-target-dependency all .END
+.CURDIR = <curdir>
+.INCLUDES =
+.LIBS =
+.MAKE = <details omitted>
+.MAKE.DEPENDFILE = <details omitted>
+.MAKE.GID = <details omitted>
+.MAKE.LEVEL = <details omitted>
+.MAKE.MAKEFILES = <details omitted>
+.MAKE.MAKEFILE_PREFERENCE = <details omitted>
+.MAKE.OS = <details omitted>
+.MAKE.PATH_FILEMON = <details omitted>
+.MAKE.PID = <details omitted>
+.MAKE.PPID = <details omitted>
+.MAKE.UID = <details omitted>
+.MAKEFLAGS = -r -k -d g3
+.MAKEOVERRIDES =
+.OBJDIR = <curdir>
+.PATH = . <curdir>
+.TARGETS = all
+.newline =
+
+MACHINE = <details omitted>
+MACHINE_ARCH = <details omitted>
+MAKE = <details omitted>
+MFLAGS = -r -k -d g3
+#*** Command-line Variables:
+.MAKE.LEVEL.ENV = MAKELEVEL
+.SHELL = <details omitted>
+
+#*** Directory Cache:
+# Stats: 0 hits 4 misses 0 near misses 0 losers (0%)
+# refs hits directory
+# 1 0 <curdir>
+# 1 0 .
+# 1 0 <defsyspath>
+
+#*** Suffixes:
+#*** Transformations:
Stop.
make: stopped in unit-tests
Index: src/usr.bin/make/unit-tests/opt-debug-graph3.mk
diff -u src/usr.bin/make/unit-tests/opt-debug-graph3.mk:1.2 src/usr.bin/make/unit-tests/opt-debug-graph3.mk:1.3
--- src/usr.bin/make/unit-tests/opt-debug-graph3.mk:1.2 Tue Feb 2 17:27:35 2021
+++ src/usr.bin/make/unit-tests/opt-debug-graph3.mk Tue Feb 2 17:47:56 2021
@@ -1,9 +1,9 @@
-# $NetBSD: opt-debug-graph3.mk,v 1.2 2021/02/02 17:27:35 rillig Exp $
+# $NetBSD: opt-debug-graph3.mk,v 1.3 2021/02/02 17:47:56 rillig Exp $
#
# Tests for the -dg3 command line option, which prints the input
# graph before exiting on error.
#
-# FIXME: The documentation is wrong. There is no debug output despite
+# Before compat.c 1.222 from 2021-02-02, there was no debug output despite
# the error.
.MAKEFLAGS: -dg3