|
From: <sv...@va...> - 2006-12-18 15:22:51
|
Author: tom
Date: 2006-12-18 15:22:46 +0000 (Mon, 18 Dec 2006)
New Revision: 6410
Log:
Improve prctl support - based on patch from Eric Pouech in bug #138627.
Modified:
trunk/coregrind/m_syswrap/syswrap-amd64-linux.c
trunk/coregrind/m_syswrap/syswrap-linux.c
trunk/coregrind/m_syswrap/syswrap-ppc32-linux.c
trunk/coregrind/m_syswrap/syswrap-x86-linux.c
trunk/include/vki/vki-linux.h
Modified: trunk/coregrind/m_syswrap/syswrap-amd64-linux.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_syswrap/syswrap-amd64-linux.c 2006-12-17 19:36:06 U=
TC (rev 6409)
+++ trunk/coregrind/m_syswrap/syswrap-amd64-linux.c 2006-12-18 15:22:46 U=
TC (rev 6410)
@@ -1189,7 +1189,7 @@
=20
// (__NR_pivot_root, sys_pivot_root), // 155=20
LINXY(__NR__sysctl, sys_sysctl), // 156=20
- LINX_(__NR_prctl, sys_prctl), // 157=20
+ LINXY(__NR_prctl, sys_prctl), // 157=20
PLAX_(__NR_arch_prctl, sys_arch_prctl), // 158=20
// (__NR_adjtimex, sys_adjtimex), // 159=20
=20
Modified: trunk/coregrind/m_syswrap/syswrap-linux.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_syswrap/syswrap-linux.c 2006-12-17 19:36:06 UTC (re=
v 6409)
+++ trunk/coregrind/m_syswrap/syswrap-linux.c 2006-12-18 15:22:46 UTC (re=
v 6410)
@@ -699,15 +699,99 @@
PRE(sys_prctl)
{
*flags |=3D 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, AR=
G5 );
+ 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, arg=
3,
+ 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;
+ }
+}
=20
PRE(sys_sendfile)
{
Modified: trunk/coregrind/m_syswrap/syswrap-ppc32-linux.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_syswrap/syswrap-ppc32-linux.c 2006-12-17 19:36:06 U=
TC (rev 6409)
+++ trunk/coregrind/m_syswrap/syswrap-ppc32-linux.c 2006-12-18 15:22:46 U=
TC (rev 6410)
@@ -1683,7 +1683,7 @@
//..=20
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
=20
Modified: trunk/coregrind/m_syswrap/syswrap-x86-linux.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_syswrap/syswrap-x86-linux.c 2006-12-17 19:36:06 UTC=
(rev 6409)
+++ trunk/coregrind/m_syswrap/syswrap-x86-linux.c 2006-12-18 15:22:46 UTC=
(rev 6410)
@@ -2004,7 +2004,7 @@
//zz=20
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 o=
nly?
LINXY(__NR_rt_sigaction, sys_rt_sigaction), // 174
=20
Modified: trunk/include/vki/vki-linux.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/include/vki/vki-linux.h 2006-12-17 19:36:06 UTC (rev 6409)
+++ trunk/include/vki/vki-linux.h 2006-12-18 15:22:46 UTC (rev 6410)
@@ -314,6 +314,8 @@
int sched_priority;
};
=20
+#define VKI_TASK_COMM_LEN 16
+
//----------------------------------------------------------------------
// From linux-2.6.8.1/include/asm-generic/siginfo.h
//----------------------------------------------------------------------
@@ -2185,6 +2187,58 @@
#define VKI_VT_LOCKSWITCH 0x560B /* disallow vt switching */
#define VKI_VT_UNLOCKSWITCH 0x560C /* allow vt switching */
=20
+//----------------------------------------------------------------------
+// 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 si=
gnal */
+
+#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 acce=
sses */
+# define VKI_PR_UNALIGN_SIGBUS 2 /* generate SIGBUS on unaligned user ac=
cess */
+
+#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 access=
es */
+# define VKI_PR_FPEMU_SIGFPE 2 /* don't emulate fp operations, send SIGF=
PE 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 enab=
les */
+# 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 t=
iming */
+# 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
=20
/*--------------------------------------------------------------------*/
|