Update ugly Callgrind hack for supporting instrumentation modes

To support different instrumentation modes, callgrind calls
VG_(discard_translations), which up to now does not belong to the
functions allowed to call from tools, as this is unsafe if
called from generated code.

Callgrind hacks around that by defining the prototype itself.
However, in r4789 (from Sep 27 2005!) a 3rd arg was added for
debugging output. Thus, callgrind could crash if called
with "-d -d".

As the "instrumentation off" feature seems to be used quite often,
it really would be nice to have VG_(discard_translations) callable
from tools...

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11906
This commit is contained in:
Josef Weidendorfer 2011-07-21 20:24:54 +00:00
parent bd379979b8
commit 3bb3954eb5

View File

@ -1330,8 +1330,8 @@ void zero_state_cost(thread_info* t)
CLG_(zero_cost)( CLG_(sets).full, CLG_(current_state).cost );
}
/* Ups, this can go wrong... */
extern void VG_(discard_translations) ( Addr64 start, ULong range );
/* Ups, this can go very wrong... */
extern void VG_(discard_translations) ( Addr64 start, ULong range, HChar* who );
void CLG_(set_instrument_state)(Char* reason, Bool state)
{
@ -1344,7 +1344,7 @@ void CLG_(set_instrument_state)(Char* reason, Bool state)
CLG_DEBUG(2, "%s: Switching instrumentation %s ...\n",
reason, state ? "ON" : "OFF");
VG_(discard_translations)( (Addr64)0x1000, (ULong) ~0xfffl);
VG_(discard_translations)( (Addr64)0x1000, (ULong) ~0xfffl, "callgrind");
/* reset internal state: call stacks, simulator */
CLG_(forall_threads)(unwind_thread);