|
From: <sv...@va...> - 2005-12-27 16:40:42
|
Author: sewardj
Date: 2005-12-27 16:40:35 +0000 (Tue, 27 Dec 2005)
New Revision: 5453
Log:
Redesign and simplify function-wrapping support.
Modified:
branches/FNWRAP/coregrind/m_demangle/demangle.c
branches/FNWRAP/coregrind/m_redir.c
branches/FNWRAP/coregrind/m_replacemalloc/vg_replace_malloc.c
branches/FNWRAP/coregrind/m_scheduler/scheduler.c
branches/FNWRAP/coregrind/m_translate.c
branches/FNWRAP/coregrind/pub_core_demangle.h
branches/FNWRAP/coregrind/pub_core_redir.h
branches/FNWRAP/include/pub_tool_redir.h
branches/FNWRAP/include/valgrind.h
branches/FNWRAP/memcheck/mac_replace_strmem.c
Modified: branches/FNWRAP/coregrind/m_demangle/demangle.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
--- branches/FNWRAP/coregrind/m_demangle/demangle.c 2005-12-27 15:02:50 U=
TC (rev 5452)
+++ branches/FNWRAP/coregrind/m_demangle/demangle.c 2005-12-27 16:40:35 U=
TC (rev 5453)
@@ -72,7 +72,7 @@
Z-demangling (with NULL soname buffer, since we're not
interested in that). */
if (VG_(maybe_Z_demangle)( orig, NULL,0,/*soname*/
- z_demangled, N_ZBUF)) {
+ z_demangled, N_ZBUF, NULL)) {
orig =3D z_demangled;
}
=20
@@ -113,7 +113,8 @@
=20
Bool VG_(maybe_Z_demangle) ( const HChar* sym,=20
/*OUT*/HChar* so, Int soLen,
- /*OUT*/HChar* fn, Int fnLen )
+ /*OUT*/HChar* fn, Int fnLen,
+ /*OUT*/Bool* isWrap )
{
# define EMITSO(ch) \
do { \
@@ -147,7 +148,7 @@
valid =3D sym[0] =3D=3D '_'
&& sym[1] =3D=3D 'v'
&& sym[2] =3D=3D 'g'
- && (sym[3] =3D=3D 'r' || sym[3] =3D=3D 'n')
+ && (sym[3] =3D=3D 'r' || sym[3] =3D=3D 'w' || sym[3] =3D=3D '=
n')
&& sym[4] =3D=3D 'Z'
&& (sym[5] =3D=3D 'Z' || sym[5] =3D=3D 'U')
&& sym[6] =3D=3D '_';
@@ -156,6 +157,9 @@
=20
fn_is_encoded =3D sym[5] =3D=3D 'Z';
=20
+ if (isWrap)
+ *isWrap =3D sym[3] =3D=3D 'w';
+
/* Now scan the Z-encoded soname. */
i =3D 7;
while (True) {
@@ -244,12 +248,12 @@
=20
if (error) {
/* Something's wrong. Give up. */
- VG_(message)(Vg_UserMsg, "m_redir: error demangling: %s", sym);
+ VG_(message)(Vg_UserMsg, "m_demangle: error Z-demangling: %s", sym=
);
return False;
}
if (oflow) {
/* It didn't fit. Give up. */
- VG_(message)(Vg_UserMsg, "m_debuginfo: oflow demangling: %s", sym)=
;
+ VG_(message)(Vg_UserMsg, "m_demangle: oflow Z-demangling: %s", sym=
);
return False;
}
=20
Modified: branches/FNWRAP/coregrind/m_redir.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
--- branches/FNWRAP/coregrind/m_redir.c 2005-12-27 15:02:50 UTC (rev 5452=
)
+++ branches/FNWRAP/coregrind/m_redir.c 2005-12-27 16:40:35 UTC (rev 5453=
)
@@ -98,7 +98,7 @@
/* The redirector holds two pieces of state:
=20
Specs - a set of (soname pattern, fnname pattern) -> redir addr
- Active - a set of orig addr -> redir addr
+ Active - a set of orig addr -> (bool, redir addr)
=20
Active is the currently active set of bindings that the translator
consults. Specs is the current set of specifications as harvested
@@ -210,6 +210,7 @@
HChar* from_sopatt; /* from soname pattern */
HChar* from_fnpatt; /* from fnname pattern */
Addr to_addr; /* where redirecting to */
+ Bool isWrap; /* wrap or replacement? */
Bool mark; /* transient temporary used during matching */
}
Spec;
@@ -249,6 +250,7 @@
Addr to_addr; /* where redirecting to */
TopSpec* parent_spec; /* the TopSpec which supplied the Spec */
TopSpec* parent_sym; /* the TopSpec which supplied the symbol */
+ Bool isWrap; /* wrap or replacement? */
}
Active;
=20
@@ -296,7 +298,7 @@
=20
void VG_(redir_notify_new_SegInfo)( SegInfo* newsi )
{
- Bool ok;
+ Bool ok, isWrap;
Int i, nsyms;
Spec* specList;
Spec* spec;
@@ -323,7 +325,7 @@
for (i =3D 0; i < nsyms; i++) {
VG_(seginfo_syms_getidx)( newsi, i, &sym_addr, NULL, &sym_name );
ok =3D VG_(maybe_Z_demangle)( sym_name, demangled_sopatt, N_DEMANG=
LED,
- demangled_fnpatt, N_DEMANGLED );
+ demangled_fnpatt, N_DEMANGLED, &isWrap );
if (!ok) {
/* It's not a full-scale redirect, but perhaps it is a load-not=
ify
fn? Let the load-notify department see it. */
@@ -337,6 +339,7 @@
vg_assert(spec->from_sopatt);
vg_assert(spec->from_fnpatt);
spec->to_addr =3D sym_addr;
+ spec->isWrap =3D isWrap;
/* check we're not adding manifestly stupid destinations */
vg_assert(is_plausible_guest_addr(sym_addr));
spec->next =3D specList;
@@ -447,6 +450,7 @@
act.to_addr =3D sp->to_addr;
act.parent_spec =3D parent_spec;
act.parent_sym =3D parent_sym;
+ act.isWrap =3D sp->isWrap;
maybe_add_active( act );
}
}
@@ -619,13 +623,15 @@
/* This is the crucial redirection function. It answers the question:
should this code address be redirected somewhere else? It's used
just before translating a basic block. */
-Addr VG_(redir_do_lookup) ( Addr orig )
+Addr VG_(redir_do_lookup) ( Addr orig, Bool* isWrap )
{
Active* r =3D VG_(OSet_Lookup)(activeSet, &orig);
if (r =3D=3D NULL)
return orig;
=20
vg_assert(r->to_addr !=3D 0);
+ if (isWrap)
+ *isWrap =3D r->isWrap;
return r->to_addr;
}
=20
@@ -644,6 +650,7 @@
act.to_addr =3D to;
act.parent_spec =3D NULL;
act.parent_sym =3D NULL;
+ act.isWrap =3D False;
maybe_add_active( act );
}
=20
@@ -676,6 +683,7 @@
spec->from_sopatt =3D sopatt;
spec->from_fnpatt =3D fnpatt;
spec->to_addr =3D to_addr;
+ spec->isWrap =3D False;
spec->mark =3D False; /* not significant */
=20
spec->next =3D topSpecs->specs;
@@ -814,9 +822,10 @@
static void show_spec ( HChar* left, Spec* spec )
{
VG_(message)(Vg_DebugMsg,=20
- "%s%18s %30s -> 0x%08llx",
+ "%s%18s %30s %s-> 0x%08llx",
left,
spec->from_sopatt, spec->from_fnpatt,
+ spec->isWrap ? "W" : "R",
(ULong)spec->to_addr );
}
=20
@@ -831,9 +840,10 @@
ok =3D VG_(get_fnname_w_offset)(act->to_addr, name2, 64);
if (!ok) VG_(strcpy)(name2, "???");
=20
- VG_(message)(Vg_DebugMsg, "%s0x%08llx (%10s) -> 0x%08llx %s",=20
+ VG_(message)(Vg_DebugMsg, "%s0x%08llx (%10s) %s-> 0x%08llx %s",=20
left,=20
(ULong)act->from_addr, name1,
+ act->isWrap ? "W" : "R",
(ULong)act->to_addr, name2 );
}
=20
Modified: branches/FNWRAP/coregrind/m_replacemalloc/vg_replace_malloc.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
--- branches/FNWRAP/coregrind/m_replacemalloc/vg_replace_malloc.c 2005-12=
-27 15:02:50 UTC (rev 5452)
+++ branches/FNWRAP/coregrind/m_replacemalloc/vg_replace_malloc.c 2005-12=
-27 16:40:35 UTC (rev 5453)
@@ -103,8 +103,8 @@
*/
#define ALLOC_or_NULL(soname, fnname, vg_replacement) \
\
- void* VG_REDIRECT_FUNCTION_ZU(soname,fnname) (SizeT n); \
- void* VG_REDIRECT_FUNCTION_ZU(soname,fnname) (SizeT n) \
+ void* VG_REPLACE_FUNCTION_ZU(soname,fnname) (SizeT n); \
+ void* VG_REPLACE_FUNCTION_ZU(soname,fnname) (SizeT n) \
{ \
void* v; \
\
@@ -123,8 +123,8 @@
*/
#define ALLOC_or_BOMB(soname, fnname, vg_replacement) \
\
- void* VG_REDIRECT_FUNCTION_ZU(soname,fnname) (SizeT n); \
- void* VG_REDIRECT_FUNCTION_ZU(soname,fnname) (SizeT n) \
+ void* VG_REPLACE_FUNCTION_ZU(soname,fnname) (SizeT n); \
+ void* VG_REPLACE_FUNCTION_ZU(soname,fnname) (SizeT n) \
{ \
void* v; \
\
@@ -221,8 +221,8 @@
*/
#define FREE(soname, fnname, vg_replacement) \
\
- void VG_REDIRECT_FUNCTION_ZU(soname,fnname) (void *p); \
- void VG_REDIRECT_FUNCTION_ZU(soname,fnname) (void *p) \
+ void VG_REPLACE_FUNCTION_ZU(soname,fnname) (void *p); \
+ void VG_REPLACE_FUNCTION_ZU(soname,fnname) (void *p) \
{ \
MALLOC_TRACE(#vg_replacement "(%p)", p ); \
if (p =3D=3D NULL) \
@@ -264,8 +264,8 @@
=20
#define CALLOC(soname, fnname) \
\
- void* VG_REDIRECT_FUNCTION_ZU(soname,fnname) ( SizeT nmemb, SizeT siz=
e ); \
- void* VG_REDIRECT_FUNCTION_ZU(soname,fnname) ( SizeT nmemb, SizeT siz=
e ) \
+ void* VG_REPLACE_FUNCTION_ZU(soname,fnname) ( SizeT nmemb, SizeT size=
); \
+ void* VG_REPLACE_FUNCTION_ZU(soname,fnname) ( SizeT nmemb, SizeT size=
) \
{ \
void* v; \
\
@@ -282,8 +282,8 @@
=20
#define REALLOC(soname, fnname) \
\
- void* VG_REDIRECT_FUNCTION_ZU(soname,fnname) ( void* ptrV, SizeT new_=
size );\
- void* VG_REDIRECT_FUNCTION_ZU(soname,fnname) ( void* ptrV, SizeT new_=
size ) \
+ void* VG_REPLACE_FUNCTION_ZU(soname,fnname) ( void* ptrV, SizeT new_s=
ize );\
+ void* VG_REPLACE_FUNCTION_ZU(soname,fnname) ( void* ptrV, SizeT new_s=
ize ) \
{ \
void* v; \
\
@@ -292,9 +292,9 @@
if (ptrV =3D=3D NULL) \
/* We need to call a malloc-like function; so let's use \
one which we know exists. */ \
- return VG_REDIRECT_FUNCTION_ZU(libcZdsoZa,malloc) (new_size); \
+ return VG_REPLACE_FUNCTION_ZU(libcZdsoZa,malloc) (new_size); \
if (new_size <=3D 0) { \
- VG_REDIRECT_FUNCTION_ZU(libcZdsoZa,free)(ptrV); \
+ VG_REPLACE_FUNCTION_ZU(libcZdsoZa,free)(ptrV); \
MALLOC_TRACE(" =3D 0"); \
return NULL; \
} \
@@ -309,8 +309,8 @@
=20
#define MEMALIGN(soname, fnname) \
\
- void* VG_REDIRECT_FUNCTION_ZU(soname,fnname) ( SizeT alignment, SizeT=
n ); \
- void* VG_REDIRECT_FUNCTION_ZU(soname,fnname) ( SizeT alignment, SizeT=
n ) \
+ void* VG_REPLACE_FUNCTION_ZU(soname,fnname) ( SizeT alignment, SizeT =
n ); \
+ void* VG_REPLACE_FUNCTION_ZU(soname,fnname) ( SizeT alignment, SizeT =
n ) \
{ \
void* v; \
\
@@ -335,10 +335,10 @@
=20
#define VALLOC(soname, fnname) \
\
- void* VG_REDIRECT_FUNCTION_ZU(soname,fnname) ( SizeT size ); \
- void* VG_REDIRECT_FUNCTION_ZU(soname,fnname) ( SizeT size ) \
+ void* VG_REPLACE_FUNCTION_ZU(soname,fnname) ( SizeT size ); \
+ void* VG_REPLACE_FUNCTION_ZU(soname,fnname) ( SizeT size ) \
{ \
- return VG_REDIRECT_FUNCTION_ZU(libcZdsoZa,memalign)(VKI_PAGE_SIZE,=
size); \
+ return VG_REPLACE_FUNCTION_ZU(libcZdsoZa,memalign)(VKI_PAGE_SIZE, =
size); \
}
=20
VALLOC(m_libc_dot_so_star, valloc);
@@ -348,8 +348,8 @@
=20
#define MALLOPT(soname, fnname) \
\
- int VG_REDIRECT_FUNCTION_ZU(soname, fnname) ( int cmd, int value ); \
- int VG_REDIRECT_FUNCTION_ZU(soname, fnname) ( int cmd, int value ) \
+ int VG_REPLACE_FUNCTION_ZU(soname, fnname) ( int cmd, int value ); \
+ int VG_REPLACE_FUNCTION_ZU(soname, fnname) ( int cmd, int value ) \
{ \
/* In glibc-2.2.4, 1 denotes a successful return value for \
mallopt */ \
@@ -361,9 +361,9 @@
=20
#define POSIX_MEMALIGN(soname, fnname) \
\
- int VG_REDIRECT_FUNCTION_ZU(soname, fnname) ( void **memptr, \
+ int VG_REPLACE_FUNCTION_ZU(soname, fnname) ( void **memptr, \
SizeT alignment, SizeT =
size ); \
- int VG_REDIRECT_FUNCTION_ZU(soname, fnname) ( void **memptr, \
+ int VG_REPLACE_FUNCTION_ZU(soname, fnname) ( void **memptr, \
SizeT alignment, SizeT =
size ) \
{ \
void *mem; \
@@ -374,7 +374,7 @@
|| (alignment & (alignment - 1)) !=3D 0) \
return VKI_EINVAL; \
\
- mem =3D VG_REDIRECT_FUNCTION_ZU(libcZdsoZa,memalign)(alignment, si=
ze); \
+ mem =3D VG_REPLACE_FUNCTION_ZU(libcZdsoZa,memalign)(alignment, siz=
e); \
\
if (mem !=3D NULL) { \
*memptr =3D mem; \
@@ -389,8 +389,8 @@
=20
#define MALLOC_USABLE_SIZE(soname, fnname) \
\
- int VG_REDIRECT_FUNCTION_ZU(soname, fnname) ( void* p ); \
- int VG_REDIRECT_FUNCTION_ZU(soname, fnname) ( void* p ) \
+ int VG_REPLACE_FUNCTION_ZU(soname, fnname) ( void* p ); \
+ int VG_REPLACE_FUNCTION_ZU(soname, fnname) ( void* p ) \
{ \
SizeT pszB; \
\
@@ -420,8 +420,8 @@
=20
#define PANIC(soname, fnname) \
\
- void VG_REDIRECT_FUNCTION_ZU(soname, fnname) ( void ); \
- void VG_REDIRECT_FUNCTION_ZU(soname, fnname) ( void ) \
+ void VG_REPLACE_FUNCTION_ZU(soname, fnname) ( void ); \
+ void VG_REPLACE_FUNCTION_ZU(soname, fnname) ( void ) \
{ \
panic(#fnname); \
}
@@ -437,8 +437,8 @@
// doesn't know that the call to mallinfo fills in mi.
#define MALLINFO(soname, fnname) \
\
- struct vg_mallinfo VG_REDIRECT_FUNCTION_ZU(soname, fnname) ( void ); =
\
- struct vg_mallinfo VG_REDIRECT_FUNCTION_ZU(soname, fnname) ( void ) =
\
+ struct vg_mallinfo VG_REPLACE_FUNCTION_ZU(soname, fnname) ( void ); \
+ struct vg_mallinfo VG_REPLACE_FUNCTION_ZU(soname, fnname) ( void ) \
{ \
static struct vg_mallinfo mi; \
MALLOC_TRACE("mallinfo()"); \
Modified: branches/FNWRAP/coregrind/m_scheduler/scheduler.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
--- branches/FNWRAP/coregrind/m_scheduler/scheduler.c 2005-12-27 15:02:50=
UTC (rev 5452)
+++ branches/FNWRAP/coregrind/m_scheduler/scheduler.c 2005-12-27 16:40:35=
UTC (rev 5453)
@@ -1099,54 +1099,9 @@
VG_(printf)("req no =3D 0x%llx, arg =3D %p\n", (ULong)req_no, arg)=
;
switch (req_no) {
=20
- case VG_USERREQ__PUSH_NRADDR: {
- Addr nraddr =3D arg[1];
- UWord do_check =3D arg[2];
-
- if (do_check) {
-
- /* This is the normal (safe) case. */
- switch (GET_CLIENT_NRFLAG(tid)) {
- case 0:
- SET_CLIENT_NRFLAG(tid, 1);
- SET_CLIENT_NRADDR(tid, nraddr);
- SET_CLREQ_RETVAL(tid, 0);
- break;
- case 1:=20
- case 2:
- /* The 1-entry stack is full, so we must fail
- (return 1). */
- SET_CLREQ_RETVAL(tid, 1);
- break;
- default:
- vg_assert2(0, "VG_USERREQ__PUSH_NRADDR(checked):"
- " bogus value");
- }
-
- } else {
-
- /* This is the not-normal (unsafe) case. */
- switch (GET_CLIENT_NRFLAG(tid)) {
- case 0:
- SET_CLIENT_NRFLAG(tid, 1);
- SET_CLIENT_NRADDR(tid, nraddr);
- break;
- case 1:=20
- SET_CLIENT_NRFLAG(tid, 2);
- break;
- case 2:
- break;
- default:
- vg_assert2(0, "VG_USERREQ__PUSH_NRADDR(***unchecked***=
):"
- " bogus value");
- }
- /* Unchecked case always succeeds */
- SET_CLREQ_RETVAL(tid, 0);
-
- }
-
+ case VG_USERREQ__GET_NRADDR:
+ SET_CLREQ_RETVAL(tid, VG_(threads)[tid].arch.vex.guest_NRADDR);
break;
- }
=20
case VG_USERREQ__CLIENT_CALL0: {
UWord (*f)(ThreadId) =3D (void*)arg[1];
Modified: branches/FNWRAP/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
--- branches/FNWRAP/coregrind/m_translate.c 2005-12-27 15:02:50 UTC (rev =
5452)
+++ branches/FNWRAP/coregrind/m_translate.c 2005-12-27 16:40:35 UTC (rev =
5453)
@@ -426,7 +426,7 @@
}
=20
/* Destination is redirected? */
- if (addr !=3D VG_(redir_do_lookup)(addr))
+ if (addr !=3D VG_(redir_do_lookup)(addr, NULL))
goto dontchase;
=20
/* well, ok then. go on and chase. */
@@ -453,7 +453,8 @@
{
Addr64 redir, orig_addr_noredir =3D orig_addr;
Int tmpbuf_used, verbosity, i;
- Bool notrace_until_done, do_self_check, did_redirect;
+ Bool notrace_until_done, do_self_check;
+ Bool did_redirect, isWrap;
UInt notrace_until_limit =3D 0;
NSegment* seg;
VexArch vex_arch;
@@ -478,14 +479,17 @@
=20
/* Look in the code redirect table to see if we should
translate an alternative address for orig_addr. */
+ isWrap =3D False;
if (allow_redirection) {
- redir =3D VG_(redir_do_lookup)(orig_addr);
+ redir =3D VG_(redir_do_lookup)(orig_addr, &isWrap);
did_redirect =3D redir !=3D orig_addr;
} else {
redir =3D orig_addr;
did_redirect =3D False;
}
=20
+ if (did_redirect =3D=3D False) vg_assert(isWrap =3D=3D False);
+
if (redir !=3D orig_addr=20
&& (VG_(clo_verbosity) >=3D 2 || VG_(clo_trace_redir))) {
Bool ok;
@@ -605,9 +609,9 @@
NULL,
verbosity,
/* If this translation started at a redirected address,
- then we need to ask the JIT to put in the
- guest_NOREDIR preamble. */
- did_redirect =20
+ then we need to ask the JIT to generate code to put the
+ non-redirected guest address into guest_NRADDR. */
+ isWrap =20
);
=20
vg_assert(tres =3D=3D VexTransOK);
Modified: branches/FNWRAP/coregrind/pub_core_demangle.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
--- branches/FNWRAP/coregrind/pub_core_demangle.h 2005-12-27 15:02:50 UTC=
(rev 5452)
+++ branches/FNWRAP/coregrind/pub_core_demangle.h 2005-12-27 16:40:35 UTC=
(rev 5453)
@@ -56,9 +56,9 @@
extern=20
Bool VG_(maybe_Z_demangle) ( const HChar* sym,=20
/*OUT*/HChar* so, Int soLen,
- /*OUT*/HChar* fn, Int fnLen );
+ /*OUT*/HChar* fn, Int fnLen,
+ /*OUT*/Bool* isWrap );
=20
-
#endif // __PUB_CORE_DEMANGLE_H
=20
/*--------------------------------------------------------------------*/
Modified: branches/FNWRAP/coregrind/pub_core_redir.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
--- branches/FNWRAP/coregrind/pub_core_redir.h 2005-12-27 15:02:50 UTC (r=
ev 5452)
+++ branches/FNWRAP/coregrind/pub_core_redir.h 2005-12-27 16:40:35 UTC (r=
ev 5453)
@@ -65,8 +65,10 @@
=20
/* This is the crucial redirection function. It answers the question:
should this code address be redirected somewhere else? It's used
- just before translating a basic block. */
-extern Addr VG_(redir_do_lookup) ( Addr orig );
+ just before translating a basic block. If a redir is found,
+ *isWrap allows to distinguish wrap- from replace- style
+ redirections. */
+extern Addr VG_(redir_do_lookup) ( Addr orig, Bool* isWrap );
=20
=20
//--------------------------------------------------------------------
Modified: branches/FNWRAP/include/pub_tool_redir.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
--- branches/FNWRAP/include/pub_tool_redir.h 2005-12-27 15:02:50 UTC (rev=
5452)
+++ branches/FNWRAP/include/pub_tool_redir.h 2005-12-27 16:40:35 UTC (rev=
5453)
@@ -31,12 +31,32 @@
#ifndef __PUB_TOOL_REDIR_H
#define __PUB_TOOL_REDIR_H
=20
-/* The following macros facilitate function redirection (redirects).
+/* The following macros facilitate function replacement and wrapping.
=20
- The general idea is: you can write a function like this:
+ Function wrapping and function replacement are similar but not
+ identical.
=20
+ A replacement for some function F simply diverts all calls to F
+ to the stated replacement. There is no way to get back to F itself
+ from the replacement.
+
+ A wrapper for a function F causes all calls to F to instead go to
+ the wrapper. However, from inside the wrapper, it is possible
+ (with some difficulty) to get to F itself.
+
+ You may notice that replacement is a special case of wrapping, in
+ which the call to the original is omitted. For implementation
+ reasons, though, it is important to use the following macros
+ correctly: in particular, if you want to write a replacement, make
+ sure you use the VG_REPLACE_FN_ macros and not the VG_WRAP_FN_
+ macros.
+
+ Replacement
+ ~~~~~~~~~~~
+ To write a replacement function, do this:
+
ret_type=20
- VG_REDIRECT_FUNCTION_ZU(zEncodedSoname,fnname) ( .. args .. )
+ VG_REPLACE_FUNCTION_ZU(zEncodedSoname,fnname) ( .. args .. )
{
... body ...
}
@@ -51,7 +71,7 @@
It is also possible to write
=20
ret_type=20
- VG_REDIRECT_FUNCTION_ZZ(zEncodedSoname,zEncodedFnname) ( .. args .=
. )
+ VG_REPLACE_FUNCTION_ZZ(zEncodedSoname,zEncodedFnname) ( .. args ..=
)
{
... body ...
}
@@ -92,6 +112,18 @@
underscores, since the intercept-handlers in m_redir.c detect the
end of the soname by looking for the first trailing underscore.
=20
+ Wrapping
+ ~~~~~~~~
+ This is identical to replacement, except that you should use the
+ macro names
+
+ VG_WRAP_FUNCTION_ZU
+ VG_WRAP_FUNCTION_ZZ
+
+ instead.
+
+ Z-encoding
+ ~~~~~~~~~~
Z-encoding details: the scheme is like GHC's. It is just about
readable enough to make a preprocessor unnecessary. First the
"_vgrZU_" or "_vgrZZ_" prefix is added, and then the following
@@ -112,11 +144,14 @@
=20
/* If you change these, the code in VG_(maybe_Z_demangle) needs to be
changed accordingly. NOTE: duplicates
- I_REPLACE_SONAME_FNNAME_Z{U,Z} in valgrind.h. */
-#define VG_REDIRECT_FUNCTION_ZU(soname,fnname) _vgrZU_##soname##_##fnnam=
e
-#define VG_REDIRECT_FUNCTION_ZZ(soname,fnname) _vgrZZ_##soname##_##fnnam=
e
+ I_{WRAP,REPLACE}_SONAME_FNNAME_Z{U,Z} in valgrind.h. */
=20
+#define VG_REPLACE_FUNCTION_ZU(soname,fnname) _vgrZU_##soname##_##fnname
+#define VG_REPLACE_FUNCTION_ZZ(soname,fnname) _vgrZZ_##soname##_##fnname
=20
+#define VG_WRAP_FUNCTION_ZU(soname,fnname) _vgwZU_##soname##_##fnname
+#define VG_WRAP_FUNCTION_ZZ(soname,fnname) _vgwZZ_##soname##_##fnname
+
#endif // __PUB_TOOL_REDIR_H
=20
/*--------------------------------------------------------------------*/
Modified: branches/FNWRAP/include/valgrind.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
--- branches/FNWRAP/include/valgrind.h 2005-12-27 15:02:50 UTC (rev 5452)
+++ branches/FNWRAP/include/valgrind.h 2005-12-27 16:40:35 UTC (rev 5453)
@@ -138,8 +138,8 @@
_zzq_args[4] =3D (volatile unsigned long long)(_zzq_arg4); \
__asm__ volatile("roll $29, %%eax ; roll $3, %%eax\n\t" \
"rorl $27, %%eax ; rorl $5, %%eax\n\t" \
- "roll $13, %%eax ; roll $19, %%eax" \
- : "=3Dd" (_zzq_rlval) \
+ "roll $13, %%eax ; roll $19, %%eax" \
+ : "=3Dd" (_zzq_rlval) \
: "a" (&_zzq_args[0]), "0" (_zzq_default) \
: "cc", "memory" \
); \
@@ -248,7 +248,7 @@
typedef
enum { VG_USERREQ__RUNNING_ON_VALGRIND =3D 0x1001,
VG_USERREQ__DISCARD_TRANSLATIONS =3D 0x1002,
- VG_USERREQ__PUSH_NRADDR =3D 0x1003,
+ VG_USERREQ__GET_NRADDR =3D 0x1003,
=20
/* These allow any function to be called from the
simulated CPU but run on the real CPU.
@@ -315,33 +315,14 @@
that the next entry by this thread into a redirected translation
whose address is on top of the stack will instead to jump to the
non-redirected version. Returns 0 if success, 1 if failure. */
-#define VALGRIND_PUSH_NRADDR(_qzz_addr,_qzz_check) __extension__ \
+#define VALGRIND_GET_NRADDR __extension__ \
({unsigned long _qzz_res; \
VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0/*native result*/, \
- VG_USERREQ__PUSH_NRADDR, \
- _qzz_addr, _qzz_check, 0, 0); \
- _qzz_res; \
+ VG_USERREQ__GET_NRADDR, \
+ 0, 0, 0, 0); \
+ (void*)_qzz_res; \
})
=20
-#define VALGRIND_PUSH_NRADDR_AND_CHECK(_addr) \
- /* Always use this one -- it's safer. */ \
- do { \
- extern void exit(int); \
- long _r =3D VALGRIND_PUSH_NRADDR(_addr,1); \
- if (_r) { \
- VALGRIND_PRINTF_BACKTRACE( \
- "Valgrind: function wrapping: " \
- "redirect stack is full. Program halted."); \
- exit(1); \
- } \
- } while (0)
-#define VALGRIND_PUSH_NRADDR_NO_CHECK(_addr) \
- /* Don't use this. This is a horrible kludge for libpthread. */ \
- do { \
- (void) VALGRIND_PUSH_NRADDR(_addr,0); \
- } while (0)
-
-
#ifdef NVALGRIND
=20
#define VALGRIND_PRINTF(...)
@@ -560,13 +541,13 @@
/* ---------------------------------------------------------- */
=20
/* Use these to write the name of your wrapper. NOTE: duplicates
- VG_REDIRECT_FUNCTION_Z{U,Z} in pub_tool_redir.h. */
+ VG_WRAP_FUNCTION_Z{U,Z} in pub_tool_redir.h. */
=20
-#define I_REPLACE_SONAME_FNNAME_ZU(soname,fnname) \
- _vgrZU_##soname##_##fnname
+#define I_WRAP_SONAME_FNNAME_ZU(soname,fnname) \
+ _vgwZU_##soname##_##fnname
=20
-#define I_REPLACE_SONAME_FNNAME_ZZ(soname,fnname) \
- _vgrZZ_##soname##_##fnname
+#define I_WRAP_SONAME_FNNAME_ZZ(soname,fnname) \
+ _vgwZZ_##soname##_##fnname
=20
/* Use these inside the wrapper, to make calls to the function you are
wrapping. You must use these - calling originals directly will get
@@ -607,4 +588,137 @@
lval =3D _lval; \
} while (0)
=20
+/* Generates a magic call-noredir *%eax "insn" */
+#define __CALL_NOREDIR_EAX \
+ /* "call-noredir *%eax" */ \
+ "rorl $28, %%eax ; rorl $4, %%eax\n\t" \
+ "roll $26, %%eax ; roll $6, %%eax\n\t" \
+ "rorl $12, %%eax ; rorl $20, %%eax\n\t" \
+ "call *%%eax\n\t" \
+
+/* x86: regs trashed by the hidden call. No need to mention eax as
+ gcc can already see that, plus causes gcc to bomb. */
+#define __CALLER_SAVED_REGS /*"eax"*/ "ecx", "edx"
+
+/* Rename _GET_NRADDR to something that is meaningful to people
+ writing wrappers. Used within a wrapper function, gets the address
+ of the original function, which needs to be supplied the CALL_FN_
+ macros below. */
+#define VALGRIND_GET_ORIG_FN VALGRIND_GET_NRADDR
+
+#define CALL_FN_W_v(lval, fnptr) \
+ do { \
+ void* _fnptr =3D (fnptr); \
+ long _argvec[1]; \
+ long _res; \
+ _argvec[0] =3D (long)_fnptr; \
+ __asm__ volatile( \
+ "movl (%%eax), %%eax\n\t" /* target->%eax */ \
+ __CALL_NOREDIR_EAX \
+ : /*out*/ "=3Da" (_res) \
+ : /*in*/ "a" (&_argvec[0]) \
+ : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
+ ); \
+ lval =3D (__typeof__(lval)) _res; \
+ } while (0)
+
+#define CALL_FN_W_W(lval, fnptr, arg1) \
+ do { \
+ void* _fnptr =3D (fnptr); \
+ long _argvec[2]; \
+ long _res; \
+ _argvec[0] =3D (long)_fnptr; \
+ _argvec[1] =3D (long)(arg1); \
+ __asm__ volatile( \
+ "pushl 4(%%eax)\n\t" \
+ "movl (%%eax), %%eax\n\t" /* target->%eax */ \
+ __CALL_NOREDIR_EAX \
+ "addl $4, %%esp\n" \
+ : /*out*/ "=3Da" (_res) \
+ : /*in*/ "a" (&_argvec[0]) \
+ : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
+ ); \
+ lval =3D (__typeof__(lval)) _res; \
+ } while (0)
+
+#define CALL_FN_W_WW(lval, fnptr, arg1,arg2) \
+ do { \
+ void* _fnptr =3D (fnptr); \
+ long _argvec[3]; \
+ long _res; \
+ _argvec[0] =3D (long)_fnptr; \
+ _argvec[1] =3D (long)(arg1); \
+ _argvec[2] =3D (long)(arg2); \
+ __asm__ volatile( \
+ "pushl 8(%%eax)\n\t" \
+ "pushl 4(%%eax)\n\t" \
+ "movl (%%eax), %%eax\n\t" /* target->%eax */ \
+ __CALL_NOREDIR_EAX \
+ "addl $8, %%esp\n" \
+ : /*out*/ "=3Da" (_res) \
+ : /*in*/ "a" (&_argvec[0]) \
+ : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
+ ); \
+ lval =3D (__typeof__(lval)) _res; \
+ } while (0)
+
+#define CALL_FN_W_WWWWW(lval, fnptr, arg1,arg2,arg3,arg4,arg5) \
+ do { \
+ void* _fnptr =3D (fnptr); \
+ long _argvec[6]; \
+ long _res; \
+ _argvec[0] =3D (long)_fnptr; \
+ _argvec[1] =3D (long)(arg1); \
+ _argvec[2] =3D (long)(arg2); \
+ _argvec[3] =3D (long)(arg3); \
+ _argvec[4] =3D (long)(arg4); \
+ _argvec[5] =3D (long)(arg5); \
+ __asm__ volatile( \
+ "pushl 20(%%eax)\n\t" \
+ "pushl 16(%%eax)\n\t" \
+ "pushl 12(%%eax)\n\t" \
+ "pushl 8(%%eax)\n\t" \
+ "pushl 4(%%eax)\n\t" \
+ "movl (%%eax), %%eax\n\t" /* target->%eax */ \
+ __CALL_NOREDIR_EAX \
+ "addl $20, %%esp\n" \
+ : /*out*/ "=3Da" (_res) \
+ : /*in*/ "a" (&_argvec[0]) \
+ : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
+ ); \
+ lval =3D (__typeof__(lval)) _res; \
+ } while (0)
+
+#define CALL_FN_W_WWWWWWW(lval, fnptr, arg1,arg2,arg3,arg4,arg5,arg6,arg=
7) \
+ do { \
+ void* _fnptr =3D (fnptr); \
+ long _argvec[8]; \
+ long _res; \
+ _argvec[0] =3D (long)_fnptr; \
+ _argvec[1] =3D (long)(arg1); \
+ _argvec[2] =3D (long)(arg2); \
+ _argvec[3] =3D (long)(arg3); \
+ _argvec[4] =3D (long)(arg4); \
+ _argvec[5] =3D (long)(arg5); \
+ _argvec[6] =3D (long)(arg6); \
+ _argvec[7] =3D (long)(arg7); \
+ __asm__ volatile( \
+ "pushl 28(%%eax)\n\t" \
+ "pushl 24(%%eax)\n\t" \
+ "pushl 20(%%eax)\n\t" \
+ "pushl 16(%%eax)\n\t" \
+ "pushl 12(%%eax)\n\t" \
+ "pushl 8(%%eax)\n\t" \
+ "pushl 4(%%eax)\n\t" \
+ "movl (%%eax), %%eax\n\t" /* target->%eax */ \
+ __CALL_NOREDIR_EAX \
+ "addl $28, %%esp\n" \
+ : /*out*/ "=3Da" (_res) \
+ : /*in*/ "a" (&_argvec[0]) \
+ : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
+ ); \
+ lval =3D (__typeof__(lval)) _res; \
+ } while (0)
+
+
#endif /* __VALGRIND_H */
Modified: branches/FNWRAP/memcheck/mac_replace_strmem.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
--- branches/FNWRAP/memcheck/mac_replace_strmem.c 2005-12-27 15:02:50 UTC=
(rev 5452)
+++ branches/FNWRAP/memcheck/mac_replace_strmem.c 2005-12-27 16:40:35 UTC=
(rev 5453)
@@ -124,8 +124,8 @@
=20
=20
#define STRRCHR(soname, fnname) \
- char* VG_REDIRECT_FUNCTION_ZU(soname,fnname)( const char* s, int c );=
\
- char* VG_REDIRECT_FUNCTION_ZU(soname,fnname)( const char* s, int c ) =
\
+ char* VG_REPLACE_FUNCTION_ZU(soname,fnname)( const char* s, int c ); =
\
+ char* VG_REPLACE_FUNCTION_ZU(soname,fnname)( const char* s, int c ) \
{ \
UChar ch =3D (UChar)((UInt)c); \
UChar* p =3D (UChar*)s; \
@@ -144,8 +144,8 @@
=20
=20
#define STRCHR(soname, fnname) \
- char* VG_REDIRECT_FUNCTION_ZU(soname,fnname) ( const char* s, int c )=
; \
- char* VG_REDIRECT_FUNCTION_ZU(soname,fnname) ( const char* s, int c )=
\
+ char* VG_REPLACE_FUNCTION_ZU(soname,fnname) ( const char* s, int c );=
\
+ char* VG_REPLACE_FUNCTION_ZU(soname,fnname) ( const char* s, int c ) =
\
{ \
UChar ch =3D (UChar)((UInt)c); \
UChar* p =3D (UChar*)s; \
@@ -166,8 +166,8 @@
=20
=20
#define STRCAT(soname, fnname) \
- char* VG_REDIRECT_FUNCTION_ZU(soname,fnname) ( char* dst, const char*=
src ); \
- char* VG_REDIRECT_FUNCTION_ZU(soname,fnname) ( char* dst, const char*=
src ) \
+ char* VG_REPLACE_FUNCTION_ZU(soname,fnname) ( char* dst, const char* =
src ); \
+ char* VG_REPLACE_FUNCTION_ZU(soname,fnname) ( char* dst, const char* =
src ) \
{ \
const Char* src_orig =3D src; \
Char* dst_orig =3D dst; \
@@ -190,9 +190,9 @@
=20
=20
#define STRNCAT(soname, fnname) \
- char* VG_REDIRECT_FUNCTION_ZU(soname,fnname) \
+ char* VG_REPLACE_FUNCTION_ZU(soname,fnname) \
( char* dst, const char* src, SizeT n ); \
- char* VG_REDIRECT_FUNCTION_ZU(soname,fnname) \
+ char* VG_REPLACE_FUNCTION_ZU(soname,fnname) \
( char* dst, const char* src, SizeT n ) \
{ \
const Char* src_orig =3D src; \
@@ -218,8 +218,8 @@
=20
=20
#define STRNLEN(soname, fnname) \
- SizeT VG_REDIRECT_FUNCTION_ZU(soname,fnname) ( const char* str, SizeT=
n ); \
- SizeT VG_REDIRECT_FUNCTION_ZU(soname,fnname) ( const char* str, SizeT=
n ) \
+ SizeT VG_REPLACE_FUNCTION_ZU(soname,fnname) ( const char* str, SizeT =
n ); \
+ SizeT VG_REPLACE_FUNCTION_ZU(soname,fnname) ( const char* str, SizeT =
n ) \
{ \
SizeT i =3D 0; \
while (i < n && str[i] !=3D 0) i++; \
@@ -234,8 +234,8 @@
// confusing if you aren't expecting it. Other small functions in this =
file
// may also be inline by gcc.
#define STRLEN(soname, fnname) \
- SizeT VG_REDIRECT_FUNCTION_ZU(soname,fnname)( const char* str ); \
- SizeT VG_REDIRECT_FUNCTION_ZU(soname,fnname)( const char* str ) \
+ SizeT VG_REPLACE_FUNCTION_ZU(soname,fnname)( const char* str ); \
+ SizeT VG_REPLACE_FUNCTION_ZU(soname,fnname)( const char* str ) \
{ \
SizeT i =3D 0; \
while (str[i] !=3D 0) i++; \
@@ -248,8 +248,8 @@
=20
=20
#define STRCPY(soname, fnname) \
- char* VG_REDIRECT_FUNCTION_ZU(soname, fnname) ( char* dst, const char=
* src ); \
- char* VG_REDIRECT_FUNCTION_ZU(soname, fnname) ( char* dst, const char=
* src ) \
+ char* VG_REPLACE_FUNCTION_ZU(soname, fnname) ( char* dst, const char*=
src ); \
+ char* VG_REPLACE_FUNCTION_ZU(soname, fnname) ( char* dst, const char*=
src ) \
{ \
const Char* src_orig =3D src; \
Char* dst_orig =3D dst; \
@@ -272,9 +272,9 @@
=20
=20
#define STRNCPY(soname, fnname) \
- char* VG_REDIRECT_FUNCTION_ZU(soname, fnname) \
+ char* VG_REPLACE_FUNCTION_ZU(soname, fnname) \
( char* dst, const char* src, SizeT n ); \
- char* VG_REDIRECT_FUNCTION_ZU(soname, fnname) \
+ char* VG_REPLACE_FUNCTION_ZU(soname, fnname) \
( char* dst, const char* src, SizeT n ) \
{ \
const Char* src_orig =3D src; \
@@ -295,9 +295,9 @@
=20
=20
#define STRNCMP(soname, fnname) \
- int VG_REDIRECT_FUNCTION_ZU(soname,fnname) \
+ int VG_REPLACE_FUNCTION_ZU(soname,fnname) \
( const char* s1, const char* s2, SizeT nmax ); \
- int VG_REDIRECT_FUNCTION_ZU(soname,fnname) \
+ int VG_REPLACE_FUNCTION_ZU(soname,fnname) \
( const char* s1, const char* s2, SizeT nmax ) \
{ \
SizeT n =3D 0; \
@@ -318,9 +318,9 @@
=20
=20
#define STRCMP(soname, fnname) \
- int VG_REDIRECT_FUNCTION_ZU(soname,fnname) \
+ int VG_REPLACE_FUNCTION_ZU(soname,fnname) \
( const char* s1, const char* s2 ); \
- int VG_REDIRECT_FUNCTION_ZU(soname,fnname) \
+ int VG_REPLACE_FUNCTION_ZU(soname,fnname) \
( const char* s1, const char* s2 ) \
{ \
register unsigned char c1; \
@@ -342,8 +342,8 @@
=20
=20
#define MEMCHR(soname, fnname) \
- void* VG_REDIRECT_FUNCTION_ZU(soname,fnname) (const void *s, int c, S=
izeT n); \
- void* VG_REDIRECT_FUNCTION_ZU(soname,fnname) (const void *s, int c, S=
izeT n) \
+ void* VG_REPLACE_FUNCTION_ZU(soname,fnname) (const void *s, int c, Si=
zeT n); \
+ void* VG_REPLACE_FUNCTION_ZU(soname,fnname) (const void *s, int c, Si=
zeT n) \
{ \
SizeT i; \
UChar c0 =3D (UChar)c; \
@@ -357,9 +357,9 @@
=20
=20
#define MEMCPY(soname, fnname) \
- void* VG_REDIRECT_FUNCTION_ZU(soname,fnname) \
+ void* VG_REPLACE_FUNCTION_ZU(soname,fnname) \
( void *dst, const void *src, SizeT len ); \
- void* VG_REDIRECT_FUNCTION_ZU(soname,fnname) \
+ void* VG_REPLACE_FUNCTION_ZU(soname,fnname) \
( void *dst, const void *src, SizeT len ) \
{ \
register char *d; \
@@ -405,9 +405,9 @@
=20
=20
#define MEMCMP(soname, fnname) \
- int VG_REDIRECT_FUNCTION_ZU(soname,fnname) \
+ int VG_REPLACE_FUNCTION_ZU(soname,fnname) \
( const void *s1V, const void *s2V, SizeT n ); \
- int VG_REDIRECT_FUNCTION_ZU(soname,fnname) \
+ int VG_REPLACE_FUNCTION_ZU(soname,fnname) \
( const void *s1V, const void *s2V, SizeT n ) \
{ \
int res; \
@@ -436,8 +436,8 @@
/* Copy SRC to DEST, returning the address of the terminating '\0' in
DEST. (minor variant of strcpy) */
#define STPCPY(soname, fnname) \
- char* VG_REDIRECT_FUNCTION_ZU(soname,fnname) ( char* dst, const char*=
src ); \
- char* VG_REDIRECT_FUNCTION_ZU(soname,fnname) ( char* dst, const char*=
src ) \
+ char* VG_REPLACE_FUNCTION_ZU(soname,fnname) ( char* dst, const char* =
src ); \
+ char* VG_REPLACE_FUNCTION_ZU(soname,fnname) ( char* dst, const char* =
src ) \
{ \
const Char* src_orig =3D src; \
Char* dst_orig =3D dst; \
@@ -462,8 +462,8 @@
=20
=20
#define MEMSET(soname, fnname) \
- void* VG_REDIRECT_FUNCTION_ZU(soname,fnname)(void *s, Int c, SizeT n)=
; \
- void* VG_REDIRECT_FUNCTION_ZU(soname,fnname)(void *s, Int c, SizeT n)=
\
+ void* VG_REPLACE_FUNCTION_ZU(soname,fnname)(void *s, Int c, SizeT n);=
\
+ void* VG_REPLACE_FUNCTION_ZU(soname,fnname)(void *s, Int c, SizeT n) =
\
{ \
unsigned char *cp =3D s; \
\
@@ -477,9 +477,9 @@
=20
=20
#define MEMMOVE(soname, fnname) \
- void* VG_REDIRECT_FUNCTION_ZU(soname,fnname) \
+ void* VG_REPLACE_FUNCTION_ZU(soname,fnname) \
(void *dstV, const void *srcV, SizeT n); \
- void* VG_REDIRECT_FUNCTION_ZU(soname,fnname) \
+ void* VG_REPLACE_FUNCTION_ZU(soname,fnname) \
(void *dstV, const void *srcV, SizeT n) \
{ \
SizeT i; \
@@ -502,8 +502,8 @@
=20
/* Find the first occurrence of C in S or the final NUL byte. */
#define GLIBC232_STRCHRNUL(soname, fnname) \
- char* VG_REDIRECT_FUNCTION_ZU(soname,fnname) (const char* s, int c_in=
); \
- char* VG_REDIRECT_FUNCTION_ZU(soname,fnname) (const char* s, int c_in=
) \
+ char* VG_REPLACE_FUNCTION_ZU(soname,fnname) (const char* s, int c_in)=
; \
+ char* VG_REPLACE_FUNCTION_ZU(soname,fnname) (const char* s, int c_in)=
\
{ \
unsigned char c =3D (unsigned char) c_in; \
unsigned char* char_ptr =3D (unsigned char *)s; \
@@ -519,8 +519,8 @@
=20
/* Find the first occurrence of C in S. */
#define GLIBC232_RAWMEMCHR(soname, fnname) \
- char* VG_REDIRECT_FUNCTION_ZU(soname,fnname) (const char* s, int c_in=
); \
- char* VG_REDIRECT_FUNCTION_ZU(soname,fnname) (const char* s, int c_in=
) \
+ char* VG_REPLACE_FUNCTION_ZU(soname,fnname) (const char* s, int c_in)=
; \
+ char* VG_REPLACE_FUNCTION_ZU(soname,fnname) (const char* s, int c_in)=
\
{ \
unsigned char c =3D (unsigned char) c_in; \
unsigned char* char_ptr =3D (unsigned char *)s; \
|