]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add wrappers for shmat() and shmdt() on Darwin. Fixes bug 191271.
authorNicholas Nethercote <njn@valgrind.org>
Wed, 10 Jun 2009 23:26:13 +0000 (23:26 +0000)
committerNicholas Nethercote <njn@valgrind.org>
Wed, 10 Jun 2009 23:26:13 +0000 (23:26 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10297

coregrind/m_syswrap/priv_syswrap-darwin.h
coregrind/m_syswrap/syswrap-amd64-linux.c
coregrind/m_syswrap/syswrap-darwin.c
memcheck/tests/darwin/scalar.c
memcheck/tests/darwin/scalar.stderr.exp

index 7b8642c0fab4115803575677a21ed0b59920af05..840fd08193d1265c4755fd963611ff944523bd36 100644 (file)
@@ -317,9 +317,9 @@ DECL_TEMPLATE(darwin, semop);                   // 256
 // 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
index d11dc2fdc62f7aa72f9af86fb2e27c91b6634abd..b3de9e526c2216eed5d710b4daebbe03a889209e 100644 (file)
@@ -906,7 +906,7 @@ PRE(wrap_sys_shmat)
    if (arg2tmp == 0)
       SET_STATUS_Failure( VKI_EINVAL );
    else
-      ARG2 = arg2tmp;
+      ARG2 = arg2tmp;  // used in POST
 }
 POST(wrap_sys_shmat)
 {
index b1289b5c6a25c35840f3106fb95c189688321660..6189ce05fcb465d75ad4182493a5949f9a17905c 100644 (file)
@@ -1780,10 +1780,22 @@ POST(flistxattr)
    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 @@ POST(shmctl)
    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 @@ const SyscallTableEntry ML_(syscall_table)[] = {
 // _____(__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), 
index 5d65820c2780398130618a589f22a5bc7f76e31e..3df210b6353af3e61b4e51e6f24a288a59bacbdd 100644 (file)
@@ -313,13 +313,18 @@ int main(void)
    // __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");
index 4d62fca770efbaf64853a75dfed1ac6a1443c5e8..f51e8b2a4b7f8754b0c2769b11e4d0a87dbf212e 100644 (file)
@@ -124,6 +124,18 @@ Syscall param exchangedata(path2) points to unaddressable byte(s)
    ...
  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 @@ Syscall param shmctl(IPC_STAT, buf) points to unaddressable byte(s)
    ...
  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
 -----------------------------------------------------