This adds an option to change the default handling of jumps
between functions. Usually, a jump between functions is
interpreted as call, because such jumps are typically
generated by compilers on tail recursion optimization, and
we want to present this as call to the user. Thus, such
a jump pushes a call onto callgrinds shadow stack.
The option "--pop-on-jump" changes this to pop+push the
shadow callstack: then, a jump between functions is seen
as a return to the caller and a new call.
The default behaviour is _bad_ for using callgrind with
self-hosting. Valgrinds inner loop VG_(run_innerloop)
jumps to generated code, and this code jumps back to
the inner loop. Thus, every executed BB adds 2 calls
to an ever increasing shadow call stack, leading to
memory consumption increasing with runtime :-(
So: For self-hosting valgrind with an outer callgrind,
always use option "--pop-on-jump" for the outer callgrind.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5869
else if (0 == VG_(strncmp)(arg, "--separate-recs=", 16))
CLG_(clo).separate_recursions = (Int)VG_(atoll)(&arg[16]);
- /* workaround to find runtime_resolve (needs special handling) */
+ /* change handling of a jump between functions to ret+call */
+ else if (0 == VG_(strcmp)(arg, "--pop-on-jump")) {
+ CLG_(clo).pop_on_jump = True;
+ }
else if (0 == VG_(strncmp)(arg, "--pop-on-jump=", 14)) {
fn_config* fnc = get_fnc(arg+14);
fnc->pop_on_jump = CONFIG_TRUE;
CLG_(clo).instrument_atstart = True;
CLG_(clo).simulate_cache = False;
+ /* Call graph */
+ CLG_(clo).pop_on_jump = False;
+
#if CLG_ENABLE_DEBUG
CLG_(clo).verbose = 0;
CLG_(clo).verbose_start = 0;
new->zero_before = False;
new->toggle_collect = False;
new->skip = False;
- new->pop_on_jump = False;
+ new->pop_on_jump = CLG_(clo).pop_on_jump;
new->is_malloc = False;
new->is_realloc = False;
new->is_free = False;
Bool instrument_atstart; /* Instrument at start? */
Bool simulate_cache; /* Call into cache simulator ? */
+ /* Call graph generation */
+ Bool pop_on_jump; /* Handle a jump between functions as ret+call */
+
#if CLG_ENABLE_DEBUG
Int verbose;
ULong verbose_start;