]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix many holes and bugs in an attempt to get my libpthread.so to export
authorJulian Seward <jseward@acm.org>
Fri, 26 Apr 2002 03:28:18 +0000 (03:28 +0000)
committerJulian Seward <jseward@acm.org>
Fri, 26 Apr 2002 03:28:18 +0000 (03:28 +0000)
the same set of symbols as the real one, which I now realise is crucial
for it to work at all.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@151

coregrind/arch/x86-linux/vg_libpthread.c
coregrind/arch/x86-linux/vg_libpthread_unimp.c
coregrind/valgrind.in
coregrind/vg_libpthread.c
coregrind/vg_libpthread_unimp.c
coregrind/vg_to_ucode.c
valgrind.in
vg_libpthread.c
vg_libpthread_unimp.c
vg_to_ucode.c

index 2715953a05cc222704738782da5c492cabad6947..4644a0e610b8e9585bfd79f2d8e0479e09d29c59 100644 (file)
@@ -679,6 +679,90 @@ struct __res_state* __res_state ( void )
 }
 
 
+/* ---------------------------------------------------
+   LIBC-PRIVATE SPECIFIC DATA
+   ------------------------------------------------ */
+
+/* Relies on assumption that initial private data is NULL.  This
+   should be fixed somehow. */
+
+/* The allowable keys (indices) (all 2 of them). 
+   From sysdeps/pthread/bits/libc-tsd.h
+*/
+enum __libc_tsd_key_t { _LIBC_TSD_KEY_MALLOC = 0,
+                        _LIBC_TSD_KEY_DL_ERROR,
+                        _LIBC_TSD_KEY_N };
+
+/* Auto-initialising subsystem.  libc_specifics_inited is set 
+   after initialisation.  libc_specifics_inited_mx guards it. */
+static int             libc_specifics_inited    = 0;
+static pthread_mutex_t libc_specifics_inited_mx = PTHREAD_MUTEX_INITIALIZER;
+
+/* These are the keys we must initialise the first time. */
+static pthread_key_t libc_specifics_keys[_LIBC_TSD_KEY_N];
+
+/* Initialise the keys, if they are not already initialise. */
+static
+void init_libc_tsd_keys ( void )
+{
+   int res, i;
+   pthread_key_t k;
+
+   res = pthread_mutex_lock(&libc_specifics_inited_mx);
+   if (res != 0) barf("init_libc_tsd_keys: lock");
+
+   if (libc_specifics_inited == 0) {
+      /* printf("INIT libc specifics\n"); */
+      libc_specifics_inited = 1;
+      for (i = 0; i < _LIBC_TSD_KEY_N; i++) {
+         res = pthread_key_create(&k, NULL);
+        if (res != 0) barf("init_libc_tsd_keys: create");
+         libc_specifics_keys[i] = k;
+      }
+   }
+
+   res = pthread_mutex_unlock(&libc_specifics_inited_mx);
+   if (res != 0) barf("init_libc_tsd_keys: unlock");
+}
+
+
+static int
+libc_internal_tsd_set ( enum __libc_tsd_key_t key, 
+                        const void * pointer )
+{
+   int res;
+   /* printf("SET SET SET key %d ptr %p\n", key, pointer); */
+   if (key < _LIBC_TSD_KEY_MALLOC || key >= _LIBC_TSD_KEY_N)
+      barf("libc_internal_tsd_set: invalid key");
+   init_libc_tsd_keys();
+   res = pthread_setspecific(libc_specifics_keys[key], pointer);
+   if (res != 0) barf("libc_internal_tsd_set: setspecific failed");
+   return 0;
+}
+
+static void *
+libc_internal_tsd_get ( enum __libc_tsd_key_t key )
+{
+   void* v;
+   /* printf("GET GET GET key %d\n", key); */
+   if (key < _LIBC_TSD_KEY_MALLOC || key >= _LIBC_TSD_KEY_N)
+      barf("libc_internal_tsd_get: invalid key");
+   init_libc_tsd_keys();
+   v = pthread_getspecific(libc_specifics_keys[key]);
+   /* if (v == NULL) barf("libc_internal_tsd_set: getspecific failed"); */
+   return v;
+}
+
+
+
+
+int (*__libc_internal_tsd_set)(enum __libc_tsd_key_t key, const void * pointer)
+     = libc_internal_tsd_set;
+
+void* (*__libc_internal_tsd_get)(enum __libc_tsd_key_t key)
+     = libc_internal_tsd_get;
+
+
 /* ---------------------------------------------------------------------
    These are here (I think) because they are deemed cancellation
    points by POSIX.  For the moment we'll simply pass the call along
@@ -1214,6 +1298,26 @@ strong_alias(connect, __connect)
 
 /*--------------------------------------------------*/
 
+int
+pthread_rwlock_rdlock (void* /* pthread_rwlock_t* */ rwlock)
+{
+   kludged("pthread_rwlock_rdlock");
+   return 0;
+}
+
+strong_alias(pthread_rwlock_rdlock, __pthread_rwlock_rdlock)
+
+
+int
+pthread_rwlock_unlock (void* /* pthread_rwlock_t* */ rwlock)
+{
+   kludged("pthread_rwlock_unlock");
+   return 0;
+}
+
+strong_alias(pthread_rwlock_unlock, __pthread_rwlock_unlock)
+
+
 /* I've no idea what these are, but they get called quite a lot.
    Anybody know? */
 
index d01dc5bfb03826da01cfda1b00ebdb8d19cac0a9..a2cc926d7e80ba1c0ede9382bb808458d021aafd 100644 (file)
@@ -101,12 +101,12 @@ void pthread_mutex_timedlock ( void )  { unimp("pthread_mutex_timedlock"); }
 //void pthread_once ( void )  { unimp("pthread_once"); }
 void pthread_rwlock_destroy ( void )  { unimp("pthread_rwlock_destroy"); }
 void pthread_rwlock_init ( void )  { unimp("pthread_rwlock_init"); }
-void pthread_rwlock_rdlock ( void )  { unimp("pthread_rwlock_rdlock"); }
+//void pthread_rwlock_rdlock ( void )  { unimp("pthread_rwlock_rdlock"); }
 void pthread_rwlock_timedrdlock ( void )  { unimp("pthread_rwlock_timedrdlock"); }
 void pthread_rwlock_timedwrlock ( void )  { unimp("pthread_rwlock_timedwrlock"); }
 void pthread_rwlock_tryrdlock ( void )  { unimp("pthread_rwlock_tryrdlock"); }
 void pthread_rwlock_trywrlock ( void )  { unimp("pthread_rwlock_trywrlock"); }
-void pthread_rwlock_unlock ( void )  { unimp("pthread_rwlock_unlock"); }
+//void pthread_rwlock_unlock ( void )  { unimp("pthread_rwlock_unlock"); }
 void pthread_rwlock_wrlock ( void )  { unimp("pthread_rwlock_wrlock"); }
 void pthread_rwlockattr_destroy ( void )  { unimp("pthread_rwlockattr_destroy"); }
 void pthread_rwlockattr_getkind_np ( void )  { unimp("pthread_rwlockattr_getkind_np"); }
@@ -153,3 +153,4 @@ void sem_init@GLIBC_2.0 ( void )  { unimp("sem_init@GLIBC_2.0"); }
 void pthread_attr_init@@GLIBC_2.1 ( void )  { unimp("pthread_attr_init@@GLIBC_2.1"); }
 void pthread_attr_init@GLIBC_2.0 ( void )  { unimp("pthread_attr_init@GLIBC_2.0"); }
 #endif
+
index d16b5d96645cc57279cd83594c6dedbf306f11b7..7f188907961419ea007e0fb1f21df2e14f5c71de 100755 (executable)
@@ -166,5 +166,6 @@ export LD_LIBRARY_PATH
 LD_PRELOAD=valgrind.so:$LD_PRELOAD
 export LD_PRELOAD
 #LD_DEBUG=files
+#LD_DEBUG=symbols
 #export LD_DEBUG
 exec "$@"
index 2715953a05cc222704738782da5c492cabad6947..4644a0e610b8e9585bfd79f2d8e0479e09d29c59 100644 (file)
@@ -679,6 +679,90 @@ struct __res_state* __res_state ( void )
 }
 
 
+/* ---------------------------------------------------
+   LIBC-PRIVATE SPECIFIC DATA
+   ------------------------------------------------ */
+
+/* Relies on assumption that initial private data is NULL.  This
+   should be fixed somehow. */
+
+/* The allowable keys (indices) (all 2 of them). 
+   From sysdeps/pthread/bits/libc-tsd.h
+*/
+enum __libc_tsd_key_t { _LIBC_TSD_KEY_MALLOC = 0,
+                        _LIBC_TSD_KEY_DL_ERROR,
+                        _LIBC_TSD_KEY_N };
+
+/* Auto-initialising subsystem.  libc_specifics_inited is set 
+   after initialisation.  libc_specifics_inited_mx guards it. */
+static int             libc_specifics_inited    = 0;
+static pthread_mutex_t libc_specifics_inited_mx = PTHREAD_MUTEX_INITIALIZER;
+
+/* These are the keys we must initialise the first time. */
+static pthread_key_t libc_specifics_keys[_LIBC_TSD_KEY_N];
+
+/* Initialise the keys, if they are not already initialise. */
+static
+void init_libc_tsd_keys ( void )
+{
+   int res, i;
+   pthread_key_t k;
+
+   res = pthread_mutex_lock(&libc_specifics_inited_mx);
+   if (res != 0) barf("init_libc_tsd_keys: lock");
+
+   if (libc_specifics_inited == 0) {
+      /* printf("INIT libc specifics\n"); */
+      libc_specifics_inited = 1;
+      for (i = 0; i < _LIBC_TSD_KEY_N; i++) {
+         res = pthread_key_create(&k, NULL);
+        if (res != 0) barf("init_libc_tsd_keys: create");
+         libc_specifics_keys[i] = k;
+      }
+   }
+
+   res = pthread_mutex_unlock(&libc_specifics_inited_mx);
+   if (res != 0) barf("init_libc_tsd_keys: unlock");
+}
+
+
+static int
+libc_internal_tsd_set ( enum __libc_tsd_key_t key, 
+                        const void * pointer )
+{
+   int res;
+   /* printf("SET SET SET key %d ptr %p\n", key, pointer); */
+   if (key < _LIBC_TSD_KEY_MALLOC || key >= _LIBC_TSD_KEY_N)
+      barf("libc_internal_tsd_set: invalid key");
+   init_libc_tsd_keys();
+   res = pthread_setspecific(libc_specifics_keys[key], pointer);
+   if (res != 0) barf("libc_internal_tsd_set: setspecific failed");
+   return 0;
+}
+
+static void *
+libc_internal_tsd_get ( enum __libc_tsd_key_t key )
+{
+   void* v;
+   /* printf("GET GET GET key %d\n", key); */
+   if (key < _LIBC_TSD_KEY_MALLOC || key >= _LIBC_TSD_KEY_N)
+      barf("libc_internal_tsd_get: invalid key");
+   init_libc_tsd_keys();
+   v = pthread_getspecific(libc_specifics_keys[key]);
+   /* if (v == NULL) barf("libc_internal_tsd_set: getspecific failed"); */
+   return v;
+}
+
+
+
+
+int (*__libc_internal_tsd_set)(enum __libc_tsd_key_t key, const void * pointer)
+     = libc_internal_tsd_set;
+
+void* (*__libc_internal_tsd_get)(enum __libc_tsd_key_t key)
+     = libc_internal_tsd_get;
+
+
 /* ---------------------------------------------------------------------
    These are here (I think) because they are deemed cancellation
    points by POSIX.  For the moment we'll simply pass the call along
@@ -1214,6 +1298,26 @@ strong_alias(connect, __connect)
 
 /*--------------------------------------------------*/
 
+int
+pthread_rwlock_rdlock (void* /* pthread_rwlock_t* */ rwlock)
+{
+   kludged("pthread_rwlock_rdlock");
+   return 0;
+}
+
+strong_alias(pthread_rwlock_rdlock, __pthread_rwlock_rdlock)
+
+
+int
+pthread_rwlock_unlock (void* /* pthread_rwlock_t* */ rwlock)
+{
+   kludged("pthread_rwlock_unlock");
+   return 0;
+}
+
+strong_alias(pthread_rwlock_unlock, __pthread_rwlock_unlock)
+
+
 /* I've no idea what these are, but they get called quite a lot.
    Anybody know? */
 
index d01dc5bfb03826da01cfda1b00ebdb8d19cac0a9..a2cc926d7e80ba1c0ede9382bb808458d021aafd 100644 (file)
@@ -101,12 +101,12 @@ void pthread_mutex_timedlock ( void )  { unimp("pthread_mutex_timedlock"); }
 //void pthread_once ( void )  { unimp("pthread_once"); }
 void pthread_rwlock_destroy ( void )  { unimp("pthread_rwlock_destroy"); }
 void pthread_rwlock_init ( void )  { unimp("pthread_rwlock_init"); }
-void pthread_rwlock_rdlock ( void )  { unimp("pthread_rwlock_rdlock"); }
+//void pthread_rwlock_rdlock ( void )  { unimp("pthread_rwlock_rdlock"); }
 void pthread_rwlock_timedrdlock ( void )  { unimp("pthread_rwlock_timedrdlock"); }
 void pthread_rwlock_timedwrlock ( void )  { unimp("pthread_rwlock_timedwrlock"); }
 void pthread_rwlock_tryrdlock ( void )  { unimp("pthread_rwlock_tryrdlock"); }
 void pthread_rwlock_trywrlock ( void )  { unimp("pthread_rwlock_trywrlock"); }
-void pthread_rwlock_unlock ( void )  { unimp("pthread_rwlock_unlock"); }
+//void pthread_rwlock_unlock ( void )  { unimp("pthread_rwlock_unlock"); }
 void pthread_rwlock_wrlock ( void )  { unimp("pthread_rwlock_wrlock"); }
 void pthread_rwlockattr_destroy ( void )  { unimp("pthread_rwlockattr_destroy"); }
 void pthread_rwlockattr_getkind_np ( void )  { unimp("pthread_rwlockattr_getkind_np"); }
@@ -153,3 +153,4 @@ void sem_init@GLIBC_2.0 ( void )  { unimp("sem_init@GLIBC_2.0"); }
 void pthread_attr_init@@GLIBC_2.1 ( void )  { unimp("pthread_attr_init@@GLIBC_2.1"); }
 void pthread_attr_init@GLIBC_2.0 ( void )  { unimp("pthread_attr_init@GLIBC_2.0"); }
 #endif
+
index b1b28556475c6cc882a25d77f6666382c0851e6f..f06689d956e913a2e67b6385ab0568f89daf705d 100644 (file)
@@ -3066,7 +3066,10 @@ static Addr disInstr ( UCodeBlock* cb, Addr eip, Bool* isEnd )
    }
 
    /* Skip a LOCK prefix. */
-   if (getUChar(eip) == 0xF0) eip++;
+   if (getUChar(eip) == 0xF0) { 
+      /* VG_(printf)("LOCK LOCK LOCK LOCK LOCK \n"); */
+      eip++;
+   }
 
    /* Crap out if we see a segment override prefix. */
    if (getUChar(eip) == 0x65) {
index d16b5d96645cc57279cd83594c6dedbf306f11b7..7f188907961419ea007e0fb1f21df2e14f5c71de 100755 (executable)
@@ -166,5 +166,6 @@ export LD_LIBRARY_PATH
 LD_PRELOAD=valgrind.so:$LD_PRELOAD
 export LD_PRELOAD
 #LD_DEBUG=files
+#LD_DEBUG=symbols
 #export LD_DEBUG
 exec "$@"
index 2715953a05cc222704738782da5c492cabad6947..4644a0e610b8e9585bfd79f2d8e0479e09d29c59 100644 (file)
@@ -679,6 +679,90 @@ struct __res_state* __res_state ( void )
 }
 
 
+/* ---------------------------------------------------
+   LIBC-PRIVATE SPECIFIC DATA
+   ------------------------------------------------ */
+
+/* Relies on assumption that initial private data is NULL.  This
+   should be fixed somehow. */
+
+/* The allowable keys (indices) (all 2 of them). 
+   From sysdeps/pthread/bits/libc-tsd.h
+*/
+enum __libc_tsd_key_t { _LIBC_TSD_KEY_MALLOC = 0,
+                        _LIBC_TSD_KEY_DL_ERROR,
+                        _LIBC_TSD_KEY_N };
+
+/* Auto-initialising subsystem.  libc_specifics_inited is set 
+   after initialisation.  libc_specifics_inited_mx guards it. */
+static int             libc_specifics_inited    = 0;
+static pthread_mutex_t libc_specifics_inited_mx = PTHREAD_MUTEX_INITIALIZER;
+
+/* These are the keys we must initialise the first time. */
+static pthread_key_t libc_specifics_keys[_LIBC_TSD_KEY_N];
+
+/* Initialise the keys, if they are not already initialise. */
+static
+void init_libc_tsd_keys ( void )
+{
+   int res, i;
+   pthread_key_t k;
+
+   res = pthread_mutex_lock(&libc_specifics_inited_mx);
+   if (res != 0) barf("init_libc_tsd_keys: lock");
+
+   if (libc_specifics_inited == 0) {
+      /* printf("INIT libc specifics\n"); */
+      libc_specifics_inited = 1;
+      for (i = 0; i < _LIBC_TSD_KEY_N; i++) {
+         res = pthread_key_create(&k, NULL);
+        if (res != 0) barf("init_libc_tsd_keys: create");
+         libc_specifics_keys[i] = k;
+      }
+   }
+
+   res = pthread_mutex_unlock(&libc_specifics_inited_mx);
+   if (res != 0) barf("init_libc_tsd_keys: unlock");
+}
+
+
+static int
+libc_internal_tsd_set ( enum __libc_tsd_key_t key, 
+                        const void * pointer )
+{
+   int res;
+   /* printf("SET SET SET key %d ptr %p\n", key, pointer); */
+   if (key < _LIBC_TSD_KEY_MALLOC || key >= _LIBC_TSD_KEY_N)
+      barf("libc_internal_tsd_set: invalid key");
+   init_libc_tsd_keys();
+   res = pthread_setspecific(libc_specifics_keys[key], pointer);
+   if (res != 0) barf("libc_internal_tsd_set: setspecific failed");
+   return 0;
+}
+
+static void *
+libc_internal_tsd_get ( enum __libc_tsd_key_t key )
+{
+   void* v;
+   /* printf("GET GET GET key %d\n", key); */
+   if (key < _LIBC_TSD_KEY_MALLOC || key >= _LIBC_TSD_KEY_N)
+      barf("libc_internal_tsd_get: invalid key");
+   init_libc_tsd_keys();
+   v = pthread_getspecific(libc_specifics_keys[key]);
+   /* if (v == NULL) barf("libc_internal_tsd_set: getspecific failed"); */
+   return v;
+}
+
+
+
+
+int (*__libc_internal_tsd_set)(enum __libc_tsd_key_t key, const void * pointer)
+     = libc_internal_tsd_set;
+
+void* (*__libc_internal_tsd_get)(enum __libc_tsd_key_t key)
+     = libc_internal_tsd_get;
+
+
 /* ---------------------------------------------------------------------
    These are here (I think) because they are deemed cancellation
    points by POSIX.  For the moment we'll simply pass the call along
@@ -1214,6 +1298,26 @@ strong_alias(connect, __connect)
 
 /*--------------------------------------------------*/
 
+int
+pthread_rwlock_rdlock (void* /* pthread_rwlock_t* */ rwlock)
+{
+   kludged("pthread_rwlock_rdlock");
+   return 0;
+}
+
+strong_alias(pthread_rwlock_rdlock, __pthread_rwlock_rdlock)
+
+
+int
+pthread_rwlock_unlock (void* /* pthread_rwlock_t* */ rwlock)
+{
+   kludged("pthread_rwlock_unlock");
+   return 0;
+}
+
+strong_alias(pthread_rwlock_unlock, __pthread_rwlock_unlock)
+
+
 /* I've no idea what these are, but they get called quite a lot.
    Anybody know? */
 
index d01dc5bfb03826da01cfda1b00ebdb8d19cac0a9..a2cc926d7e80ba1c0ede9382bb808458d021aafd 100644 (file)
@@ -101,12 +101,12 @@ void pthread_mutex_timedlock ( void )  { unimp("pthread_mutex_timedlock"); }
 //void pthread_once ( void )  { unimp("pthread_once"); }
 void pthread_rwlock_destroy ( void )  { unimp("pthread_rwlock_destroy"); }
 void pthread_rwlock_init ( void )  { unimp("pthread_rwlock_init"); }
-void pthread_rwlock_rdlock ( void )  { unimp("pthread_rwlock_rdlock"); }
+//void pthread_rwlock_rdlock ( void )  { unimp("pthread_rwlock_rdlock"); }
 void pthread_rwlock_timedrdlock ( void )  { unimp("pthread_rwlock_timedrdlock"); }
 void pthread_rwlock_timedwrlock ( void )  { unimp("pthread_rwlock_timedwrlock"); }
 void pthread_rwlock_tryrdlock ( void )  { unimp("pthread_rwlock_tryrdlock"); }
 void pthread_rwlock_trywrlock ( void )  { unimp("pthread_rwlock_trywrlock"); }
-void pthread_rwlock_unlock ( void )  { unimp("pthread_rwlock_unlock"); }
+//void pthread_rwlock_unlock ( void )  { unimp("pthread_rwlock_unlock"); }
 void pthread_rwlock_wrlock ( void )  { unimp("pthread_rwlock_wrlock"); }
 void pthread_rwlockattr_destroy ( void )  { unimp("pthread_rwlockattr_destroy"); }
 void pthread_rwlockattr_getkind_np ( void )  { unimp("pthread_rwlockattr_getkind_np"); }
@@ -153,3 +153,4 @@ void sem_init@GLIBC_2.0 ( void )  { unimp("sem_init@GLIBC_2.0"); }
 void pthread_attr_init@@GLIBC_2.1 ( void )  { unimp("pthread_attr_init@@GLIBC_2.1"); }
 void pthread_attr_init@GLIBC_2.0 ( void )  { unimp("pthread_attr_init@GLIBC_2.0"); }
 #endif
+
index b1b28556475c6cc882a25d77f6666382c0851e6f..f06689d956e913a2e67b6385ab0568f89daf705d 100644 (file)
@@ -3066,7 +3066,10 @@ static Addr disInstr ( UCodeBlock* cb, Addr eip, Bool* isEnd )
    }
 
    /* Skip a LOCK prefix. */
-   if (getUChar(eip) == 0xF0) eip++;
+   if (getUChar(eip) == 0xF0) { 
+      /* VG_(printf)("LOCK LOCK LOCK LOCK LOCK \n"); */
+      eip++;
+   }
 
    /* Crap out if we see a segment override prefix. */
    if (getUChar(eip) == 0x65) {