|
From: <sv...@va...> - 2005-12-05 19:17:42
|
Author: sewardj
Date: 2005-12-05 19:17:37 +0000 (Mon, 05 Dec 2005)
New Revision: 5286
Log:
Finish off handling of SegInfo disappearance in m_redir, and also
make function load-notification work again.
Modified:
branches/FNWRAP/coregrind/m_redir.c
branches/FNWRAP/coregrind/vg_preloaded.c
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-05 18:11:02 UTC (rev 5285=
)
+++ branches/FNWRAP/coregrind/m_redir.c 2005-12-05 19:17:37 UTC (rev 5286=
)
@@ -44,7 +44,9 @@
#include "pub_core_transtab.h"
#include "pub_core_tooliface.h" // VG_(needs).malloc_replacement
#include "pub_core_aspacemgr.h" // VG_(am_find_nsegment)
+#include "pub_core_clientstate.h" // VG_(client___libc_freeres_wrapper)
=20
+
/*------------------------------------------------------------*/
/*--- Semantics ---*/
/*------------------------------------------------------------*/
@@ -162,7 +164,9 @@
=20
static void show_redir_state ( HChar* who );
=20
+static void handle_maybe_load_notifier( HChar* symbol, Addr addr );
=20
+
/*------------------------------------------------------------*/
/*--- REDIRECTION SPECIFICATIONS ---*/
/*------------------------------------------------------------*/
@@ -172,11 +176,11 @@
spec can match an arbitrary number of times. */
typedef
struct _Spec {
- struct _Spec* next; /* linked list */
- HChar* from_sopatt; /* from soname pattern */
- const Char* from_fnpatt; /* from fnname pattern */
- Addr to_addr; /* where redirecting to */
- Bool mark; /* transient temporary used during matching */
+ struct _Spec* next; /* linked list */
+ HChar* from_sopatt; /* from soname pattern */
+ HChar* from_fnpatt; /* from fnname pattern */
+ Addr to_addr; /* where redirecting to */
+ Bool mark; /* transient temporary used during matching */
}
Spec;
=20
@@ -188,8 +192,8 @@
typedef
struct _TopSpec {
struct _TopSpec* next; /* linked list */
- SegInfo* seginfo; /* symbols etc */
- Spec* specs; /* specs pulled out of seginfo */
+ SegInfo* seginfo; /* symbols etc */
+ Spec* specs; /* specs pulled out of seginfo */
Bool mark; /* transient temporary used during deletion */
}
TopSpec;
@@ -275,7 +279,12 @@
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 );
- if (!ok) continue;
+ 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. */
+ handle_maybe_load_notifier( sym_name, sym_addr );
+ continue;=20
+ }
spec =3D symtab_alloc(sizeof(Spec));
vg_assert(spec);
spec->from_sopatt =3D symtab_strdup(demangled_sopatt);
@@ -433,6 +442,9 @@
void VG_(redir_notify_delete_SegInfo)( SegInfo* delsi )
{
TopSpec* ts;
+ TopSpec* tsPrev;
+ Spec* sp;
+ Spec* sp_next;
OSet* tmpSet;
Active* act;
Bool delMe;
@@ -440,12 +452,19 @@
=20
vg_assert(delsi);
=20
- /* Search for it. */
- for (ts =3D topSpecs; ts; ts =3D ts->next)
- if (ts->seginfo =3D=3D delsi)
- break;
+ /* Search for it, and make tsPrev point to the previous entry, if
+ any. */
+ tsPrev =3D NULL;
+ ts =3D topSpecs;
+ while (True) {
+ if (ts =3D=3D NULL) break;
+ if (ts->seginfo =3D=3D delsi) break;
+ tsPrev =3D ts;
+ ts =3D ts->next;
+ }
=20
vg_assert(ts); /* else we don't have the deleted SegInfo */
+ vg_assert(ts->seginfo =3D=3D delsi);
=20
/* Traverse the actives, copying the addresses of those we intend
to delete into tmpSet. */
@@ -472,11 +491,29 @@
activeSet. */
VG_(OSet_ResetIter)( tmpSet );
while ( (addrP =3D VG_(OSet_Next)(tmpSet)) ) {
+ /* XXXXXXXXXXX invalidate translations */
VG_(OSet_Remove)( activeSet, addrP );
VG_(OSet_FreeNode)( activeSet, addrP );
}
=20
VG_(OSet_Destroy)( tmpSet );
+
+ /* The Actives set is now cleaned up. Free up this TopSpec and
+ everything hanging off it. */
+ for (sp =3D ts->specs; sp; sp =3D sp_next) {
+ if (sp->from_sopatt) symtab_free(sp->from_sopatt);
+ if (sp->from_fnpatt) symtab_free(sp->from_fnpatt);
+ sp_next =3D sp->next;
+ symtab_free(sp);
+ }
+
+ if (tsPrev =3D=3D NULL) {
+ /* first in list */
+ topSpecs =3D ts->next;
+ } else {
+ tsPrev->next =3D ts->next;
+ }
+ symtab_free(ts);
}
=20
=20
@@ -624,8 +661,9 @@
}
=20
=20
-//////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////
+/*------------------------------------------------------------*/
+/*--- MISC HELPERS ---*/
+/*------------------------------------------------------------*/
=20
static void* symtab_alloc(SizeT n)
{
@@ -642,7 +680,7 @@
return VG_(arena_strdup)(VG_AR_SYMTAB, str);
}
=20
-/* Really this should be merged with translations_allowable_from_seg
+/* Really this should be merged with translations_allowable_from_seg
in m_translate. */
static Bool is_plausible_guest_addr(Addr a)
{
@@ -652,40 +690,26 @@
&& (seg->hasX || seg->hasR); /* crude x86-specific hack */
}
=20
-//////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////
=20
+/*------------------------------------------------------------*/
+/*--- NOTIFY-ON-LOAD FUNCTIONS ---*/
+/*------------------------------------------------------------*/
=20
-// This is specifically for stringifying VG_(x) function names. We
-// need to do two macroexpansions to get the VG_ macro expanded before
-// stringifying.
-//zz #define _STR(x) #x
-//zz #define STR(x) _STR(x)
-//zz=20
-//zz static void handle_load_notifier( Char* symbol, Addr addr )
-//zz {
-//zz if (VG_(strcmp)(symbol, STR(VG_NOTIFY_ON_LOAD(freeres))) =3D=3D =
0)
-//zz VG_(client___libc_freeres_wrapper) =3D addr;
+static void handle_maybe_load_notifier( HChar* symbol, Addr addr )
+{
+ if (0 !=3D VG_(strncmp)(symbol, VG_NOTIFY_ON_LOAD_PREFIX,=20
+ VG_NOTIFY_ON_LOAD_PREFIX_LEN))
+ /* Doesn't have the right prefix */
+ return;
+
+ if (VG_(strcmp)(symbol, VG_STRINGIFY(VG_NOTIFY_ON_LOAD(freeres))) =3D=
=3D 0)
+ VG_(client___libc_freeres_wrapper) =3D addr;
// else
// if (VG_(strcmp)(symbol, STR(VG_WRAPPER(pthread_startfunc_wrapper))) =3D=
=3D 0)
// VG_(pthread_startfunc_wrapper)((Addr)(si->offset + sym->st_value))=
;
-//zz else
-//zz vg_assert2(0, "unrecognised load notification function: %s", =
symbol);
-//zz }
-//zz=20
-//zz static Bool is_replacement_function(Char* s)
-//zz {
-//zz return (0 =3D=3D VG_(strncmp)(s,
-//zz VG_REPLACE_FUNCTION_PREFIX,
-//zz VG_REPLACE_FUNCTION_PREFIX_LEN));
-//zz }
-//zz=20
-//zz static Bool is_load_notifier(Char* s)
-//zz {
-//zz return (0 =3D=3D VG_(strncmp)(s,
-//zz VG_NOTIFY_ON_LOAD_PREFIX,
-//zz VG_NOTIFY_ON_LOAD_PREFIX_LEN));
-//zz }
+ else
+ vg_assert2(0, "unrecognised load notification function: %s", symbo=
l);
+}
=20
=20
/*------------------------------------------------------------*/
Modified: branches/FNWRAP/coregrind/vg_preloaded.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/vg_preloaded.c 2005-12-05 18:11:02 UTC (rev=
5285)
+++ branches/FNWRAP/coregrind/vg_preloaded.c 2005-12-05 19:17:37 UTC (rev=
5286)
@@ -71,6 +71,8 @@
/*--- end ---*/
/*--------------------------------------------------------------------*/
=20
+#if 0
+
#define PTH_FUNC(ret_ty, f, args...) \
ret_ty VG_REDIRECT_FUNCTION_ZZ(libpthreadZdsoZd0,f)(args); \
ret_ty VG_REDIRECT_FUNCTION_ZZ(libpthreadZdsoZd0,f)(args)
@@ -125,3 +127,5 @@
fprintf(stderr, " -> %d >>\n", ret);
return ret;
}
+
+#endif
|