|
From: <sv...@va...> - 2005-12-05 18:11:11
|
Author: sewardj
Date: 2005-12-05 18:11:02 +0000 (Mon, 05 Dec 2005)
New Revision: 5285
Log:
Make the new redirection stuff work. Add debug printing to aid
diagnosis. Reinstate the basic 3 pthread wrappers we have so far.
Modified:
branches/FNWRAP/coregrind/m_debuginfo/symtab.c
branches/FNWRAP/coregrind/m_main.c
branches/FNWRAP/coregrind/m_redir.c
branches/FNWRAP/coregrind/vg_preloaded.c
Modified: branches/FNWRAP/coregrind/m_debuginfo/symtab.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_debuginfo/symtab.c 2005-12-05 14:26:59 UT=
C (rev 5284)
+++ branches/FNWRAP/coregrind/m_debuginfo/symtab.c 2005-12-05 18:11:02 UT=
C (rev 5285)
@@ -1436,7 +1436,10 @@
=20
o_phdr =3D &((ElfXX_Phdr *)(oimage + ehdr->e_phoff))[i];
=20
- // Try to get the soname.
+ /* Try to get the soname. If there isn't one, use "NONE".
+ The seginfo needs to have some kind of soname in order to
+ facilitate writing redirect functions, since all redirect
+ specifications require a soname (pattern). */
if (o_phdr->p_type =3D=3D PT_DYNAMIC && si->soname =3D=3D NULL) {
const ElfXX_Dyn *dyn =3D (const ElfXX_Dyn *)(oimage + o_phdr->p_off=
set);
Int stroff =3D -1;
@@ -1446,7 +1449,7 @@
for(j =3D 0; dyn[j].d_tag !=3D DT_NULL; j++) {
switch(dyn[j].d_tag) {
case DT_SONAME:
- stroff =3D dyn[j].d_un.d_val;
+ stroff =3D dyn[j].d_un.d_val;
break;
=20
case DT_STRTAB:
@@ -1510,6 +1513,13 @@
}
}
=20
+ /* If, after looking at all the program headers, we still didn't=20
+ find a soname, add a fake one. */
+ if (si->soname =3D=3D NULL) {
+ TRACE_SYMTAB("soname(fake)=3D\"NONE\"\n");
+ si->soname =3D "NONE";
+ }
+
TRACE_SYMTAB("shoff =3D %d, shnum =3D %d, size =3D %d, n_vg_oimage=
=3D %d\n",
ehdr->e_shoff, ehdr->e_shnum, sizeof(ElfXX_Shdr), n_oima=
ge );
=20
Modified: branches/FNWRAP/coregrind/m_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
--- branches/FNWRAP/coregrind/m_main.c 2005-12-05 14:26:59 UTC (rev 5284)
+++ branches/FNWRAP/coregrind/m_main.c 2005-12-05 18:11:02 UTC (rev 5285)
@@ -911,6 +911,7 @@
" --trace-signals=3Dno|yes show signal handling details? [no]\n"
" --trace-symtab=3Dno|yes show symbol table details? [no]\n"
" --trace-cfi=3Dno|yes show call-frame-info details? [no]\n"
+" --trace-redir=3Dno|yes show redirection details? [no]\n"
" --trace-sched=3Dno|yes show thread scheduler details? [no]\n"
" --wait-for-gdb=3Dyes|no pause on startup to wait for gdb attach=
\n"
#if 0
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 14:26:59 UTC (rev 5284=
)
+++ branches/FNWRAP/coregrind/m_redir.c 2005-12-05 18:11:02 UTC (rev 5285=
)
@@ -160,6 +160,9 @@
static HChar* symtab_strdup(HChar*);
static Bool is_plausible_guest_addr(Addr);
=20
+static void show_redir_state ( HChar* who );
+
+
/*------------------------------------------------------------*/
/*--- REDIRECTION SPECIFICATIONS ---*/
/*------------------------------------------------------------*/
@@ -256,6 +259,7 @@
HChar demangled_fnpatt[N_DEMANGLED];
=20
vg_assert(newsi);
+ vg_assert(VG_(seginfo_soname)(newsi) !=3D NULL);
=20
/* stay sane: we don't already have this. */
for (ts =3D topSpecs; ts; ts =3D ts->next)
@@ -332,6 +336,9 @@
/* Finally, add the new TopSpec. */
newts->next =3D topSpecs;
topSpecs =3D newts;
+
+ if (VG_(clo_trace_redir))
+ show_redir_state("after VG_(redir_notify_new_SegInfo)");
}
=20
#undef N_DEMANGLED
@@ -482,7 +489,7 @@
just before translating a basic block. */
Addr VG_(redir_do_lookup) ( Addr orig )
{
- Spec* r =3D VG_(OSet_Lookup)(activeSet, &orig);
+ Active* r =3D VG_(OSet_Lookup)(activeSet, &orig);
if (r =3D=3D NULL)
return orig;
=20
@@ -611,6 +618,9 @@
# else
# error Unknown platform
# endif
+
+ if (VG_(clo_trace_redir))
+ show_redir_state("after VG_(redir_initialise)");
}
=20
=20
@@ -832,6 +842,60 @@
}
=20
=20
+/*------------------------------------------------------------*/
+/*--- SANITY/DEBUG ---*/
+/*------------------------------------------------------------*/
+
+static void show_spec ( HChar* left, Spec* spec )
+{
+ VG_(message)(Vg_DebugMsg,=20
+ "%s%18s %22s -> 0x%08llx",
+ left,
+ spec->from_sopatt, spec->from_fnpatt,
+ (ULong)spec->to_addr );
+}
+
+static void show_active ( HChar* left, Active* act )
+{
+ Bool ok;
+ HChar name1[64] =3D "";
+ HChar name2[64] =3D "";
+ name1[0] =3D name2[0] =3D 0;
+ ok =3D VG_(get_fnname_w_offset)(act->from_addr, name1, 64);
+ if (!ok) VG_(strcpy)(name1, "???");
+ ok =3D VG_(get_fnname_w_offset)(act->to_addr, name2, 64);
+ if (!ok) VG_(strcpy)(name2, "???");
+
+ VG_(message)(Vg_DebugMsg, "%s0x%08llx (%10s) -> 0x%08llx %s",=20
+ left,=20
+ (ULong)act->from_addr, name1,
+ (ULong)act->to_addr, name2 );
+}
+
+static void show_redir_state ( HChar* who )
+{
+ TopSpec* ts;
+ Spec* sp;
+ Active* act;
+ VG_(message)(Vg_DebugMsg, "<<");
+ VG_(message)(Vg_DebugMsg, " ------ REDIR STATE %s ------", who);
+ for (ts =3D topSpecs; ts; ts =3D ts->next) {
+ VG_(message)(Vg_DebugMsg,=20
+ " TOPSPECS of soname %s",
+ ts->seginfo ? (HChar*)VG_(seginfo_soname)(ts->seginfo=
)
+ : "(hardwired)" );
+ for (sp =3D ts->specs; sp; sp =3D sp->next)
+ show_spec(" ", sp);
+ }
+ VG_(message)(Vg_DebugMsg, " ------ ACTIVE ------");
+ VG_(OSet_ResetIter)( activeSet );
+ while ( (act =3D VG_(OSet_Next)(activeSet)) ) {
+ show_active(" ", act);
+ }
+
+ VG_(message)(Vg_DebugMsg, ">>");
+}
+
/*--------------------------------------------------------------------*/
/*--- end ---*/
/*--------------------------------------------------------------------*/
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 14:26:59 UTC (rev=
5284)
+++ branches/FNWRAP/coregrind/vg_preloaded.c 2005-12-05 18:11:02 UTC (rev=
5285)
@@ -71,11 +71,9 @@
/*--- end ---*/
/*--------------------------------------------------------------------*/
=20
-#if 0
-
#define PTH_FUNC(ret_ty, f, args...) \
- ret_ty VG_REPLACE_FUNCTION(libpthreadZdsoZd0, f)(args); \
- ret_ty VG_REPLACE_FUNCTION(libpthreadZdsoZd0, f)(args)
+ ret_ty VG_REDIRECT_FUNCTION_ZZ(libpthreadZdsoZd0,f)(args); \
+ ret_ty VG_REDIRECT_FUNCTION_ZZ(libpthreadZdsoZd0,f)(args)
=20
#define LIBC_FUNC(ret_ty, f, args...) \
ret_ty VG_REPLACE_FUNCTION(libcZdsoZd6, f)(args); \
@@ -84,9 +82,11 @@
#include <stdio.h>
#include <pthread.h>
=20
-PTH_FUNC(int, pthread_create, // pthread_create@*
- pthread_t *thread, const pthread_attr_t *attr,
- void *(*start) (void *), void *arg)
+// pthread_create@GLIBC_2.0
+// pthread_create@@GLIBC_2.1
+PTH_FUNC(int, pthreadZucreateZAZa, // pthread_create@*
+ pthread_t *thread, const pthread_attr_t *attr,
+ void *(*start) (void *), void *arg)
{
int ret;
fprintf(stderr, "<< pthread_create wrapper"); fflush(stderr);
@@ -98,7 +98,9 @@
return ret;
}
=20
-PTH_FUNC(int, pthread_mutex_lock, pthread_mutex_t *mutex)
+// pthread_mutex_lock
+PTH_FUNC(int, pthreadZumutexZulock, // pthread_mutex_lock
+ pthread_mutex_t *mutex)
{
int ret;
fprintf(stderr, "<< pthread_mxlock %p", mutex); fflush(stderr);
@@ -110,7 +112,9 @@
return ret;
}
=20
-PTH_FUNC(int, pthread_mutex_unlock, pthread_mutex_t *mutex)
+// pthread_mutex_unlock
+PTH_FUNC(int, pthreadZumutexZuunlock, // pthread_mutex_unlock
+ pthread_mutex_t *mutex)
{
int ret;
fprintf(stderr, "<< pthread_mxunlk %p", mutex); fflush(stderr);
@@ -121,19 +125,3 @@
fprintf(stderr, " -> %d >>\n", ret);
return ret;
}
-
-#endif
-
-#if 0
-LIBC_FUNC(int, fclose, void* f)
-{
- int ret;
- fprintf(stderr, "<< fclose(%p)\n", f);
-
- VALGRIND_SET_NOREDIR;
- ret =3D fclose(f);
-
- fprintf(stderr, ">>\n");
- return ret;
-}
-#endif
|