#include "pub_tool_threadstate.h"
#include "pub_tool_gdbserver.h"
+#include "pub_tool_transtab.h" // VG_(discard_translations_safely)
#include "cg_branchpred.c"
CLG_(zero_cost)( CLG_(sets).full, CLG_(current_state).cost );
}
-/* Ups, this can go very wrong...
- FIXME: We should export this function or provide other means to get a handle */
-extern void VG_(discard_translations) ( Addr start, ULong range, const HChar* who );
-
void CLG_(set_instrument_state)(const HChar* reason, Bool state)
{
if (CLG_(instrument_state) == state) {
CLG_DEBUG(2, "%s: Switching instrumentation %s ...\n",
reason, state ? "ON" : "OFF");
- VG_(discard_translations)( (Addr)0x1000, (ULong) ~0xfffl, "callgrind");
+ VG_(discard_translations_safely)( (Addr)0x1000, ~(SizeT)0xfff, "callgrind");
/* reset internal state: call stacks, simulator */
CLG_(forall_threads)(unwind_thread);
#include "pub_core_basics.h"
#include "pub_core_tooliface.h"
+#include "pub_core_transtab.h" /* VG_(ok_to_discard_translations) */
// The core/tool dictionary of functions (initially zeroed, as we want it)
VgToolInterface VG_(tdict);
VG_(tdict).tool_print_debug_usage = debug_usage;
}
+/* The tool's function for handling client requests. */
+static Bool (*tool_handle_client_request_func)(ThreadId, UWord *, UWord *);
+
+static Bool wrap_tool_handle_client_request(ThreadId tid, UWord *arg1,
+ UWord *arg2)
+{
+ Bool ret;
+ VG_(ok_to_discard_translations) = True;
+ ret = tool_handle_client_request_func(tid, arg1, arg2);
+ VG_(ok_to_discard_translations) = False;
+ return ret;
+}
+
void VG_(needs_client_requests)(
Bool (*handle)(ThreadId, UWord*, UWord*)
)
{
VG_(needs).client_requests = True;
- VG_(tdict).tool_handle_client_request = handle;
+ tool_handle_client_request_func = handle; /* Stash away */
+ /* Register the wrapper function */
+ VG_(tdict).tool_handle_client_request = wrap_tool_handle_client_request;
}
void VG_(needs_syscall_wrapper)(
}
}
+/* Whether or not tools may discard translations. */
+Bool VG_(ok_to_discard_translations) = False;
+
+/* This function is exported to tools which can use it to discard
+ translations, provided it is safe to do so. */
+void VG_(discard_translations_safely) ( Addr start, SizeT len,
+ const HChar* who )
+{
+ vg_assert(VG_(ok_to_discard_translations));
+ VG_(discard_translations)(start, len, who);
+}
/*------------------------------------------------------------*/
/*--- AUXILIARY: the unredirected TT/TC ---*/
//--------------------------------------------------------------------
#include "pub_core_transtab_asm.h"
+#include "pub_tool_transtab.h"
#include "libvex.h" // VexGuestExtents
/* The fast-cache for tt-lookup. Unused entries are denoted by .guest
extern ULong VG_(get_SB_profile) ( SBProfEntry tops[], UInt n_tops );
+// Exported variables
+extern Bool VG_(ok_to_discard_translations);
+
#endif // __PUB_CORE_TRANSTAB_H
/*--------------------------------------------------------------------*/
pub_tool_stacktrace.h \
pub_tool_threadstate.h \
pub_tool_tooliface.h \
+ pub_tool_transtab.h \
pub_tool_vki.h \
pub_tool_vkiscnums.h \
pub_tool_vkiscnums_asm.h \
--- /dev/null
+
+/*--------------------------------------------------------------------*/
+/*--- The translation table and cache. ---*/
+/*--- pub_tool_transtab.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+ This file is part of Valgrind, a dynamic binary instrumentation
+ framework.
+
+ Copyright (C) 2014-2014 Florian Krohm (florian@eich-krohm.de)
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307, USA.
+
+ The GNU General Public License is contained in the file COPYING.
+*/
+
+#ifndef __PUB_TOOL_TRANSTAB_H
+#define __PUB_TOOL_TRANSTAB_H
+
+#include "pub_tool_basics.h" // VG_ macro and primitive types
+
+void VG_(discard_translations_safely) ( Addr start, SizeT len,
+ const HChar* who );
+
+#endif // __PUB_TOOL_TRANSTAB_H
+
+/*--------------------------------------------------------------------*/
+/*--- end ---*/
+/*--------------------------------------------------------------------*/