From: Nicholas Nethercote Date: Sat, 26 Mar 2005 03:50:14 +0000 (+0000) Subject: Obsoleted three client requests that were still hanging around from the old X-Git-Tag: svn/VALGRIND_3_0_0~880 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bb4598350ed80c726e5b8efbc7e58b2b17de6ae1;p=thirdparty%2Fvalgrind.git Obsoleted three client requests that were still hanging around from the old 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 --- diff --git a/coregrind/amd64/core_arch.h b/coregrind/amd64/core_arch.h index 41816308b1..5c9cad8138 100644 --- a/coregrind/amd64/core_arch.h +++ b/coregrind/amd64/core_arch.h @@ -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 diff --git a/coregrind/arm/core_arch.h b/coregrind/arm/core_arch.h index dcddc98cfc..160a50cb29 100644 --- a/coregrind/arm/core_arch.h +++ b/coregrind/arm/core_arch.h @@ -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 diff --git a/coregrind/core.h b/coregrind/core.h index ad7e0235ca..3b47f0fd85 100644 --- a/coregrind/core.h +++ b/coregrind/core.h @@ -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 diff --git a/coregrind/vg_default.c b/coregrind/vg_default.c index ee5d6300e1..d9c58b73e2 100644 --- a/coregrind/vg_default.c +++ b/coregrind/vg_default.c @@ -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__); diff --git a/coregrind/vg_pthreadmodel.c b/coregrind/vg_pthreadmodel.c index b1bcc49857..c7f3120f76 100644 --- a/coregrind/vg_pthreadmodel.c +++ b/coregrind/vg_pthreadmodel.c @@ -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)); diff --git a/coregrind/vg_scheduler.c b/coregrind/vg_scheduler.c index 0599f4bf67..8ed2a36db7 100644 --- a/coregrind/vg_scheduler.c +++ b/coregrind/vg_scheduler.c @@ -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."); diff --git a/coregrind/x86/core_arch.h b/coregrind/x86/core_arch.h index 683c01ab2f..69c23c9d61 100644 --- a/coregrind/x86/core_arch.h +++ b/coregrind/x86/core_arch.h @@ -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