|
From: <sv...@va...> - 2005-11-17 15:12:39
|
Author: sewardj
Date: 2005-11-17 15:12:34 +0000 (Thu, 17 Nov 2005)
New Revision: 5170
Log:
Make VG_(apply_StackTrace) stop if it looks like we've overshot main().
Modified:
trunk/coregrind/m_stacktrace.c
Modified: trunk/coregrind/m_stacktrace.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_stacktrace.c 2005-11-17 14:26:52 UTC (rev 5169)
+++ trunk/coregrind/m_stacktrace.c 2005-11-17 15:12:34 UTC (rev 5170)
@@ -370,7 +370,8 @@
void VG_(apply_StackTrace)( void(*action)(UInt n, Addr ip),
StackTrace ips, UInt n_ips )
{
- #define MYBUF_LEN 10 // only needs to be long enough for "main"
+ #define MYBUF_LEN 50 // only needs to be long enough for=20
+ // the names specially tested for
=20
Bool main_done =3D False;
Char mybuf[MYBUF_LEN]; // ok to stack allocate mybuf[] -- it's ti=
ny
@@ -382,20 +383,26 @@
if (i > 0)=20
ip -=3D VG_MIN_INSTR_SZB; // point to calling line
=20
- // Stop after "main"; if main() is recursive, stop after last mai=
n().
+ // Stop after the first appearance of "main" or one of the other n=
ames
+ // (the appearance of which is a pretty good sign that we've gone =
past
+ // main without seeing it, for whatever reason)
if ( ! VG_(clo_show_below_main)) {
VG_(get_fnname_nodemangle)( ip, mybuf, MYBUF_LEN );
- if ( VG_STREQ("main", mybuf) )
+ mybuf[MYBUF_LEN-1] =3D 0; // paranoia
+ if ( VG_STREQ("main", mybuf)
+# if defined(VGO_linux)
+ || VG_STREQ("__libc_start_main", mybuf) // glibc wretched=
ness
+ || VG_STREQ("generic_start_main", mybuf) // Yellow Dog dog=
gedness
+# endif
+ )
main_done =3D True;
- else if (main_done)
- break;
}
=20
// Act on the ip
action(i, ip);
=20
i++;
- } while (i < n_ips && ips[i] !=3D 0);
+ } while (i < n_ips && ips[i] !=3D 0 && !main_done);
=20
#undef MYBUF_LEN
}
|