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): inline macros for debug logging



details:   https://anonhg.NetBSD.org/src/rev/b959b5a31f1f
branches:  trunk
changeset: 1016907:b959b5a31f1f
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Dec 06 10:49:02 2020 +0000

description:
make(1): inline macros for debug logging

No changes to the resulting binary, except for the line numbers in
assertions.

diffstat:

 usr.bin/make/dir.c  |  66 ++++++++++++++++++++++++----------------------------
 usr.bin/make/suff.c |  60 ++++++++++++++++++++++-------------------------
 usr.bin/make/targ.c |   6 ++--
 usr.bin/make/var.c  |  54 +++++++++++++++++++------------------------
 4 files changed, 86 insertions(+), 100 deletions(-)

diffs (truncated from 703 to 300 lines):

diff -r c99a69bdb694 -r b959b5a31f1f usr.bin/make/dir.c
--- a/usr.bin/make/dir.c        Sun Dec 06 10:33:42 2020 +0000
+++ b/usr.bin/make/dir.c        Sun Dec 06 10:49:02 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dir.c,v 1.249 2020/12/04 14:39:56 rillig Exp $ */
+/*     $NetBSD: dir.c,v 1.250 2020/12/06 10:49:02 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -136,11 +136,7 @@
 #include "job.h"
 
 /*     "@(#)dir.c      8.2 (Berkeley) 1/2/94"  */
-MAKE_RCSID("$NetBSD: dir.c,v 1.249 2020/12/04 14:39:56 rillig Exp $");
-
-#define DIR_DEBUG0(text) DEBUG0(DIR, text)
-#define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1)
-#define DIR_DEBUG2(fmt, arg1, arg2) DEBUG2(DIR, fmt, arg1, arg2)
+MAKE_RCSID("$NetBSD: dir.c,v 1.250 2020/12/06 10:49:02 rillig Exp $");
 
 /* A search path is a list of CachedDir structures. A CachedDir has in it the
  * name of the directory and the names of all the files in the directory.
@@ -369,12 +365,12 @@
 OpenDirs_Done(OpenDirs *odirs)
 {
        CachedDirListNode *ln = odirs->list.first;
-       DIR_DEBUG1("OpenDirs_Done: %u entries to remove\n",
+       DEBUG1(DIR, "OpenDirs_Done: %u entries to remove\n",
            odirs->table.numEntries);
        while (ln != NULL) {
                CachedDirListNode *next = ln->next;
                CachedDir *dir = ln->datum;
-               DIR_DEBUG2("OpenDirs_Done: refCount %d for \"%s\"\n",
+               DEBUG2(DIR, "OpenDirs_Done: refCount %d for \"%s\"\n",
                    dir->refCount, dir->name);
                CachedDir_Unref(dir);   /* removes the dir from odirs->list */
                ln = next;
@@ -429,8 +425,8 @@
        cst = HashTable_FindValue(tbl, pathname);
        if (cst != NULL && !(flags & CST_UPDATE)) {
                *out_cst = *cst;
-               DIR_DEBUG2("Using cached time %s for %s\n",
-                          Targ_FmtTime(cst->cst_mtime), pathname);
+               DEBUG2(DIR, "Using cached time %s for %s\n",
+                   Targ_FmtTime(cst->cst_mtime), pathname);
                return 0;
        }
 
@@ -450,8 +446,8 @@
        cst->cst_mode = sys_st.st_mode;
 
        *out_cst = *cst;
-       DIR_DEBUG2("   Caching %s for %s\n",
-                  Targ_FmtTime(sys_st.st_mtime), pathname);
+       DEBUG2(DIR, "   Caching %s for %s\n",
+           Targ_FmtTime(sys_st.st_mtime), pathname);
 
        return 0;
 }
@@ -838,7 +834,7 @@
        assert(path != NULL);
        assert(expansions != NULL);
 
-       DIR_DEBUG1("Expanding \"%s\"... ", word);
+       DEBUG1(DIR, "Expanding \"%s\"... ", word);
 
        cp = strchr(word, '{');
        if (cp != NULL) {
@@ -942,13 +938,13 @@
 {
        char *file;             /* the current filename to check */
 
-       DIR_DEBUG1("   %s ...\n", dir->name);
+       DEBUG1(DIR, "   %s ...\n", dir->name);
 
        if (!HashSet_Contains(&dir->files, base))
                return NULL;
 
        file = str_concat3(dir->name, "/", base);
-       DIR_DEBUG1("   returning %s\n", file);
+       DEBUG1(DIR, "   returning %s\n", file);
        dir->hits++;
        hits++;
        return file;
@@ -964,7 +960,7 @@
        char *file = dir == dot ? bmake_strdup(name)
                                : str_concat3(dir->name, "/", name);
 
-       DIR_DEBUG1("checking %s ...\n", file);
+       DEBUG1(DIR, "checking %s ...\n", file);
 
        if (cached_stat(file, &cst) == 0) {
                nearmisses++;
@@ -984,7 +980,7 @@
        const char *dnp;        /* pointer into dir->name */
        const char *np;         /* pointer into name */
 
-       DIR_DEBUG1("   %s ...\n", dir->name);
+       DEBUG1(DIR, "   %s ...\n", dir->name);
 
        /*
         * If the file has a leading path component and that component
@@ -999,13 +995,13 @@
                return NULL;
 
        if (!HashSet_Contains(&dir->files, cp)) {
-               DIR_DEBUG0("   must be here but isn't -- returning\n");
+               DEBUG0(DIR, "   must be here but isn't -- returning\n");
                return bmake_strdup("");        /* to terminate the search */
        }
 
        dir->hits++;
        hits++;
-       DIR_DEBUG1("   returning %s\n", name);
+       DEBUG1(DIR, "   returning %s\n", name);
        return bmake_strdup(name);
 }
 
@@ -1016,14 +1012,14 @@
 {
 
        if (HashSet_Contains(&dot->files, base)) {
-               DIR_DEBUG0("   in '.'\n");
+               DEBUG0(DIR, "   in '.'\n");
                hits++;
                dot->hits++;
                return bmake_strdup(name);
        }
 
        if (cur != NULL && HashSet_Contains(&cur->files, base)) {
-               DIR_DEBUG1("   in ${.CURDIR} = %s\n", cur->name);
+               DEBUG1(DIR, "   in ${.CURDIR} = %s\n", cur->name);
                hits++;
                cur->hits++;
                return str_concat3(cur->name, "/", base);
@@ -1061,10 +1057,10 @@
        lastSlash = strrchr(name, '/');
        base = lastSlash != NULL ? lastSlash + 1 : name;
 
-       DIR_DEBUG1("Searching for %s ...", name);
+       DEBUG1(DIR, "Searching for %s ...", name);
 
        if (path == NULL) {
-               DIR_DEBUG0("couldn't open path, file not found\n");
+               DEBUG0(DIR, "couldn't open path, file not found\n");
                misses++;
                return NULL;
        }
@@ -1073,10 +1069,10 @@
                CachedDir *dir = path->first->datum;
                if (dir == dotLast) {
                        seenDotLast = TRUE;
-                       DIR_DEBUG0("[dot last]...");
+                       DEBUG0(DIR, "[dot last]...");
                }
        }
-       DIR_DEBUG0("\n");
+       DEBUG0(DIR, "\n");
 
        /*
         * If there's no leading directory components or if the leading
@@ -1130,7 +1126,7 @@
         * This phase is only performed if the file is *not* absolute.
         */
        if (lastSlash == NULL) {
-               DIR_DEBUG0("   failed.\n");
+               DEBUG0(DIR, "   failed.\n");
                misses++;
                return NULL;
        }
@@ -1144,7 +1140,7 @@
                SearchPathNode *ln;
                Boolean checkedDot = FALSE;
 
-               DIR_DEBUG0("   Trying subdirectories...\n");
+               DEBUG0(DIR, "   Trying subdirectories...\n");
 
                if (!seenDotLast) {
                        if (dot != NULL) {
@@ -1184,7 +1180,7 @@
                         * Already checked by the given name, since . was in
                         * the path, so no point in proceeding.
                         */
-                       DIR_DEBUG0("   Checked . already, returning NULL\n");
+                       DEBUG0(DIR, "   Checked . already, returning NULL\n");
                        return NULL;
                }
 
@@ -1201,7 +1197,7 @@
                 * This is signified by DirLookupAbs() returning an empty
                 * string.
                 */
-               DIR_DEBUG0("   Trying exact path matches...\n");
+               DEBUG0(DIR, "   Trying exact path matches...\n");
 
                if (!seenDotLast && cur &&
                    ((file = DirLookupAbs(cur, name, base)) != NULL)) {
@@ -1276,14 +1272,14 @@
                return NULL;
        }
 #else
-       DIR_DEBUG1("   Looking for \"%s\" ...\n", name);
+       DEBUG1(DIR, "   Looking for \"%s\" ...\n", name);
 
        bigmisses++;
        if (cached_stat(name, &cst) == 0) {
                return bmake_strdup(name);
        }
 
-       DIR_DEBUG0("   failed. Returning NULL\n");
+       DEBUG0(DIR, "   failed. Returning NULL\n");
        return NULL;
 #endif
 }
@@ -1401,7 +1397,7 @@
                    !Lst_IsEmpty(&gn->implicitParents))
                        fullName = ResolveMovedDepends(gn);
 
-               DIR_DEBUG2("Found '%s' as '%s'\n",
+               DEBUG2(DIR, "Found '%s' as '%s'\n",
                           gn->name, fullName ? fullName : "(not found)");
        }
 
@@ -1465,11 +1461,11 @@
        struct dirent *dp;
 
        if ((d = opendir(name)) == NULL) {
-               DIR_DEBUG1("Caching %s ... not found\n", name);
+               DEBUG1(DIR, "Caching %s ... not found\n", name);
                return dir;
        }
 
-       DIR_DEBUG1("Caching %s ...\n", name);
+       DEBUG1(DIR, "Caching %s ...\n", name);
 
        dir = CachedDir_New(name);
 
@@ -1493,7 +1489,7 @@
        if (path != NULL)
                Lst_Append(path, CachedDir_Ref(dir));
 
-       DIR_DEBUG1("Caching %s done\n", name);
+       DEBUG1(DIR, "Caching %s done\n", name);
        return dir;
 }
 
diff -r c99a69bdb694 -r b959b5a31f1f usr.bin/make/suff.c
--- a/usr.bin/make/suff.c       Sun Dec 06 10:33:42 2020 +0000
+++ b/usr.bin/make/suff.c       Sun Dec 06 10:49:02 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: suff.c,v 1.326 2020/12/05 18:38:02 rillig Exp $        */
+/*     $NetBSD: suff.c,v 1.327 2020/12/06 10:49:02 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -114,11 +114,7 @@
 #include "dir.h"
 
 /*     "@(#)suff.c     8.4 (Berkeley) 3/21/94" */
-MAKE_RCSID("$NetBSD: suff.c,v 1.326 2020/12/05 18:38:02 rillig Exp $");
-
-#define SUFF_DEBUG0(text) DEBUG0(SUFF, text)
-#define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1)
-#define SUFF_DEBUG2(fmt, arg1, arg2) DEBUG2(SUFF, fmt, arg1, arg2)
+MAKE_RCSID("$NetBSD: suff.c,v 1.327 2020/12/06 10:49:02 rillig Exp $");
 
 typedef List SuffixList;
 typedef ListNode SuffixListNode;
@@ -442,7 +438,7 @@
        }
 
        if (ln == NULL) {
-               SUFF_DEBUG2("inserting \"%s\" (%d) at end of list\n",
+               DEBUG2(SUFF, "inserting \"%s\" (%d) at end of list\n",
                    suff->name, suff->sNum);
                Lst_Append(list, Suffix_Ref(suff));
                Lst_Append(&suff->ref, list);
@@ -452,7 +448,7 @@
                Lst_InsertBefore(list, ln, Suffix_Ref(suff));
                Lst_Append(&suff->ref, list);
        } else {
-               SUFF_DEBUG2("\"%s\" (%d) is already there\n",
+               DEBUG2(SUFF, "\"%s\" (%d) is already there\n",
                    suff->name, suff->sNum);
        }
 }
@@ -622,7 +618,7 @@
        }
 
        /* Link the two together in the proper relationship and order. */
-       SUFF_DEBUG2("defining transformation from `%s' to `%s'\n",
+       DEBUG2(SUFF, "defining transformation from `%s' to `%s'\n",
            srcSuff->name, targSuff->name);
        Relate(srcSuff, targSuff);
 
@@ -652,7 +648,7 @@
                return;
 
        if (!Lst_IsEmpty(&gn->commands) || !Lst_IsEmpty(&gn->children)) {
-               SUFF_DEBUG1("transformation %s complete\n", gn->name);



Home | Main Index | Thread Index | Old Index