Subject: make: extra debug info
To: None <tech-toolchain@netbsd.org>
From: Simon J. Gerraty <sjg@crufty.net>
List: tech-toolchain
Date: 05/22/2006 13:35:15
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,}}@
--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 22 May 2006 20:28:53 -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: var.c
===================================================================
RCS file: /cvsroot/src/usr.bin/make/var.c,v
retrieving revision 1.108
diff -u -p -r1.108 var.c
--- var.c 11 May 2006 15:37:07 -0000 1.108
+++ var.c 22 May 2006 20:28:53 -0000
@@ -1981,6 +1981,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';
@@ -2032,7 +2033,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] == '=' ||
@@ -2926,7 +2927,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) {