mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-04 02:18:37 +00:00
Localized use of VGP_UCONTEXT_* to vg_signals.c, which meant they could
be moved out of $PLATFORM/core_platform.h. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3812
This commit is contained in:
parent
61cf579216
commit
e24ef1ffba
@ -32,19 +32,6 @@
|
||||
#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
|
||||
------------------------------------------------------------------ */
|
||||
|
||||
@ -32,18 +32,6 @@
|
||||
#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
|
||||
------------------------------------------------------------------ */
|
||||
|
||||
@ -108,18 +108,17 @@ static void restart_syscall(ThreadArchState *arch)
|
||||
*/
|
||||
/* 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));
|
||||
@ -149,8 +148,8 @@ void VGP_(interrupted_syscall)(ThreadId tid,
|
||||
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;
|
||||
|
||||
@ -107,18 +107,17 @@ static void restart_syscall(ThreadArchState *arch)
|
||||
*/
|
||||
/* 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));
|
||||
@ -148,8 +147,8 @@ void VGP_(interrupted_syscall)(ThreadId tid,
|
||||
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;
|
||||
|
||||
@ -48,7 +48,7 @@ extern void VG_(post_syscall) ( ThreadId tid );
|
||||
// (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
|
||||
|
||||
@ -113,6 +113,28 @@ typedef struct SigQueue {
|
||||
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)
|
||||
------------------------------------------------------------------ */
|
||||
@ -1584,7 +1606,10 @@ void async_signalhandler ( Int sigNo, vki_siginfo_t *info, struct vki_ucontext *
|
||||
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 */
|
||||
|
||||
@ -32,19 +32,6 @@
|
||||
#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
|
||||
------------------------------------------------------------------ */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user