|
From: <sv...@va...> - 2005-10-18 12:04:30
|
Author: sewardj
Date: 2005-10-18 13:04:18 +0100 (Tue, 18 Oct 2005)
New Revision: 4943
Log:
Change the core-tool interface so that tools are fully aware of both
the guest extents for the presented translation and also its original
un-redirected guest address. These changes are needed in particular
to make cachegrind's code cache management work properly.
Modified:
trunk/cachegrind/cg_main.c
trunk/coregrind/m_tooliface.c
trunk/coregrind/m_translate.c
trunk/coregrind/m_transtab.c
trunk/coregrind/pub_core_tooliface.h
trunk/helgrind/hg_main.c
trunk/include/pub_tool_tooliface.h
trunk/lackey/lk_main.c
trunk/massif/ms_main.c
trunk/memcheck/mc_include.h
trunk/memcheck/mc_translate.c
trunk/none/nl_main.c
Modified: trunk/cachegrind/cg_main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/cachegrind/cg_main.c 2005-10-18 02:30:42 UTC (rev 4942)
+++ trunk/cachegrind/cg_main.c 2005-10-18 12:04:18 UTC (rev 4943)
@@ -141,7 +141,7 @@
=20
typedef struct _BB_info BB_info;
struct _BB_info {
- Addr BB_addr; // key
+ Addr BB_addr; // key; MUST BE FIRST
Int n_instrs;
InstrInfo instrs[0];
};
@@ -452,6 +452,8 @@
/*--- Instrumentation main ---*/
/*------------------------------------------------------------*/
=20
+// Note that origAddr is the real origAddr, not the address of the first
+// instruction in the block (they can be different due to redirection).
static
BB_info* get_BB_info(IRBB* bbIn, Addr origAddr)
{
@@ -731,8 +733,10 @@
////////////////////////////////////////////////////////////
=20
=20
-static IRBB* cg_instrument ( IRBB* bbIn, VexGuestLayout* layout,=20
- IRType gWordTy, IRType hWordTy )
+static
+IRBB* cg_instrument ( IRBB* bbIn, VexGuestLayout* layout,=20
+ Addr64 orig_addr_noredir, VexGuestExtents* vge,
+ IRType gWordTy, IRType hWordTy )
{
Int i, isize;
IRStmt* st;
@@ -763,7 +767,7 @@
=20
// Set up running state and get block info
cgs.events_used =3D 0;
- cgs.bbInfo =3D get_BB_info(bbIn, (Addr)cia);
+ cgs.bbInfo =3D get_BB_info(bbIn, (Addr)orig_addr_noredir);
cgs.bbInfo_i =3D 0;
=20
if (DEBUG_CG)
@@ -1241,18 +1245,22 @@
// Called when a translation is removed from the translation cache for
// any reason at all: to free up space, because the guest code was
// unmapped or modified, or for any arbitrary reason.
-static void cg_discard_basic_block_info ( VexGuestExtents vge )
+static
+void cg_discard_basic_block_info ( Addr64 orig_addr64, VexGuestExtents v=
ge )
{
BB_info* bbInfo;
+ Addr orig_addr =3D (Addr)orig_addr64;
=20
tl_assert(vge.n_used > 0);
=20
if (DEBUG_CG)
- VG_(printf)( "discard_basic_block_info: %p, %llu\n",=20
+ VG_(printf)( "discard_basic_block_info: %p, %p, %llu\n",=20
+ (void*)(Addr)orig_addr,
(void*)(Addr)vge.base[0], (ULong)vge.len[0]);
=20
- // Get BB info, remove from table, free BB info. Simple!
- bbInfo =3D VG_(OSet_Remove)(instrInfoTable, &(vge.base[0]));
+ // Get BB info, remove from table, free BB info. Simple! Note that =
we
+ // use orig_addr, not the first instruction address in vge.
+ bbInfo =3D VG_(OSet_Remove)(instrInfoTable, &orig_addr);
tl_assert(NULL !=3D bbInfo);
VG_(OSet_FreeNode)(instrInfoTable, bbInfo);
}
@@ -1375,7 +1383,7 @@
CC_table =3D VG_(OSet_Create)(offsetof(LineCC, loc),
cmp_CodeLoc_LineCC,
VG_(malloc), VG_(free));
- instrInfoTable =3D VG_(OSet_Create)(offsetof(BB_info, BB_addr),
+ instrInfoTable =3D VG_(OSet_Create)(/*keyOff*/0,
NULL,
VG_(malloc), VG_(free));
stringTable =3D VG_(OSet_Create)(/*keyOff*/0,
Modified: trunk/coregrind/m_tooliface.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_tooliface.c 2005-10-18 02:30:42 UTC (rev 4942)
+++ trunk/coregrind/m_tooliface.c 2005-10-18 12:04:18 UTC (rev 4943)
@@ -40,7 +40,8 @@
=20
void VG_(basic_tool_funcs)(
void(*post_clo_init)(void),
- IRBB*(*instrument)(IRBB*, VexGuestLayout*, IRType, IRType ),
+ IRBB*(*instrument)(IRBB*, VexGuestLayout*,=20
+ Addr64, VexGuestExtents*, IRType, IRType ),
void(*fini)(Int)
)
{
@@ -154,7 +155,7 @@
NEEDS(data_syms)
=20
void VG_(needs_basic_block_discards)(
- void (*discard)(VexGuestExtents)
+ void (*discard)(Addr64, VexGuestExtents)
)
{
VG_(needs).basic_block_discards =3D True;
Modified: trunk/coregrind/m_translate.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_translate.c 2005-10-18 02:30:42 UTC (rev 4942)
+++ trunk/coregrind/m_translate.c 2005-10-18 12:04:18 UTC (rev 4943)
@@ -166,8 +166,12 @@
*/
=20
static
-IRBB* vg_SP_update_pass ( IRBB* bb_in, VexGuestLayout* layout,=20
- IRType gWordTy, IRType hWordTy )
+IRBB* vg_SP_update_pass ( IRBB* bb_in,=20
+ VexGuestLayout* layout,=20
+ Addr64 orig_addr_noredir,
+ VexGuestExtents* vge,
+ IRType gWordTy,=20
+ IRType hWordTy )
{
Int i, j, minoff_ST, maxoff_ST, sizeof_SP, offset_SP;
IRDirty *dcall, *d;
@@ -520,7 +524,7 @@
Int debugging_verbosity,
ULong bbs_done )
{
- Addr64 redir, orig_addr0 =3D orig_addr;
+ Addr64 redir, orig_addr_noredir =3D orig_addr;
Int tmpbuf_used, verbosity, i;
Bool notrace_until_done, do_self_check;
UInt notrace_until_limit =3D 0;
@@ -672,6 +676,7 @@
vex_arch, &vex_archinfo,
(UChar*)ULong_to_Ptr(orig_addr),=20
(Addr64)orig_addr,=20
+ (Addr64)orig_addr_noredir,=20
chase_into_ok,
&vge,
tmpbuf, N_TMPBUF, &tmpbuf_used,
@@ -711,10 +716,10 @@
// If debugging, don't do anything with the translated block; we
// only did this for the debugging output produced along the way.
if (!debugging_translation) {
- // Note that we use orig_addr0, not orig_addr, which might have be=
en
- // changed by the redirection
+ // Note that we use orig_addr_noredir, not orig_addr, which
+ // might have been changed by the redirection
VG_(add_to_transtab)( &vge,
- orig_addr0,
+ orig_addr_noredir,
(Addr)(&tmpbuf[0]),=20
tmpbuf_used,
do_self_check );
Modified: trunk/coregrind/m_transtab.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_transtab.c 2005-10-18 02:30:42 UTC (rev 4942)
+++ trunk/coregrind/m_transtab.c 2005-10-18 12:04:18 UTC (rev 4943)
@@ -688,6 +688,7 @@
/* Tell the tool too. */
if (VG_(needs).basic_block_discards) {
VG_TDICT_CALL( tool_discard_basic_block_info,
+ sec->tt[i].entry,
sec->tt[i].vge );
}
} else {
@@ -1011,6 +1012,7 @@
/* Tell the tool too. */
if (VG_(needs).basic_block_discards) {
VG_TDICT_CALL( tool_discard_basic_block_info,
+ tte->entry,
tte->vge );
}
}
Modified: trunk/coregrind/pub_core_tooliface.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/pub_core_tooliface.h 2005-10-18 02:30:42 UTC (rev 494=
2)
+++ trunk/coregrind/pub_core_tooliface.h 2005-10-18 12:04:18 UTC (rev 494=
3)
@@ -104,7 +104,8 @@
// Basic functions
void (*tool_pre_clo_init) (void);
void (*tool_post_clo_init)(void);
- IRBB* (*tool_instrument) (IRBB*, VexGuestLayout*, IRType, IRType);
+ IRBB* (*tool_instrument) (IRBB*, VexGuestLayout*,=20
+ Addr64, VexGuestExtents*, IRType, IRType)=
;
void (*tool_fini) (Int);
=20
// VG_(needs).core_errors
@@ -121,7 +122,7 @@
void (*tool_print_extra_suppression_info)(Error*);
=20
// VG_(needs).basic_block_discards
- void (*tool_discard_basic_block_info)(VexGuestExtents);
+ void (*tool_discard_basic_block_info)(Addr64, VexGuestExtents);
=20
// VG_(needs).command_line_options
Bool (*tool_process_cmd_line_option)(Char*);
Modified: trunk/helgrind/hg_main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/helgrind/hg_main.c 2005-10-18 02:30:42 UTC (rev 4942)
+++ trunk/helgrind/hg_main.c 2005-10-18 12:04:18 UTC (rev 4943)
@@ -2297,8 +2297,10 @@
return cb;
}
#endif
-static IRBB* hg_instrument ( IRBB* bb_in, VexGuestLayout* layout,=20
- IRType gWordTy, IRType hWordTy )
+static
+IRBB* hg_instrument ( IRBB* bb_in, VexGuestLayout* layout,=20
+ Addr64 orig_addr_noredir, VexGuestExtents* vge,
+ IRType gWordTy, IRType hWordTy )
{
tl_assert(0); // Need to convert to Vex
}
Modified: trunk/include/pub_tool_tooliface.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/include/pub_tool_tooliface.h 2005-10-18 02:30:42 UTC (rev 4942)
+++ trunk/include/pub_tool_tooliface.h 2005-10-18 12:04:18 UTC (rev 4943)
@@ -78,10 +78,14 @@
// processing.
void (*post_clo_init)(void),
=20
- // Instrument a basic block. Must be a true function, ie. the same i=
nput
- // always results in the same output, because basic blocks can be
- // retranslated. Unless you're doing something really strange...
- IRBB* (*instrument)(IRBB* bb_in, VexGuestLayout* layout,=20
+ // Instrument a basic block. Must be a true function, ie. the same
+ // input always results in the same output, because basic blocks
+ // can be retranslated. Unless you're doing something really
+ // strange... Note that orig_addr_noredir is not necessarily the
+ // same as the address of the first instruction in the IR, due to
+ // function redirection.
+ IRBB* (*instrument)(IRBB* bb_in, VexGuestLayout* layout,
+ Addr64 orig_addr_noredir, VexGuestExtents* vge,=20
IRType gWordTy, IRType hWordTy ),
=20
// Finish up, print out any results, etc. `exitcode' is program's ex=
it
@@ -195,19 +199,21 @@
reused for new translations. */
extern void VG_(needs_basic_block_discards) (
// Discard any information that pertains to specific translations
- // or instructions within the address range given. The "extents"
- // arg can be used in two ways.
- // - If info is being stored at a per-translation level, the first
- // address in the extents can be used to identify which translation
- // is being discarded. Each translation will be discarded exactly
- // once.
+ // or instructions within the address range given. There are two
+ // possible approaches.
+ // - If info is being stored at a per-translation level, use orig_add=
r
+ // to identify which translation is being discarded. Each translat=
ion
+ // will be discarded exactly once.
+ // This orig_addr will match the orig_addr which was passed to
+ // to instrument() when this translation was made. Note that orig_=
addr
+ // won't necessarily be the same as the first address in "extents".
// - If info is being stored at a per-instruction level, you can get
// the address range(s) being discarded by stepping through "extent=
s".
// Note that any single instruction may belong to more than one
// translation, and so could be covered by the "extents" of more th=
an
// one call to this function.
// Doing it the first way (as eg. Cachegrind does) is probably easier=
.
- void (*discard_basic_block_info)(VexGuestExtents vge)
+ void (*discard_basic_block_info)(Addr64 orig_addr, VexGuestExtents ex=
tents)
);
=20
/* Tool defines its own command line options? */
Modified: trunk/lackey/lk_main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/lackey/lk_main.c 2005-10-18 02:30:42 UTC (rev 4942)
+++ trunk/lackey/lk_main.c 2005-10-18 12:04:18 UTC (rev 4943)
@@ -124,8 +124,10 @@
Which gives us the right answer. And just to avoid two C calls, we f=
old
the basic-block-beginning call in with add_one_BB(). Phew.
*/=20
-static IRBB* lk_instrument(IRBB* bb_in, VexGuestLayout* layout,=20
- IRType gWordTy, IRType hWordTy )
+static
+IRBB* lk_instrument( IRBB* bb_in, VexGuestLayout* layout,=20
+ Addr64 orig_addr_noredir, VexGuestExtents* vge,
+ IRType gWordTy, IRType hWordTy )
{
IRDirty* di;
Int i;
Modified: trunk/massif/ms_main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/massif/ms_main.c 2005-10-18 02:30:42 UTC (rev 4942)
+++ trunk/massif/ms_main.c 2005-10-18 12:04:18 UTC (rev 4943)
@@ -1148,8 +1148,10 @@
/*--- Instrumentation ---*/
/*------------------------------------------------------------*/
=20
-static IRBB* ms_instrument ( IRBB* bb_in, VexGuestLayout* layout,=20
- IRType gWordTy, IRType hWordTy )
+static
+IRBB* ms_instrument ( IRBB* bb_in, VexGuestLayout* layout,=20
+ Addr64 orig_addr_noredir, VexGuestExtents* vge,
+ IRType gWordTy, IRType hWordTy )
{
/* XXX Will Massif work when gWordTy !=3D hWordTy ? */
return bb_in;
Modified: trunk/memcheck/mc_include.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/memcheck/mc_include.h 2005-10-18 02:30:42 UTC (rev 4942)
+++ trunk/memcheck/mc_include.h 2005-10-18 12:04:18 UTC (rev 4943)
@@ -79,10 +79,11 @@
extern void MC_(helperc_MAKE_STACK_UNINIT) ( Addr base, UWord len );
=20
/* Functions defined in mc_translate.c */
-extern IRBB* MC_(instrument) ( IRBB* bb_in, VexGuestLayout* layout,
- IRType gWordTy, IRType hWordTy );
+extern
+IRBB* MC_(instrument) ( IRBB* bb_in, VexGuestLayout* layout,=20
+ Addr64 orig_addr_noredir, VexGuestExtents* vge,
+ IRType gWordTy, IRType hWordTy );
=20
-
#endif /* ndef __MC_INCLUDE_H */
=20
/*--------------------------------------------------------------------*/
Modified: trunk/memcheck/mc_translate.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/memcheck/mc_translate.c 2005-10-18 02:30:42 UTC (rev 4942)
+++ trunk/memcheck/mc_translate.c 2005-10-18 12:04:18 UTC (rev 4943)
@@ -2810,6 +2810,7 @@
=20
=20
IRBB* MC_(instrument) ( IRBB* bb_in, VexGuestLayout* layout,=20
+ Addr64 orig_addr_noredir, VexGuestExtents* vge,
IRType gWordTy, IRType hWordTy )
{
Bool verboze =3D False; //True;=20
Modified: trunk/none/nl_main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/none/nl_main.c 2005-10-18 02:30:42 UTC (rev 4942)
+++ trunk/none/nl_main.c 2005-10-18 12:04:18 UTC (rev 4943)
@@ -36,8 +36,10 @@
{
}
=20
-static IRBB* nl_instrument(IRBB* bb, VexGuestLayout* layout,=20
- IRType gWordTy, IRType hWordTy)
+static
+IRBB* nl_instrument(IRBB* bb, VexGuestLayout* layout,=20
+ Addr64 orig_addr_noredir, VexGuestExtents* vge,
+ IRType gWordTy, IRType hWordTy)
{
return bb;
}
|