|
From: <sv...@va...> - 2009-06-10 23:26:19
|
Author: njn
Date: 2009-06-11 00:26:13 +0100 (Thu, 11 Jun 2009)
New Revision: 10297
Log:
Add wrappers for shmat() and shmdt() on Darwin. Fixes bug 191271.
Modified:
trunk/coregrind/m_syswrap/priv_syswrap-darwin.h
trunk/coregrind/m_syswrap/syswrap-amd64-linux.c
trunk/coregrind/m_syswrap/syswrap-darwin.c
trunk/memcheck/tests/darwin/scalar.c
trunk/memcheck/tests/darwin/scalar.stderr.exp
Modified: trunk/coregrind/m_syswrap/priv_syswrap-darwin.h
===================================================================
--- trunk/coregrind/m_syswrap/priv_syswrap-darwin.h 2009-06-10 23:09:40 UTC (rev 10296)
+++ trunk/coregrind/m_syswrap/priv_syswrap-darwin.h 2009-06-10 23:26:13 UTC (rev 10297)
@@ -317,9 +317,9 @@
// NYI msgget 259
// NYI msgsnd 260
// NYI msgrcv 261
-// NYI shmat 262
+DECL_TEMPLATE(darwin, shmat); // 262
DECL_TEMPLATE(darwin, shmctl); // 263
-// NYI shmdt 264
+DECL_TEMPLATE(darwin, shmdt); // 264
DECL_TEMPLATE(darwin, shmget); // 265
DECL_TEMPLATE(darwin, shm_open); // 266
// NYI shm_unlink 267
Modified: trunk/coregrind/m_syswrap/syswrap-amd64-linux.c
===================================================================
--- trunk/coregrind/m_syswrap/syswrap-amd64-linux.c 2009-06-10 23:09:40 UTC (rev 10296)
+++ trunk/coregrind/m_syswrap/syswrap-amd64-linux.c 2009-06-10 23:26:13 UTC (rev 10297)
@@ -906,7 +906,7 @@
if (arg2tmp == 0)
SET_STATUS_Failure( VKI_EINVAL );
else
- ARG2 = arg2tmp;
+ ARG2 = arg2tmp; // used in POST
}
POST(wrap_sys_shmat)
{
Modified: trunk/coregrind/m_syswrap/syswrap-darwin.c
===================================================================
--- trunk/coregrind/m_syswrap/syswrap-darwin.c 2009-06-10 23:09:40 UTC (rev 10296)
+++ trunk/coregrind/m_syswrap/syswrap-darwin.c 2009-06-10 23:26:13 UTC (rev 10297)
@@ -1780,11 +1780,23 @@
POST_MEM_WRITE( ARG2, (vki_ssize_t)RES );
}
-PRE(shmget)
+
+PRE(shmat)
{
- PRINT("shmget ( %ld, %ld, %ld )",ARG1,ARG2,ARG3);
- PRE_REG_READ3(long, "shmget", vki_key_t, key, vki_size_t, size, int, shmflg);
+ UWord arg2tmp;
+ PRINT("shmat ( %ld, %#lx, %ld )",ARG1,ARG2,ARG3);
+ PRE_REG_READ3(long, "shmat",
+ int, shmid, const void *, shmaddr, int, shmflg);
+ arg2tmp = ML_(generic_PRE_sys_shmat)(tid, ARG1,ARG2,ARG3);
+ if (arg2tmp == 0)
+ SET_STATUS_Failure( VKI_EINVAL );
+ else
+ ARG2 = arg2tmp; // used in POST
}
+POST(shmat)
+{
+ ML_(generic_POST_sys_shmat)(tid, RES,ARG1,ARG2,ARG3);
+}
PRE(shmctl)
{
@@ -1798,6 +1810,24 @@
ML_(generic_POST_sys_shmctl)(tid, RES,ARG1,ARG2,ARG3);
}
+PRE(shmdt)
+{
+ PRINT("shmdt ( %#lx )",ARG1);
+ PRE_REG_READ1(long, "shmdt", const void *, shmaddr);
+ if (!ML_(generic_PRE_sys_shmdt)(tid, ARG1))
+ SET_STATUS_Failure( VKI_EINVAL );
+}
+POST(shmdt)
+{
+ ML_(generic_POST_sys_shmdt)(tid, RES,ARG1);
+}
+
+PRE(shmget)
+{
+ PRINT("shmget ( %ld, %ld, %ld )",ARG1,ARG2,ARG3);
+ PRE_REG_READ3(long, "shmget", vki_key_t, key, vki_size_t, size, int, shmflg);
+}
+
PRE(shm_open)
{
PRINT("shm_open(%#lx(%s), %ld, %ld)", ARG1, (char *)ARG1, ARG2, ARG3);
@@ -7216,9 +7246,9 @@
// _____(__NR_msgget),
// _____(__NR_msgsnd), // 260
// _____(__NR_msgrcv),
-// _____(__NR_shmat),
+ MACXY(__NR_shmat, shmat),
MACXY(__NR_shmctl, shmctl),
-// _____(__NR_shmdt),
+ MACXY(__NR_shmdt, shmdt),
MACX_(__NR_shmget, shmget),
MACXY(__NR_shm_open, shm_open),
// _____(__NR_shm_unlink),
Modified: trunk/memcheck/tests/darwin/scalar.c
===================================================================
--- trunk/memcheck/tests/darwin/scalar.c 2009-06-10 23:09:40 UTC (rev 10296)
+++ trunk/memcheck/tests/darwin/scalar.c 2009-06-10 23:26:13 UTC (rev 10297)
@@ -313,13 +313,18 @@
// __NR_msgget 259
// __NR_msgsnd 260
// __NR_msgrcv 261
+
// __NR_shmat 262
+ GO(__NR_shmat, "3s 0m");
+ SY(__NR_shmat, x0, x0, x0); FAIL;
// __NR_shmctl 263
GO(__NR_shmctl, "3s 1m");
SY(__NR_shmctl, x0, x0+IPC_STAT, x0+1); FAIL;
// __NR_shmdt 264
+ GO(__NR_shmdt, "1s 0m");
+ SY(__NR_shmdt, x0); FAIL;
// __NR_shmget 265
GO(__NR_shmget, "3s 0m");
Modified: trunk/memcheck/tests/darwin/scalar.stderr.exp
===================================================================
--- trunk/memcheck/tests/darwin/scalar.stderr.exp 2009-06-10 23:09:40 UTC (rev 10296)
+++ trunk/memcheck/tests/darwin/scalar.stderr.exp 2009-06-10 23:26:13 UTC (rev 10297)
@@ -124,6 +124,18 @@
...
Address 0x........ is not stack'd, malloc'd or (recently) free'd
-----------------------------------------------------
+x2000106(262): __NR_shmat 3s 0m
+-----------------------------------------------------
+
+Syscall param shmat(shmid) contains uninitialised byte(s)
+ ...
+
+Syscall param shmat(shmaddr) contains uninitialised byte(s)
+ ...
+
+Syscall param shmat(shmflg) contains uninitialised byte(s)
+ ...
+-----------------------------------------------------
x2000107(263): __NR_shmctl 3s 1m
-----------------------------------------------------
@@ -140,6 +152,12 @@
...
Address 0x........ is not stack'd, malloc'd or (recently) free'd
-----------------------------------------------------
+x2000108(264): __NR_shmdt 1s 0m
+-----------------------------------------------------
+
+Syscall param shmdt(shmaddr) contains uninitialised byte(s)
+ ...
+-----------------------------------------------------
x2000109(265): __NR_shmget 3s 0m
-----------------------------------------------------
|