Index: valgrind-quilt/coregrind/vg_syscalls.c =================================================================== --- valgrind-quilt.orig/coregrind/vg_syscalls.c 2005-05-02 19:04:51.000000000 -0400 +++ valgrind-quilt/coregrind/vg_syscalls.c 2005-06-08 11:18:45.667972208 -0400 @@ -5770,6 +5770,22 @@ { if (SYSRES == 0 && arg3 != 0) POST_MEM_WRITE( arg3, sizeof(vki_old_sigset_t)); +#ifdef __powerpc__ + /* The signal delivery mechanism expects the signal number to be in gpr3. + However, at this point, the sigprocmask return value has overwritten + that value. So here we put the signal number into gpr3, saving the + syscall return value for later restoration (in coregrind/ppc/signal.c). */ + { + ThreadState *tst = VG_(get_ThreadState)(tid);; + if (tst->arch.saved_signal) { + UInt swap; + swap = tst->arch.m_gpr[3]; + tst->arch.m_gpr[3] = tst->arch.saved_signal; + tst->arch.saved_signal = swap; + } else + tst->arch.saved_signal = tst->arch.m_gpr[3]; + } +#endif } PRE(sys_rt_sigprocmask, Special) @@ -5797,6 +5813,22 @@ { if (SYSRES == 0 && arg3 != 0) POST_MEM_WRITE( arg3, sizeof(vki_sigset_t)); +#ifdef __powerpc__ + /* The signal delivery mechanism expects the signal number to be in gpr3. + However, at this point, the sigprocmask return value has overwritten + that value. So here we put the signal number into gpr3, saving the + syscall return value for later restoration (in coregrind/ppc/signal.c). */ + { + ThreadState *tst = VG_(get_ThreadState)(tid);; + if (tst->arch.saved_signal) { + UInt swap; + swap = tst->arch.m_gpr[3]; + tst->arch.m_gpr[3] = tst->arch.saved_signal; + tst->arch.saved_signal = swap; + } else + tst->arch.saved_signal = tst->arch.m_gpr[3]; + } +#endif } PRE(sys_sigpending, 0) Index: valgrind-quilt/coregrind/ppc/signal.c =================================================================== --- valgrind-quilt.orig/coregrind/ppc/signal.c 2005-05-02 08:22:01.000000000 -0400 +++ valgrind-quilt/coregrind/ppc/signal.c 2005-06-08 10:21:46.469876816 -0400 @@ -252,6 +252,10 @@ SET_SIGNAL_GPR(tid, 3, sigNo); tst->arch.m_eip = (Addr) handler; + /* If this is happening in a system call, the system call return value will + overwrite sigNo in gpr3. We need to preserve the signal number + elsewhere. */ + tst->arch.saved_signal = sigNo; } void VGA_(signal_return)(ThreadId tid, Bool has_siginfo) @@ -265,6 +269,10 @@ vg_assert(VG_(is_valid_tid)(tid)); tst = VG_(get_ThreadState)(tid); + + /* Restore syscall return value to gpr3 (saved in POST(sys_rt_sigprocmask) */ + SET_SYSCALL_RETVAL(tid, tst->arch.saved_signal); + tst->arch.saved_signal = 0; /* Check that the stack frame looks valid */ sp = tst->arch.m_gpr[1]; Index: valgrind-quilt/coregrind/ppc/core_arch.h =================================================================== --- valgrind-quilt.orig/coregrind/ppc/core_arch.h 2005-04-07 08:51:34.000000000 -0400 +++ valgrind-quilt/coregrind/ppc/core_arch.h 2005-06-08 10:25:03.073945304 -0400 @@ -113,6 +113,7 @@ Bool vr_live; /* vector state is in machine regs */ Addr dispatch_sp; + UInt saved_signal; /* needed to preserve sigNo during syscall */ } arch_thread_t;