From: Nicholas Nethercote Date: Fri, 5 Jun 2009 01:33:16 +0000 (+0000) Subject: For no apparent reason, the machine-dependent syscall X-Git-Tag: svn/VALGRIND_3_5_0~533 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2314fe1acccefe78f599cf42f2bde7992e7cfd91;p=thirdparty%2Fvalgrind.git For no apparent reason, the machine-dependent syscall thread_fast_set_cthread_self was being called pthread_set_self. This commit fixes this. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10249 --- diff --git a/coregrind/m_syswrap/priv_syswrap-darwin.h b/coregrind/m_syswrap/priv_syswrap-darwin.h index bc8570625e..6dd8cb344b 100644 --- a/coregrind/m_syswrap/priv_syswrap-darwin.h +++ b/coregrind/m_syswrap/priv_syswrap-darwin.h @@ -241,7 +241,7 @@ DECL_TEMPLATE(darwin, swtch); DECL_TEMPLATE(darwin, swtch_pri); // Machine-dependent traps -DECL_TEMPLATE(darwin, pthread_set_self); +DECL_TEMPLATE(darwin, thread_fast_set_cthread_self); // syswrap--darwin.c #include diff --git a/coregrind/m_syswrap/syswrap-darwin.c b/coregrind/m_syswrap/syswrap-darwin.c index 49b8a9a6b6..20d665f0f5 100644 --- a/coregrind/m_syswrap/syswrap-darwin.c +++ b/coregrind/m_syswrap/syswrap-darwin.c @@ -6873,13 +6873,12 @@ static VexGuestX86SegDescr* alloc_zeroed_x86_LDT ( void ) } #endif -PRE(pthread_set_self) +PRE(thread_fast_set_cthread_self) { - PRINT("pthread_set_self ( %#lx )", ARG1); - PRE_REG_READ1(void, "pthread_set_self", struct pthread_t *, self); + PRINT("thread_fast_set_cthread_self ( %#lx )", ARG1); + PRE_REG_READ1(void, "thread_fast_set_cthread_self", struct pthread_t *, self); #if defined(VGA_x86) - // GrP fixme hack this isn't really pthread_set_self // Point the USER_CTHREAD ldt entry (slot 6, reg 0x37) at this pthread { VexGuestX86SegDescr *ldt; @@ -6912,7 +6911,7 @@ PRE(pthread_set_self) // and use that to set the syscall return status. SET_STATUS_from_SysRes( VG_(mk_SysRes_x86_darwin)( - VG_DARWIN_SYSNO_CLASS(__NR_pthread_set_self), + VG_DARWIN_SYSNO_CLASS(__NR_thread_fast_set_cthread_self), False, 0, 0x37 ) ); @@ -6928,7 +6927,7 @@ PRE(pthread_set_self) // see comments on x86 case just above SET_STATUS_from_SysRes( VG_(mk_SysRes_amd64_darwin)( - VG_DARWIN_SYSNO_CLASS(__NR_pthread_set_self), + VG_DARWIN_SYSNO_CLASS(__NR_thread_fast_set_cthread_self), False, 0, 0x60 ) ); @@ -7524,11 +7523,11 @@ const SyscallTableEntry ML_(mach_trap_table)[] = { #if defined(VGA_x86) const SyscallTableEntry ML_(mdep_trap_table)[] = { - MACX_(__NR_pthread_set_self, pthread_set_self), + MACX_(__NR_thread_fast_set_cthread_self, thread_fast_set_cthread_self), }; #elif defined(VGA_amd64) const SyscallTableEntry ML_(mdep_trap_table)[] = { - MACX_(__NR_pthread_set_self, pthread_set_self), + MACX_(__NR_thread_fast_set_cthread_self, thread_fast_set_cthread_self), }; #else #error unknown architecture diff --git a/coregrind/m_syswrap/syswrap-main.c b/coregrind/m_syswrap/syswrap-main.c index 5cd70b7f5a..11f56ec600 100644 --- a/coregrind/m_syswrap/syswrap-main.c +++ b/coregrind/m_syswrap/syswrap-main.c @@ -1622,9 +1622,9 @@ void VG_(post_syscall) (ThreadId tid) when they really should call SET_STATUS_from_SysRes. The former create a UNIX-class syscall result on Darwin, which may not be correct for the syscall; if that's the case then this assertion - fires. See PRE(pthread_set_self) for an example. On non-Darwin - platforms this assertion is should never fail, and this comment - is completely irrelevant. */ + fires. See PRE(thread_fast_set_cthread_self) for an example. On + non-Darwin platforms this assertion is should never fail, and this + comment is completely irrelevant. */ /* Ok, looks sane */ /* Get the system call number. Because the pre-handler isn't diff --git a/exp-ptrcheck/h_main.c b/exp-ptrcheck/h_main.c index fccefe162d..c2c2aa3dba 100644 --- a/exp-ptrcheck/h_main.c +++ b/exp-ptrcheck/h_main.c @@ -2461,7 +2461,7 @@ static void setup_post_syscall_table ( void ) ADD(0, __NR_task_self_trap); // Machine-dependent syscalls. - ADD(0, __NR_pthread_set_self); + ADD(0, __NR_thread_fast_set_cthread_self); /* ------------------------------------ */ diff --git a/include/vki/vki-scnums-darwin.h b/include/vki/vki-scnums-darwin.h index 8046542b08..4dfd22ae25 100644 --- a/include/vki/vki-scnums-darwin.h +++ b/include/vki/vki-scnums-darwin.h @@ -116,18 +116,21 @@ #if defined(VGA_x86) // osfmk/i386/machdep_call.c -// # define __NR_thread_get_cthread_self VG_DARWIN_SYSCALL_CONSTRUCT_MDEP(0) -// # define __NR_thread_set_cthread_self VG_DARWIN_SYSCALL_CONSTRUCT_MDEP(1) -// # define __NR_2 VG_DARWIN_SYSCALL_CONSTRUCT_MDEP(2) -# define __NR_pthread_set_self VG_DARWIN_SYSCALL_CONSTRUCT_MDEP(3) -// # define __NR_thread_set_user_ldt VG_DARWIN_SYSCALL_CONSTRUCT_MDEP(4) -// # define __NR_i386_set_ldt VG_DARWIN_SYSCALL_CONSTRUCT_MDEP(5) -// # define __NR_i386_get_ldt VG_DARWIN_SYSCALL_CONSTRUCT_MDEP(6) +// DDD: the last two are BSD_CALL instead of CALL... +//#define __NR_thread_get_cthread_self VG_DARWIN_SYSCALL_CONSTRUCT_MDEP(0) +//#define __NR_thread_set_cthread_self VG_DARWIN_SYSCALL_CONSTRUCT_MDEP(1) +// 2 is invalid +#define __NR_thread_fast_set_cthread_self VG_DARWIN_SYSCALL_CONSTRUCT_MDEP(3) +//#define __NR_thread_set_user_ldt VG_DARWIN_SYSCALL_CONSTRUCT_MDEP(4) +//#define __NR_i386_set_ldt VG_DARWIN_SYSCALL_CONSTRUCT_MDEP(5) +//#define __NR_i386_get_ldt VG_DARWIN_SYSCALL_CONSTRUCT_MDEP(6) #elif defined(VGA_amd64) // osfmk/i386/machdep_call.c -# define __NR_pthread_set_self VG_DARWIN_SYSCALL_CONSTRUCT_MDEP(3) +// 0, 1, 2 are invalid +#define __NR_thread_fast_set_cthread_self VG_DARWIN_SYSCALL_CONSTRUCT_MDEP(3) +// 4, 5, 6 are invalid #else # error unknown architecture