diff options
author | njn <njn@a5019735-40e9-0310-863c-91ae7b9d1cf9> | 2009-06-10 23:26:13 +0000 |
---|---|---|
committer | njn <njn@a5019735-40e9-0310-863c-91ae7b9d1cf9> | 2009-06-10 23:26:13 +0000 |
commit | 631b819596d389e9ad8ea0a0b5926f6107d7b1e0 (patch) | |
tree | 81bfa172a839e7409dad0cda5d22f06948a4dfa9 | |
parent | 2c7e5ca3d43afda2060c4f3a1ad43d945c05ff71 (diff) | |
download | valgrind-631b819596d389e9ad8ea0a0b5926f6107d7b1e0.tar.gz |
Add wrappers for shmat() and shmdt() on Darwin. Fixes bug 191271.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10297 a5019735-40e9-0310-863c-91ae7b9d1cf9
-rw-r--r-- | coregrind/m_syswrap/priv_syswrap-darwin.h | 4 | ||||
-rw-r--r-- | coregrind/m_syswrap/syswrap-amd64-linux.c | 2 | ||||
-rw-r--r-- | coregrind/m_syswrap/syswrap-darwin.c | 40 | ||||
-rw-r--r-- | memcheck/tests/darwin/scalar.c | 5 | ||||
-rw-r--r-- | memcheck/tests/darwin/scalar.stderr.exp | 18 |
5 files changed, 61 insertions, 8 deletions
diff --git a/coregrind/m_syswrap/priv_syswrap-darwin.h b/coregrind/m_syswrap/priv_syswrap-darwin.h index 7b8642c0f..840fd0819 100644 --- a/coregrind/m_syswrap/priv_syswrap-darwin.h +++ b/coregrind/m_syswrap/priv_syswrap-darwin.h @@ -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 diff --git a/coregrind/m_syswrap/syswrap-amd64-linux.c b/coregrind/m_syswrap/syswrap-amd64-linux.c index d11dc2fdc..b3de9e526 100644 --- a/coregrind/m_syswrap/syswrap-amd64-linux.c +++ b/coregrind/m_syswrap/syswrap-amd64-linux.c @@ -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) { diff --git a/coregrind/m_syswrap/syswrap-darwin.c b/coregrind/m_syswrap/syswrap-darwin.c index b1289b5c6..6189ce05f 100644 --- a/coregrind/m_syswrap/syswrap-darwin.c +++ b/coregrind/m_syswrap/syswrap-darwin.c @@ -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), diff --git a/memcheck/tests/darwin/scalar.c b/memcheck/tests/darwin/scalar.c index 5d65820c2..3df210b63 100644 --- a/memcheck/tests/darwin/scalar.c +++ b/memcheck/tests/darwin/scalar.c @@ -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"); diff --git a/memcheck/tests/darwin/scalar.stderr.exp b/memcheck/tests/darwin/scalar.stderr.exp index 4d62fca77..f51e8b2a4 100644 --- a/memcheck/tests/darwin/scalar.stderr.exp +++ b/memcheck/tests/darwin/scalar.stderr.exp @@ -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 ----------------------------------------------------- |