From: Julian Seward Date: Tue, 26 Dec 2006 04:03:36 +0000 (+0000) Subject: Merge r6410 (Enhancement of prctl ioctl) X-Git-Tag: svn/VALGRIND_3_2_2~48 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9388fac67584ff07eddcfeed0be3c38a995726d2;p=thirdparty%2Fvalgrind.git Merge r6410 (Enhancement of prctl ioctl) git-svn-id: svn://svn.valgrind.org/valgrind/branches/VALGRIND_3_2_BRANCH@6432 --- diff --git a/coregrind/m_syswrap/syswrap-amd64-linux.c b/coregrind/m_syswrap/syswrap-amd64-linux.c index 7af579970e..519b1bb371 100644 --- a/coregrind/m_syswrap/syswrap-amd64-linux.c +++ b/coregrind/m_syswrap/syswrap-amd64-linux.c @@ -1189,7 +1189,7 @@ const SyscallTableEntry ML_(syscall_table)[] = { // (__NR_pivot_root, sys_pivot_root), // 155 LINXY(__NR__sysctl, sys_sysctl), // 156 - LINX_(__NR_prctl, sys_prctl), // 157 + LINXY(__NR_prctl, sys_prctl), // 157 PLAX_(__NR_arch_prctl, sys_arch_prctl), // 158 // (__NR_adjtimex, sys_adjtimex), // 159 diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c index 7a774458c4..a905ab1cac 100644 --- a/coregrind/m_syswrap/syswrap-linux.c +++ b/coregrind/m_syswrap/syswrap-linux.c @@ -698,14 +698,98 @@ POST(sys_sysctl) PRE(sys_prctl) { *flags |= SfMayBlock; - PRINT( "prctl ( %d, %d, %d, %d, %d )", ARG1, ARG2, ARG3, ARG4, ARG5 ); - // XXX: too simplistic, often not all args are used - // Nb: can't use "ARG2".."ARG5" here because that's our own macro... - PRE_REG_READ5(long, "prctl", - int, option, unsigned long, arg2, unsigned long, arg3, - unsigned long, arg4, unsigned long, arg5); - // XXX: totally wrong... we need to look at the 'option' arg, and do - // PRE_MEM_READs/PRE_MEM_WRITEs as necessary... + PRINT( "sys_prctl ( %d, %d, %d, %d, %d )", ARG1, ARG2, ARG3, ARG4, ARG5 ); + switch (ARG1) { + case VKI_PR_SET_PDEATHSIG: + PRE_REG_READ2(int, "prctl", int, option, int, signal); + break; + case VKI_PR_GET_PDEATHSIG: + PRE_REG_READ2(int, "prctl", int, option, int *, signal); + PRE_MEM_WRITE("prctl(get-death-signal)", ARG2, sizeof(Int)); + break; + case VKI_PR_GET_DUMPABLE: + PRE_REG_READ1(int, "prctl", int, option); + break; + case VKI_PR_SET_DUMPABLE: + PRE_REG_READ2(int, "prctl", int, option, int, dump); + break; + case VKI_PR_GET_UNALIGN: + PRE_REG_READ2(int, "prctl", int, option, int *, value); + PRE_MEM_WRITE("prctl(get-unalign)", ARG2, sizeof(Int)); + break; + case VKI_PR_SET_UNALIGN: + PRE_REG_READ2(int, "prctl", int, option, int, value); + break; + case VKI_PR_GET_KEEPCAPS: + PRE_REG_READ1(int, "prctl", int, option); + break; + case VKI_PR_SET_KEEPCAPS: + PRE_REG_READ2(int, "prctl", int, option, int, keepcaps); + break; + case VKI_PR_GET_FPEMU: + PRE_REG_READ2(int, "prctl", int, option, int *, value); + PRE_MEM_WRITE("prctl(get-fpemu)", ARG2, sizeof(Int)); + break; + case VKI_PR_SET_FPEMU: + PRE_REG_READ2(int, "prctl", int, option, int, value); + break; + case VKI_PR_GET_FPEXC: + PRE_REG_READ2(int, "prctl", int, option, int *, value); + PRE_MEM_WRITE("prctl(get-fpexc)", ARG2, sizeof(Int)); + break; + case VKI_PR_SET_FPEXC: + PRE_REG_READ2(int, "prctl", int, option, int, value); + break; + case VKI_PR_GET_TIMING: + PRE_REG_READ1(int, "prctl", int, option); + break; + case VKI_PR_SET_TIMING: + PRE_REG_READ2(int, "prctl", int, option, int, timing); + break; + case VKI_PR_SET_NAME: + PRE_REG_READ2(int, "prctl", int, option, char *, name); + PRE_MEM_RASCIIZ("prctl(set-name)", ARG2); + break; + case VKI_PR_GET_NAME: + PRE_REG_READ2(int, "prctl", int, option, char *, name); + PRE_MEM_WRITE("prctl(get-name)", ARG2, VKI_TASK_COMM_LEN); + break; + case VKI_PR_GET_ENDIAN: + PRE_REG_READ2(int, "prctl", int, option, int *, value); + PRE_MEM_WRITE("prctl(get-endian)", ARG2, sizeof(Int)); + break; + case VKI_PR_SET_ENDIAN: + PRE_REG_READ2(int, "prctl", int, option, int, value); + break; + default: + PRE_REG_READ5(long, "prctl", + int, option, unsigned long, arg2, unsigned long, arg3, + unsigned long, arg4, unsigned long, arg5); + break; + } +} +POST(sys_prctl) +{ + switch (ARG1) { + case VKI_PR_GET_PDEATHSIG: + POST_MEM_WRITE(ARG2, sizeof(Int)); + break; + case VKI_PR_GET_UNALIGN: + POST_MEM_WRITE(ARG2, sizeof(Int)); + break; + case VKI_PR_GET_FPEMU: + POST_MEM_WRITE(ARG2, sizeof(Int)); + break; + case VKI_PR_GET_FPEXC: + POST_MEM_WRITE(ARG2, sizeof(Int)); + break; + case VKI_PR_GET_NAME: + POST_MEM_WRITE(ARG2, VKI_TASK_COMM_LEN); + break; + case VKI_PR_GET_ENDIAN: + POST_MEM_WRITE(ARG2, sizeof(Int)); + break; + } } PRE(sys_sendfile) diff --git a/coregrind/m_syswrap/syswrap-ppc32-linux.c b/coregrind/m_syswrap/syswrap-ppc32-linux.c index 393cc89793..e1aca9b256 100644 --- a/coregrind/m_syswrap/syswrap-ppc32-linux.c +++ b/coregrind/m_syswrap/syswrap-ppc32-linux.c @@ -1683,7 +1683,7 @@ const SyscallTableEntry ML_(syscall_table)[] = { //.. LINX_(__NR_setresgid, sys_setresgid), // 169 LINXY(__NR_getresgid, sys_getresgid), // 170 - LINX_(__NR_prctl, sys_prctl), // 171 + LINXY(__NR_prctl, sys_prctl), // 171 PLAX_(__NR_rt_sigreturn, sys_rt_sigreturn), // 172 LINXY(__NR_rt_sigaction, sys_rt_sigaction), // 173 diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c index 228fb47d9e..d7df31ac43 100644 --- a/coregrind/m_syswrap/syswrap-x86-linux.c +++ b/coregrind/m_syswrap/syswrap-x86-linux.c @@ -2004,7 +2004,7 @@ const SyscallTableEntry ML_(syscall_table)[] = { //zz LINX_(__NR_setresgid, sys_setresgid16), // 170 LINXY(__NR_getresgid, sys_getresgid16), // 171 - LINX_(__NR_prctl, sys_prctl), // 172 + LINXY(__NR_prctl, sys_prctl), // 172 PLAX_(__NR_rt_sigreturn, sys_rt_sigreturn), // 173 x86/Linux only? LINXY(__NR_rt_sigaction, sys_rt_sigaction), // 174 diff --git a/include/vki-linux.h b/include/vki-linux.h index 7066709a0b..9de6eb3715 100644 --- a/include/vki-linux.h +++ b/include/vki-linux.h @@ -299,6 +299,8 @@ struct vki_sched_param { int sched_priority; }; +#define VKI_TASK_COMM_LEN 16 + //---------------------------------------------------------------------- // From linux-2.6.8.1/include/asm-generic/siginfo.h //---------------------------------------------------------------------- @@ -2121,8 +2123,6 @@ struct vki_serial_icounter_struct { int reserved[9]; }; -#endif // __VKI_LINUX_H - //---------------------------------------------------------------------- // From linux-2.6.16/include/linux/vt.h //---------------------------------------------------------------------- @@ -2172,6 +2172,60 @@ struct vki_vt_consize { #define VKI_VT_LOCKSWITCH 0x560B /* disallow vt switching */ #define VKI_VT_UNLOCKSWITCH 0x560C /* allow vt switching */ +//---------------------------------------------------------------------- +// From linux-2.6.19/include/linux/prctl.h +//---------------------------------------------------------------------- + +#define VKI_PR_SET_PDEATHSIG 1 /* Second arg is a signal */ +#define VKI_PR_GET_PDEATHSIG 2 /* Second arg is a ptr to return the signal */ + +#define VKI_PR_GET_DUMPABLE 3 +#define VKI_PR_SET_DUMPABLE 4 + +#define VKI_PR_GET_UNALIGN 5 +#define VKI_PR_SET_UNALIGN 6 +# define VKI_PR_UNALIGN_NOPRINT 1 /* silently fix up unaligned user accesses */ +# define VKI_PR_UNALIGN_SIGBUS 2 /* generate SIGBUS on unaligned user access */ + +#define VKI_PR_GET_KEEPCAPS 7 +#define VKI_PR_SET_KEEPCAPS 8 + +#define VKI_PR_GET_FPEMU 9 +#define VKI_PR_SET_FPEMU 10 +# define VKI_PR_FPEMU_NOPRINT 1 /* silently emulate fp operations accesses */ +# define VKI_PR_FPEMU_SIGFPE 2 /* don't emulate fp operations, send SIGFPE instead */ + +#define VKI_PR_GET_FPEXC 11 +#define VKI_PR_SET_FPEXC 12 +# define VKI_PR_FP_EXC_SW_ENABLE 0x80 /* Use FPEXC for FP exception enables */ +# define VKI_PR_FP_EXC_DIV 0x010000 /* floating point divide by zero */ +# define VKI_PR_FP_EXC_OVF 0x020000 /* floating point overflow */ +# define VKI_PR_FP_EXC_UND 0x040000 /* floating point underflow */ +# define VKI_PR_FP_EXC_RES 0x080000 /* floating point inexact result */ +# define VKI_PR_FP_EXC_INV 0x100000 /* floating point invalid operation */ +# define VKI_PR_FP_EXC_DISABLED 0 /* FP exceptions disabled */ +# define VKI_PR_FP_EXC_NONRECOV 1 /* async non-recoverable exc. mode */ +# define VKI_PR_FP_EXC_ASYNC 2 /* async recoverable exception mode */ +# define VKI_PR_FP_EXC_PRECISE 3 /* precise exception mode */ + +#define VKI_PR_GET_TIMING 13 +#define VKI_PR_SET_TIMING 14 +# define VKI_PR_TIMING_STATISTICAL 0 /* Normal, traditional, + statistical process timing */ +# define VKI_PR_TIMING_TIMESTAMP 1 /* Accurate timestamp based + process timing */ + +#define VKI_PR_SET_NAME 15 /* Set process name */ +#define VKI_PR_GET_NAME 16 /* Get process name */ + +#define VKI_PR_GET_ENDIAN 19 +#define VKI_PR_SET_ENDIAN 20 +# define VKI_PR_ENDIAN_BIG 0 +# define VKI_PR_ENDIAN_LITTLE 1 /* True little endian mode */ +# define VKI_PR_ENDIAN_PPC_LITTLE 2 /* "PowerPC" pseudo little endian */ + +#endif // __VKI_LINUX_H + /*--------------------------------------------------------------------*/ /*--- end ---*/ /*--------------------------------------------------------------------*/