]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Obsoleted three client requests that were still hanging around from the old
authorNicholas Nethercote <njn@valgrind.org>
Sat, 26 Mar 2005 03:50:14 +0000 (03:50 +0000)
committerNicholas Nethercote <njn@valgrind.org>
Sat, 26 Mar 2005 03:50:14 +0000 (03:50 +0000)
libpthread implementation: USERREQ__READ_MILLISECOND_TIMER, USERREQ__MALLOC,
USERREQ__FREE.

As a consequence, all the PTHREQ macros (eg. VGA_PTHREQ_RET,
SET_PTHREQ_RETVAL) could be removed.  And VG_(tl_malloc_called_by_scheduler)
has been renamed VG_(tl_malloc_called_deliberately) to reflect how its role
has changed.

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

coregrind/amd64/core_arch.h
coregrind/arm/core_arch.h
coregrind/core.h
coregrind/vg_default.c
coregrind/vg_pthreadmodel.c
coregrind/vg_scheduler.c
coregrind/x86/core_arch.h

index 41816308b119b6e6b25864e1521660268ed2ea34..5c9cad8138fb1243c86ee913f11f019c974cb24a 100644 (file)
@@ -57,7 +57,6 @@
 
 #define VGA_CLREQ_ARGS        guest_RAX
 #define VGA_CLREQ_RET         guest_RDX
-#define VGA_PTHREQ_RET        guest_RDX
 
 // Register numbers, for vg_symtab2.c
 #define VGA_R_STACK_PTR       4
index dcddc98cfc9e1db7c60e6ba1df8b65828ab5080f..160a50cb29e2603435167b60eea5160ec29733e4 100644 (file)
@@ -63,7 +63,6 @@
 
 #define VGA_CLREQ_ARGS        guest_R0
 #define VGA_CLREQ_RET         guest_R0
-#define VGA_PTHREQ_RET        guest_R0
 
 // Register numbers, for vg_symtab2.c
 #define VGA_R_STACK_PTR       13
index ad7e0235ca7011e5d6877b69983bc4b349b8b718..3b47f0fd85abbd33b06aff690652b75ab5759b7f 100644 (file)
@@ -408,10 +408,9 @@ extern void  VG_(print_all_arena_stats) ( void );
    request codes.  A few, publically-visible, request codes are also
    defined in valgrind.h, and similar headers for some tools. */
 
+/* Obsolete pthread-related requests */
 #define VG_USERREQ__MALLOC                  0x2001
 #define VG_USERREQ__FREE                    0x2002
-
-/* Obsolete pthread-related requests */
 #define VG_USERREQ__APPLY_IN_NEW_THREAD     0x3001
 #define VG_USERREQ__QUIT                    0x3002
 #define VG_USERREQ__WAIT_JOINER             0x3003
@@ -434,6 +433,7 @@ extern void  VG_(print_all_arena_stats) ( void );
 #define VG_USERREQ__PTHREAD_KEY_DELETE      0x3014
 #define VG_USERREQ__PTHREAD_SETSPECIFIC_PTR 0x3015
 #define VG_USERREQ__PTHREAD_GETSPECIFIC_PTR 0x3016
+#define VG_USERREQ__READ_MILLISECOND_TIMER  0x3017
 #define VG_USERREQ__PTHREAD_SIGMASK         0x3018
 #define VG_USERREQ__SIGWAIT                 0x3019
 #define VG_USERREQ__PTHREAD_KILL            0x301A
@@ -457,8 +457,6 @@ extern void  VG_(print_all_arena_stats) ( void );
 #define VG_USERREQ__PTHREAD_ERROR           0x3102
 
 
-#define VG_USERREQ__READ_MILLISECOND_TIMER  0x3017
-
 /* Internal equivalent of VALGRIND_PRINTF . */
 #define VG_USERREQ__INTERNAL_PRINTF         0x3103
 /* Internal equivalent of VALGRIND_PRINTF_BACKTRACE . (no longer used) */
@@ -502,7 +500,7 @@ struct vg_mallocfunc_info {
    Exports of vg_defaults.c
    ------------------------------------------------------------------ */
 
-extern Bool VG_(tl_malloc_called_by_scheduler);
+extern Bool VG_(tl_malloc_called_deliberately);
 
 
 
@@ -723,14 +721,6 @@ extern Bool VG_(my_fault);
    SET_THREAD_REG(zztid, zzval, CLREQ_RET, post_reg_write_clientcall_return, \
                   zztid, O_CLREQ_RET, sizeof(UWord), f)
 
-#define SET_PTHREQ_ESP(zztid, zzval) \
-   SET_THREAD_REG(zztid, zzval, STACK_PTR, post_reg_write, \
-                  Vg_CorePThread, zztid, O_STACK_PTR, sizeof(Addr))
-
-#define SET_PTHREQ_RETVAL(zztid, zzval) \
-   SET_THREAD_REG(zztid, zzval, PTHREQ_RET, post_reg_write, \
-                  Vg_CorePThread, zztid, O_PTHREQ_RET, sizeof(UWord))
-
 /* ---------------------------------------------------------------------
    Exports of vg_signals.c
    ------------------------------------------------------------------ */
@@ -1653,13 +1643,11 @@ extern Bool VGA_(getArchAndSubArch)( /*OUT*/VexArch*,
 #define STACK_PTR(regs)    ((regs).vex.VGA_STACK_PTR)
 #define FRAME_PTR(regs)    ((regs).vex.VGA_FRAME_PTR)
 #define CLREQ_ARGS(regs)   ((regs).vex.VGA_CLREQ_ARGS)
-#define PTHREQ_RET(regs)   ((regs).vex.VGA_PTHREQ_RET)
 #define CLREQ_RET(regs)    ((regs).vex.VGA_CLREQ_RET)
 // Offsets for the Vex state
 #define O_STACK_PTR        (offsetof(VexGuestArchState, VGA_STACK_PTR))
 #define O_FRAME_PTR        (offsetof(VexGuestArchState, VGA_FRAME_PTR))
 #define O_CLREQ_RET        (offsetof(VexGuestArchState, VGA_CLREQ_RET))
-#define O_PTHREQ_RET       (offsetof(VexGuestArchState, VGA_PTHREQ_RET))
 
 
 // Setting up the initial thread (1) state
index ee5d6300e16e01d8c1a251b45beedd5498c98c83..d9c58b73e2d36495459ed7fbb9139f44b0af7c38 100644 (file)
@@ -70,18 +70,16 @@ void malloc_panic ( const Char* fn )
 __attribute__ ((weak))
 SizeT VG_(vg_malloc_redzone_szB) = 8;
 
-Bool VG_(tl_malloc_called_by_scheduler) = False;
-
-/* If the tool hasn't replaced malloc(), this one can be called from the
-   scheduler, for the USERREQ__MALLOC user request used by vg_libpthread.c. 
-   (Nb: it cannot call glibc's malloc().)  The lock variable ensures that the
-   scheduler is the only place this can be called from;  this ensures that a
-   malloc()-replacing tool cannot forget to implement TL_(malloc)() or
-   TL_(free)().  */
+Bool VG_(tl_malloc_called_deliberately) = False;
+
+/* If the tool hasn't replaced malloc(), this one can be called
+   deliberately.  The lock variable ensures that this isn't called by
+   accident, which could happen if a malloc()-replacing tool forgot to
+   implement TL_(malloc)() or TL_(free)().  */
 __attribute__ ((weak))
 void* TL_(malloc)( ThreadId tid, SizeT size )
 {
-   if (VG_(tl_malloc_called_by_scheduler))
+   if (VG_(tl_malloc_called_deliberately))
       return VG_(cli_malloc)(VG_MIN_MALLOC_SZB, size);
    else 
       malloc_panic(__PRETTY_FUNCTION__);
@@ -91,7 +89,7 @@ __attribute__ ((weak))
 void TL_(free)( ThreadId tid, void* p )
 {
    /* see comment for TL_(malloc)() above */
-   if (VG_(tl_malloc_called_by_scheduler))
+   if (VG_(tl_malloc_called_deliberately))
       VG_(cli_free)(p);
    else 
       malloc_panic(__PRETTY_FUNCTION__);
index b1bcc49857d32ae16ddfef0c6e919321d6cd625f..c7f3120f76d98ff024ef4439ef4e64ec4edca4d6 100644 (file)
@@ -196,9 +196,14 @@ static void *before_pthread_create(va_list va)
 
    tst = VG_(get_ThreadState)(VG_(get_running_tid)());
 
-   VG_(sk_malloc_called_by_scheduler) = True;
-   data = SK_(malloc)(sizeof(*data));
-   VG_(sk_malloc_called_by_scheduler) = False;
+   // XXX: why use TL_(malloc)() here?  What characteristics does this
+   // allocation require?  
+   // [Possible: When using a tool that replaces malloc(), we want to call
+   //  the replacement version.  Otherwise, we want to use VG_(cli_malloc)().
+   //  So we go via the default version of TL_(malloc)() in vg_default?]
+   VG_(tl_malloc_called_deliberately) = True;
+   data = TL_(malloc)(sizeof(*data));
+   VG_(tl_malloc_called_deliberately) = False;
 
    VG_TRACK(pre_mem_write, Vg_CorePThread, tst->tid, "new thread data",
            (Addr)data, sizeof(*data));
index 0599f4bf6789245243eaff4240e8b29827b13124..8ed2a36db76bd6259420629acdb096c27301b6c1 100644 (file)
@@ -1005,37 +1005,10 @@ void do_client_request ( ThreadId tid )
          break;
       }
 
-      /* Note:  for tools that replace malloc() et al, we want to call
-         the replacement versions.  For those that don't, we want to call
-         VG_(cli_malloc)() et al.  We do this by calling SK_(malloc)(), which
-         malloc-replacing tools must replace, but have the default definition
-         of SK_(malloc)() call VG_(cli_malloc)().  */
-
-      /* Note: for MALLOC and FREE, must set the appropriate "lock"... see
-         the comment in vg_defaults.c/SK_(malloc)() for why. */
-      case VG_USERREQ__MALLOC:
-         VG_(tl_malloc_called_by_scheduler) = True;
-         SET_PTHREQ_RETVAL(
-            tid, (Addr)TL_(malloc) ( tid, arg[1] ) 
-         );
-         VG_(tl_malloc_called_by_scheduler) = False;
-         break;
-
-      case VG_USERREQ__FREE:
-         VG_(tl_malloc_called_by_scheduler) = True;
-         TL_(free) ( tid, (void*)arg[1] );
-         VG_(tl_malloc_called_by_scheduler) = False;
-        SET_PTHREQ_RETVAL(tid, 0); /* irrelevant */
-         break;
-
       case VG_USERREQ__RUNNING_ON_VALGRIND:
          SET_CLREQ_RETVAL(tid, RUNNING_ON_VALGRIND+1);
          break;
 
-      case VG_USERREQ__READ_MILLISECOND_TIMER:
-         SET_PTHREQ_RETVAL(tid, VG_(read_millisecond_timer)());
-         break;
-
       case VG_USERREQ__PRINTF: {
          int count = 
             VG_(vmessage)( Vg_ClientMsg, (char *)arg[1], (void*)arg[2] );
@@ -1119,6 +1092,7 @@ void do_client_request ( ThreadId tid )
       case VG_USERREQ__PTHREAD_KEY_DELETE:
       case VG_USERREQ__PTHREAD_SETSPECIFIC_PTR:
       case VG_USERREQ__PTHREAD_GETSPECIFIC_PTR:
+      case VG_USERREQ__READ_MILLISECOND_TIMER:
       case VG_USERREQ__PTHREAD_SIGMASK:
       case VG_USERREQ__SIGWAIT:
       case VG_USERREQ__PTHREAD_KILL:
@@ -1136,6 +1110,8 @@ void do_client_request ( ThreadId tid )
       case VG_USERREQ__GET_SIGRT_MIN:
       case VG_USERREQ__GET_SIGRT_MAX:
       case VG_USERREQ__ALLOC_RTSIG:
+      case VG_USERREQ__MALLOC:
+      case VG_USERREQ__FREE:
         VG_(message)(Vg_UserMsg, "It looks like you've got an old libpthread.so* ");
         VG_(message)(Vg_UserMsg, "installed in \"%s\".", VG_(libdir));
         VG_(message)(Vg_UserMsg, "Please delete it and try again.");
index 683c01ab2f91d8b55af685435b785b786b385f28..69c23c9d61c39ed85876b73d9c4285013e0dbf81 100644 (file)
@@ -57,8 +57,6 @@
 
 #define VGA_CLREQ_ARGS        guest_EAX
 #define VGA_CLREQ_RET         guest_EDX
-#define VGA_PTHREQ_RET        guest_EDX
-
 
 // Register numbers, for vg_symtab2.c
 #define VGA_R_STACK_PTR       4