tech-toolchain: Re: make: extra debug info

Subject: Re: make: extra debug info
To: None <tech-toolchain@netbsd.org>
From: Simon J. Gerraty <sjg@crufty.net>
List: tech-toolchain
Date: 07/11/2006 10:09:13
>The following changes proved useful while tracking down an odd
>makefile bug.
>Eg. when doing a complex set of modifiers - especially involving :?
>it can be very tedious to match the "Result is" lines up with the
>"Applying :%c" lines. This patch addresses that and
>also adds a clue as to how exists() is behaving in the case of say
>:@d@${exists(${d:S,foo,goo,}):?$d:${d:H:S,foo,goo,}}@
Of course I only included part of the patch ;-)
Repeated here. Unless anyone objects I'll commit this week.
Thanks
--sjg
Index: cond.c
===================================================================
RCS file: /cvsroot/src/usr.bin/make/cond.c,v
retrieving revision 1.32
diff -u -p -r1.32 cond.c
--- cond.c	22 Apr 2006 18:53:32 -0000	1.32
+++ cond.c	11 Jul 2006 16:06:06 -0000
@@ -420,6 +420,10 @@ CondDoExists(int argLen, char *arg)
 	result = FALSE;
 }
 arg[argLen] = savec;
+ if (DEBUG(COND)) {
+	printf("exists(%s) result is \"%s\"\n",
+	 arg, path ? path : "");
+ } 
 return (result);
 }
 
Index: main.c
===================================================================
RCS file: /cvsroot/src/usr.bin/make/main.c,v
retrieving revision 1.127
diff -u -p -r1.127 main.c
--- main.c	29 Jun 2006 22:02:06 -0000	1.127
+++ main.c	11 Jul 2006 16:06:06 -0000
@@ -1736,6 +1736,8 @@ PrintOnError(const char *s)
 s = Var_Subst(NULL, tmp, VAR_GLOBAL, 0);
 if (s && *s)
 	printf("%s", s);
+ if (s)
+	 free(s);
 }
 
 void
Index: var.c
===================================================================
RCS file: /cvsroot/src/usr.bin/make/var.c,v
retrieving revision 1.111
diff -u -p -r1.111 var.c
--- var.c	29 Jun 2006 22:01:17 -0000	1.111
+++ var.c	11 Jul 2006 16:06:07 -0000
@@ -1989,6 +1989,7 @@ ApplyModifiers(char *nstr, const char *t
 int cnt;	/* Used to count brace pairs when variable in
 				 * in parens or braces */
 char	delim;
+ int		modifier;	/* that we are processing */
 Var_Parse_State parsestate; /* Flags passed to helper functions */
 
 delim = '0円';
@@ -2040,7 +2041,7 @@ ApplyModifiers(char *nstr, const char *t
 	 printf("Applying :%c to \"%s\"\n", *tstr, nstr);
 	}
 	newStr = var_Error;
-	switch (*tstr) {
+	switch ((modifier = *tstr)) {
 	case ':':
 	 {
 		if (tstr[1] == '=' ||
@@ -2937,7 +2938,7 @@ ApplyModifiers(char *nstr, const char *t
 	 }
 	}
 	if (DEBUG(VAR)) {
-	 printf("Result is \"%s\"\n", newStr);
+	 printf("Result of :%c is \"%s\"\n", modifier, newStr);
 	}
 
 	if (newStr != nstr) {

AltStyle によって変換されたページ (->オリジナル) /