{
Int i;
HChar* LD_PRELOAD_val;
- HChar* s;
- HChar* s2;
/* We will record execontext up to clo_depth + overestimate and
we will store this as ec => we need to increase the backtrace size
// If --pages-as-heap=yes we don't want malloc replacement to occur. So we
// disable vgpreload_massif-$PLATFORM.so by removing it from LD_PRELOAD (or
- // platform-equivalent). We replace it entirely with spaces because then
- // the linker doesn't complain (it does complain if we just change the name
- // to a bogus file). This is a bit of a hack, but LD_PRELOAD is setup well
- // before tool initialisation, so this seems the best way to do it.
+ // platform-equivalent). This is a bit of a hack, but LD_PRELOAD is setup
+ // well before tool initialisation, so this seems the best way to do it.
if (clo_pages_as_heap) {
+ HChar* s1;
+ HChar* s2;
+
clo_heap_admin = 0; // No heap admin on pages.
LD_PRELOAD_val = VG_(getenv)( VG_(LD_PRELOAD_var_name) );
tl_assert(LD_PRELOAD_val);
+ VERB(2, "clo_pages_as_heap orig LD_PRELOAD '%s'\n", LD_PRELOAD_val);
+
// Make sure the vgpreload_core-$PLATFORM entry is there, for sanity.
- s2 = VG_(strstr)(LD_PRELOAD_val, "vgpreload_core");
- tl_assert(s2);
+ s1 = VG_(strstr)(LD_PRELOAD_val, "vgpreload_core");
+ tl_assert(s1);
// Now find the vgpreload_massif-$PLATFORM entry.
- s2 = VG_(strstr)(LD_PRELOAD_val, "vgpreload_massif");
- tl_assert(s2);
+ s1 = VG_(strstr)(LD_PRELOAD_val, "vgpreload_massif");
+ tl_assert(s1);
+ s2 = s1;
- // Blank out everything to the previous ':', which must be there because
+ // Position s1 on the previous ':', which must be there because
// of the preceding vgpreload_core-$PLATFORM entry.
- for (s = s2; *s != ':'; s--) {
- *s = ' ';
- }
+ for (; *s1 != ':'; s1--)
+ ;
- // Blank out everything to the end of the entry, which will be '\0' if
- // LD_PRELOAD was empty before Valgrind started, or ':' otherwise.
- for (s = s2; *s != ':' && *s != '\0'; s++) {
- *s = ' ';
- }
+ // Position s2 on the next ':' or \0
+ for (; *s2 != ':' && *s2 != '\0'; s2++)
+ ;
+
+ // Move all characters from s2 to s1
+ while ((*s1++ = *s2++))
+ ;
+
+ VERB(2, "clo_pages_as_heap cleaned LD_PRELOAD '%s'\n", LD_PRELOAD_val);
}
// Print alloc-fns and ignore-fns, if necessary.