be moved out of $PLATFORM/core_platform.h.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3812
#ifndef __AMD64_LINUX_CORE_PLATFORM_H
#define __AMD64_LINUX_CORE_PLATFORM_H
-//#include "core_platform_asm.h" // platform-specific asm stuff
-//#include "platform_arch.h" // platform-specific tool stuff
-
-/* ---------------------------------------------------------------------
- ucontext stuff
- ------------------------------------------------------------------ */
-
-#define VGP_UCONTEXT_INSTR_PTR(uc) ((uc)->uc_mcontext.rip)
-#define VGP_UCONTEXT_STACK_PTR(uc) ((uc)->uc_mcontext.rsp)
-#define VGP_UCONTEXT_FRAME_PTR(uc) ((uc)->uc_mcontext.rbp)
-#define VGP_UCONTEXT_SYSCALL_NUM(uc) ((uc)->uc_mcontext.rax)
-#define VGP_UCONTEXT_SYSCALL_RET(uc) ((uc)->uc_mcontext.rax)
-
/* ---------------------------------------------------------------------
mmap() stuff
------------------------------------------------------------------ */
#ifndef __ARM_LINUX_CORE_PLATFORM_H
#define __ARM_LINUX_CORE_PLATFORM_H
-//#include "core_platform_asm.h" // platform-specific asm stuff
-//#include "platform_arch.h" // platform-specific tool stuff
-
-/* ---------------------------------------------------------------------
- ucontext stuff
- ------------------------------------------------------------------ */
-
-#define VGP_UCONTEXT_INSTR_PTR(uc) ((uc)->uc_mcontext.arm_pc)
-#define VGP_UCONTEXT_STACK_PTR(uc) ((uc)->uc_mcontext.arm_sp)
-#define VGP_UCONTEXT_FRAME_PTR(uc) ((uc)->uc_mcontext.arm_fp)
-#define VGP_UCONTEXT_SYSCALL_NUM(uc) ((uc)->uc_mcontext.arm_r0)
-
/* ---------------------------------------------------------------------
mmap() stuff
------------------------------------------------------------------ */
*/
/* NB: this is identical to the x86 version */
void VGP_(interrupted_syscall)(ThreadId tid,
- struct vki_ucontext *uc,
+ Word ip, UWord sysnum, UWord sysret,
Bool restart)
{
static const Bool debug = 0;
ThreadState *tst = VG_(get_ThreadState)(tid);
ThreadArchState *th_regs = &tst->arch;
- Word ip = VGP_UCONTEXT_INSTR_PTR(uc);
if (debug)
VG_(printf)("interrupted_syscall: ip=%p; restart=%d eax=%d\n",
- ip, restart, VGP_UCONTEXT_SYSCALL_NUM(uc));
+ ip, restart, sysnum);
if (ip < VGA_(blksys_setup) || ip >= VGA_(blksys_finished)) {
VG_(printf)(" not in syscall (%p - %p)\n", VGA_(blksys_setup), VGA_(blksys_finished));
The saved real CPU %rax has the result, which we need to move
to RAX. */
if (debug)
- VG_(printf)(" completed: ret=%d\n", VGP_UCONTEXT_SYSCALL_RET(uc));
- th_regs->vex.VGP_SYSCALL_RET = VGP_UCONTEXT_SYSCALL_RET(uc);
+ VG_(printf)(" completed: ret=%d\n", sysret);
+ th_regs->vex.VGP_SYSCALL_RET = sysret;
VG_(post_syscall)(tid);
} else if (ip >= VGA_(blksys_committed) && ip < VGA_(blksys_finished)) {
/* Result committed, but the signal mask has not been restored;
*/
/* NB: this is identical to the amd64 version */
void VGP_(interrupted_syscall)(ThreadId tid,
- struct vki_ucontext *uc,
+ Word eip, UWord sysnum, UWord sysret,
Bool restart)
{
static const Bool debug = 0;
ThreadState *tst = VG_(get_ThreadState)(tid);
ThreadArchState *th_regs = &tst->arch;
- Word eip = VGP_UCONTEXT_INSTR_PTR(uc);
if (debug)
VG_(printf)("interrupted_syscall: eip=%p; restart=%d eax=%d\n",
- eip, restart, VGP_UCONTEXT_SYSCALL_NUM(uc));
+ eip, restart, sysnum);
if (eip < VGA_(blksys_setup) || eip >= VGA_(blksys_finished)) {
VG_(printf)(" not in syscall (%p - %p)\n", VGA_(blksys_setup), VGA_(blksys_finished));
The saved real CPU %eax has the result, which we need to move
to EAX. */
if (debug)
- VG_(printf)(" completed: ret=%d\n", VGP_UCONTEXT_SYSCALL_RET(uc));
- th_regs->vex.VGP_SYSCALL_RET = VGP_UCONTEXT_SYSCALL_RET(uc);
+ VG_(printf)(" completed: ret=%d\n", sysret);
+ th_regs->vex.VGP_SYSCALL_RET = sysret;
VG_(post_syscall)(tid);
} else if (eip >= VGA_(blksys_committed) && eip < VGA_(blksys_finished)) {
/* Result committed, but the signal mask has not been restored;
// (either interrupted or finished normally), or False if it was
// restarted (or the signal didn't actually interrupt a syscall).
extern void VGP_(interrupted_syscall)(ThreadId tid,
- struct vki_ucontext *uc,
+ Word eip, UWord sysnum, UWord sysret,
Bool restart);
// Release resources held by this thread
vki_siginfo_t sigs[N_QUEUED_SIGNALS];
} SigQueue;
+#if defined(VGP_x86_linux)
+# define VGP_UCONTEXT_INSTR_PTR(uc) ((uc)->uc_mcontext.eip)
+# define VGP_UCONTEXT_STACK_PTR(uc) ((uc)->uc_mcontext.esp)
+# define VGP_UCONTEXT_FRAME_PTR(uc) ((uc)->uc_mcontext.ebp)
+# define VGP_UCONTEXT_SYSCALL_NUM(uc) ((uc)->uc_mcontext.eax)
+# define VGP_UCONTEXT_SYSCALL_RET(uc) ((uc)->uc_mcontext.eax)
+#elif defined(VGP_amd64_linux)
+# define VGP_UCONTEXT_INSTR_PTR(uc) ((uc)->uc_mcontext.rip)
+# define VGP_UCONTEXT_STACK_PTR(uc) ((uc)->uc_mcontext.rsp)
+# define VGP_UCONTEXT_FRAME_PTR(uc) ((uc)->uc_mcontext.rbp)
+# define VGP_UCONTEXT_SYSCALL_NUM(uc) ((uc)->uc_mcontext.rax)
+# define VGP_UCONTEXT_SYSCALL_RET(uc) ((uc)->uc_mcontext.rax)
+#elif defined(VGP_arm_linux)
+# define VGP_UCONTEXT_INSTR_PTR(uc) ((uc)->uc_mcontext.arm_pc)
+# define VGP_UCONTEXT_STACK_PTR(uc) ((uc)->uc_mcontext.arm_sp)
+# define VGP_UCONTEXT_FRAME_PTR(uc) ((uc)->uc_mcontext.arm_fp)
+# define VGP_UCONTEXT_SYSCALL_NUM(uc) ((uc)->uc_mcontext.arm_r0)
+# error VGP_UCONTEXT_SYSCALL_RET undefined for ARM/Linux
+#else
+# error Unknown platform
+#endif
+
/* ---------------------------------------------------------------------
HIGH LEVEL STUFF TO DO WITH SIGNALS: POLICY (MOSTLY)
------------------------------------------------------------------ */
sigNo, tid, info->si_code);
/* Update thread state properly */
- VGP_(interrupted_syscall)(tid, uc,
+ VGP_(interrupted_syscall)(tid,
+ VGP_UCONTEXT_INSTR_PTR(uc),
+ VGP_UCONTEXT_SYSCALL_NUM(uc),
+ VGP_UCONTEXT_SYSCALL_RET(uc),
!!(scss.scss_per_sig[sigNo].scss_flags & VKI_SA_RESTART));
/* Set up the thread's state to deliver a signal */
#ifndef __X86_LINUX_CORE_PLATFORM_H
#define __X86_LINUX_CORE_PLATFORM_H
-//#include "core_platform_asm.h" // platform-specific asm stuff
-//#include "platform_arch.h" // platform-specific tool stuff
-
-/* ---------------------------------------------------------------------
- ucontext stuff
- ------------------------------------------------------------------ */
-
-#define VGP_UCONTEXT_INSTR_PTR(uc) ((uc)->uc_mcontext.eip)
-#define VGP_UCONTEXT_STACK_PTR(uc) ((uc)->uc_mcontext.esp)
-#define VGP_UCONTEXT_FRAME_PTR(uc) ((uc)->uc_mcontext.ebp)
-#define VGP_UCONTEXT_SYSCALL_NUM(uc) ((uc)->uc_mcontext.eax)
-#define VGP_UCONTEXT_SYSCALL_RET(uc) ((uc)->uc_mcontext.eax)
-
/* ---------------------------------------------------------------------
mmap() stuff
------------------------------------------------------------------ */