Fix up some stack trace inconsistencies:
- When printing suppressions, never print more entries than there are in the
stack. This avoids bogus suppressions in some cases! (I haven't seen
them on Linux, but I have seen them on Darwin.)
- When getting a stack trace, stop if we get an IP of zero or one; that
means we've hit the end of the stack. And don't include that entry in the
stack trace, because it's a guaranteed "???" if it's ever printed which is
useless.
- In VG_(apply_StackTrace), we can now rely entirely on the n_ip parameter
rather than looking for 0 or -1, because that check is done when the stack
trace is first obtained. In other words, stack traces all use an n_ip
parameter to record their size, whereas previously they used an odd
mixture of n_ip and null-termination.
- Rename 'n_ips' variables as 'max_n_ips' where appropriate; those left as
'n_ips' truly describe how many IPs there are in the stack trace.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9793 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/helgrind/libhb_core.c b/helgrind/libhb_core.c
index b2142ec..1a600ac 100644
--- a/helgrind/libhb_core.c
+++ b/helgrind/libhb_core.c
@@ -3184,15 +3184,18 @@
tl_assert(i >= 0 && i <= N_OLDREF_ACCS);
if (i < N_OLDREF_ACCS) {
+ Int n, maxNFrames;
/* return with success */
tl_assert(cand_thr);
tl_assert(cand_rcec);
tl_assert(cand_rcec->magic == RCEC_MAGIC);
tl_assert(cand_szB >= 1);
- *resEC = VG_(make_ExeContext_from_StackTrace)(
- &cand_rcec->frames[0],
- min_UInt(N_FRAMES, VG_(clo_backtrace_size))
- );
+ /* Count how many non-zero frames we have. */
+ maxNFrames = min_UInt(N_FRAMES, VG_(clo_backtrace_size));
+ for (n = 0; n < maxNFrames; n++) {
+ if (0 == cand_rcec->frames[n]) break;
+ }
+ *resEC = VG_(make_ExeContext_from_StackTrace)(cand_rcec->frames, n);
*resThr = cand_thr;
*resSzB = cand_szB;
*resIsW = cand_isW;