|
From: <sv...@va...> - 2016-11-12 20:11:32
|
Author: philippe
Date: Sat Nov 12 20:11:25 2016
New Revision: 16135
Log:
When --show-below-main=no, search main from the outermost stackframe
* main is more likely to be an outermost frame rather than an innermost
frame. So, searching from the outermost frame will more quickly find it.
* Also, in case the stacktrace contains twice the main functionn, this
ensures we only removes the functions below the outermost main.
Having 2 mains in a stacktrace does not happen normally.
However, this prepares for some future commit that improves
the outer/inner setup: the outer will append the inner guest stack trace.
The inner stack trace sometimes already contains main.
Searching from outermost frame main allows to keep the interesting
part of the stacktrace.
Modified:
trunk/coregrind/m_stacktrace.c
Modified: trunk/coregrind/m_stacktrace.c
==============================================================================
--- trunk/coregrind/m_stacktrace.c (original)
+++ trunk/coregrind/m_stacktrace.c Sat Nov 12 20:11:25 2016
@@ -1797,28 +1797,25 @@
StackTrace ips, UInt n_ips
)
{
- Bool main_done = False;
- Int i = 0;
+ Int i;
vg_assert(n_ips > 0);
- do {
- Addr ip = ips[i];
-
- // Stop after the first appearance of "main" or one of the other names
- // (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_FnNameKind kind = VG_(get_fnname_kind_from_IP)(ip);
- if (Vg_FnNameMain == kind || Vg_FnNameBelowMain == kind) {
- main_done = True;
- }
+ if ( ! VG_(clo_show_below_main) ) {
+ // Search (from the outer frame onwards) the appearance of "main"
+ // or the last appearance of a below main function.
+ // Then decrease n_ips so as to not call action for the below main
+ for (i = n_ips - 1; i >= 0; i--) {
+ Vg_FnNameKind kind = VG_(get_fnname_kind_from_IP)(ips[i]);
+ if (Vg_FnNameMain == kind || Vg_FnNameBelowMain == kind)
+ n_ips = i + 1;
+ if (Vg_FnNameMain == kind)
+ break;
}
+ }
+ for (i = 0; i < n_ips; i++)
// Act on the ip
- action(i, ip, opaque);
-
- i++;
- } while (i < n_ips && !main_done);
+ action(i, ips[i], opaque);
}
|