Merge r14308 from the BUF_REMOVAL branch to trunk
Changes VG_(describe_IP) to return the untruncated result in a statically
allocated local buffer. Fix call sites and update two .exp files who had
truncated names.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14685 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/massif/ms_main.c b/massif/ms_main.c
index 03e94ab..826091a 100644
--- a/massif/ms_main.c
+++ b/massif/ms_main.c
@@ -2135,8 +2135,7 @@
// Used for printing function names. Is made static to keep it out
// of the stack frame -- this function is recursive. Obviously this
// now means its contents are trashed across the recursive call.
- static HChar ip_desc_array[BUF_LEN];
- const HChar* ip_desc = ip_desc_array;
+ const HChar* ip_desc;
switch (sxpt->tag) {
case SigSXPt:
@@ -2166,7 +2165,7 @@
}
// We need the -1 to get the line number right, But I'm not sure why.
- ip_desc = VG_(describe_IP)(sxpt->Sig.ip-1, ip_desc_array, BUF_LEN, NULL);
+ ip_desc = VG_(describe_IP)(sxpt->Sig.ip-1, NULL);
}
// Do the non-ip_desc part first...
@@ -2187,28 +2186,13 @@
}
}
}
- // Nb: We treat this specially (ie. we don't use FP) so that if the
- // ip_desc is too long (eg. due to a long C++ function name), it'll
- // get truncated, but the '\n' is still there so its a valid file.
- // (At one point we were truncating without adding the '\n', which
- // caused bug #155929.)
- //
- // Also, we account for the length of the address in ip_desc when
- // truncating. (The longest address we could have is 18 chars: "0x"
- // plus 16 address digits.) This ensures that the truncated function
- // name always has the same length, which makes truncation
- // deterministic and thus makes testing easier.
- tl_assert(j <= 18);
- // FIXME: this whole code block will go away, once VG_(describe_IP)
- // FIXME: has been fixed; I'm keeping it for now so testcases won't fail
- HChar FP_buf[BUF_LEN];
- VG_(snprintf)(FP_buf, BUF_LEN, "%s\n", ip_desc);
- FP_buf[BUF_LEN-18+j-5] = '.'; // "..." at the end make the
- FP_buf[BUF_LEN-18+j-4] = '.'; // truncation more obvious.
- FP_buf[BUF_LEN-18+j-3] = '.';
- FP_buf[BUF_LEN-18+j-2] = '\n'; // The last char is '\n'.
- FP_buf[BUF_LEN-18+j-1] = '\0'; // The string is terminated.
- VG_(fprintf)(fp, "%s", FP_buf);
+ // It used to be that ip_desc was truncated at the end.
+ // But there does not seem to be a good reason for that. Besides,
+ // the string was truncated at the right, which is less than ideal.
+ // Truncation at the beginning of the string would have been preferable.
+ // Think several nested namespaces in C++....
+ // Anyhow, we spit out the full-length string now.
+ VG_(fprintf)(fp, "%s\n", ip_desc);
// Indent.
tl_assert(depth+1 < depth_str_len-1); // -1 for end NUL char
@@ -2232,7 +2216,7 @@
if (InsigSXPt == child->tag)
n_insig_children_sxpts++;
- // Ok, print the child. NB: contents of ip_desc_array will be
+ // Ok, print the child. NB: contents of ip_desc will be
// trashed by this recursive call. Doesn't matter currently,
// but worth noting.
pp_snapshot_SXPt(fp, child, depth+1, depth_str, depth_str_len,