RFE: Add build option to run mamake/mamprobe/iffe under valgrind control
gisburn opened this issue · 2 comments
RFE: Add build option to run mamake/mamprobe/iffe under Linux valgrind control (with custom valgrind options, e.g. to send output per invocation to a separate file).
Point is that since the OpenSolaris ksh93-integration project (replacing /sbin/sh+/bin/sh with ksh93) we know that there are memory corruption issues in mamake, and I'd like to get them hunted down now (see also Issue #758 ).
The following patch allows prefixing arbitrary whitespace-separated command arguments exported in the environment variable MAMAKE_DEBUG_PREFIX
to every mamake invocation. This should allow using valgrind. Please try this out and let me know how you get on with it.
diff --git a/bin/package b/bin/package
index 8d969c8b..682b0ed3 100755
--- a/bin/package
+++ b/bin/package
@@ -3187,7 +3187,7 @@ make|view)
case $target in
'') target="install" ;;
esac
- eval capture mamake \$makeflags \$noexec \$target $assign
+ eval capture \$\{MAMAKE_DEBUG_PREFIX} mamake \$makeflags \$noexec \$target $assign
case $HOSTTYPE in
darwin.*)
@@ -3376,7 +3376,7 @@ test) # run all available default regression tests, using our newly compiled she
set -f
set -- ${args:-src}
cd "$1" || exit
- capture mamake test
+ capture ${MAMAKE_DEBUG_PREFIX} mamake test
;;
use) # finalize the environment
diff --git a/src/cmd/INIT/mamake.c b/src/cmd/INIT/mamake.c
index e3a4a504..8c673ef2 100644
--- a/src/cmd/INIT/mamake.c
+++ b/src/cmd/INIT/mamake.c
@@ -2199,6 +2199,7 @@ static int update(Rule_t *r)
{
List_t *x;
Buf_t *buf;
+ char *cp;
/* topological sort */
r->flags |= RULE_made;
@@ -2228,6 +2229,8 @@ static int update(Rule_t *r)
}
/* do */
+ if (cp = getval(state.vars, "MAMAKE_DEBUG_PREFIX"))
+ append(buf, cp), add(buf, ' ');
append(buf, getval(state.vars, "MAMAKE"));
append(buf, " -C ");
append(buf, r->name);
BTW, mamprobe and iffe are shell scripts, so valgrind wouldn't make much sense for them.