mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-04 02:18:37 +00:00
Export VG_(discard_tranalsations_safely) to the tools. It is
only allowed to be called in certain contexts which is enforced at runtime. Change callgrind accordingly. New header file pub_tool_transtab.h added. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14867
This commit is contained in:
parent
7d07a3deaf
commit
cbd27b7288
@ -37,6 +37,7 @@
|
||||
|
||||
#include "pub_tool_threadstate.h"
|
||||
#include "pub_tool_gdbserver.h"
|
||||
#include "pub_tool_transtab.h" // VG_(discard_translations_safely)
|
||||
|
||||
#include "cg_branchpred.c"
|
||||
|
||||
@ -1448,10 +1449,6 @@ void zero_state_cost(thread_info* t)
|
||||
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) {
|
||||
@ -1463,7 +1460,7 @@ void CLG_(set_instrument_state)(const HChar* reason, Bool 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);
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
|
||||
#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);
|
||||
@ -268,12 +269,27 @@ void VG_(needs_command_line_options)(
|
||||
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)(
|
||||
|
||||
@ -2022,6 +2022,17 @@ void VG_(discard_translations) ( Addr guest_start, ULong range,
|
||||
}
|
||||
}
|
||||
|
||||
/* 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 ---*/
|
||||
|
||||
@ -38,6 +38,7 @@
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
#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
|
||||
@ -129,6 +130,9 @@ typedef struct _SBProfEntry {
|
||||
|
||||
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
|
||||
|
||||
/*--------------------------------------------------------------------*/
|
||||
|
||||
@ -37,6 +37,7 @@ nobase_pkginclude_HEADERS = \
|
||||
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 \
|
||||
|
||||
43
include/pub_tool_transtab.h
Normal file
43
include/pub_tool_transtab.h
Normal file
@ -0,0 +1,43 @@
|
||||
|
||||
/*--------------------------------------------------------------------*/
|
||||
/*--- 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 ---*/
|
||||
/*--------------------------------------------------------------------*/
|
||||
Loading…
x
Reference in New Issue
Block a user