]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add debug printing for the env-mashing machinery, to help investigate
authorJulian Seward <jseward@acm.org>
Mon, 15 Feb 2010 09:54:37 +0000 (09:54 +0000)
committerJulian Seward <jseward@acm.org>
Mon, 15 Feb 2010 09:54:37 +0000 (09:54 +0000)
#215914 ("Valgrind inserts bogus empty environment variable").

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11041

coregrind/m_initimg/initimg-linux.c

index f5659129a594910a7950def979d21dbe71b61e81..c36f2a1ba781cad66f71fa928fe693688fb1c2c5 100644 (file)
@@ -132,6 +132,7 @@ static HChar** setup_client_env ( HChar** origenv, const HChar* toolname)
    Int    v_launcher_len  = VG_(strlen)( v_launcher );
    Bool   ld_preload_done = False;
    Int    vglib_len       = VG_(strlen)(VG_(libdir));
+   Bool   debug           = False;
 
    HChar** cpp;
    HChar** ret;
@@ -172,9 +173,12 @@ static HChar** setup_client_env ( HChar** origenv, const HChar* toolname)
    VG_(debugLog)(2, "initimg", "  \"%s\"\n", preload_string);
 
    /* Count the original size of the env */
+   if (debug) VG_(printf)("\n\n");
    envc = 0;
-   for (cpp = origenv; cpp && *cpp; cpp++)
+   for (cpp = origenv; cpp && *cpp; cpp++) {
       envc++;
+      if (debug) VG_(printf)("XXXXXXXXX: BEFORE %s\n", *cpp);
+   }
 
    /* Allocate a new space */
    ret = VG_(malloc) ("initimg-linux.sce.3",
@@ -182,8 +186,10 @@ static HChar** setup_client_env ( HChar** origenv, const HChar* toolname)
    vg_assert(ret);
 
    /* copy it over */
-   for (cpp = ret; *origenv; )
+   for (cpp = ret; *origenv; ) {
+      if (debug) VG_(printf)("XXXXXXXXX: COPY   %s\n", *origenv);
       *cpp++ = *origenv++;
+   }
    *cpp = NULL;
    
    vg_assert(envc == (cpp - ret));
@@ -202,6 +208,7 @@ static HChar** setup_client_env ( HChar** origenv, const HChar* toolname)
 
          ld_preload_done = True;
       }
+      if (debug) VG_(printf)("XXXXXXXXX: MASH   %s\n", *cpp);
    }
 
    /* Add the missing bits */
@@ -213,6 +220,7 @@ static HChar** setup_client_env ( HChar** origenv, const HChar* toolname)
       VG_(snprintf)(cp, len, "%s%s", ld_preload, preload_string);
 
       ret[envc++] = cp;
+      if (debug) VG_(printf)("XXXXXXXXX: ADD    %s\n", cp);
    }
 
    /* ret[0 .. envc-1] is live now. */
@@ -230,6 +238,10 @@ static HChar** setup_client_env ( HChar** origenv, const HChar* toolname)
    VG_(free)(preload_string);
    ret[envc] = NULL;
 
+   for (i = 0; i < envc; i++) {
+      if (debug) VG_(printf)("XXXXXXXXX: FINAL  %s\n", ret[i]);
+   }
+
    return ret;
 }