From: Nicholas Nethercote Date: Wed, 24 Jun 2009 06:25:36 +0000 (+0000) Subject: Add support for various aio_*() syscalls on Darwin. With them, Quicktime X-Git-Tag: svn/VALGRIND_3_5_0~475 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5e7562af08af0849d66f5abaa4222a0a5541ac26;p=thirdparty%2Fvalgrind.git Add support for various aio_*() syscalls on Darwin. With them, Quicktime runs, albeit incredibly slowly. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10371 --- diff --git a/coregrind/m_syswrap/priv_syswrap-darwin.h b/coregrind/m_syswrap/priv_syswrap-darwin.h index 840fd08193..0803a43ca0 100644 --- a/coregrind/m_syswrap/priv_syswrap-darwin.h +++ b/coregrind/m_syswrap/priv_syswrap-darwin.h @@ -369,12 +369,12 @@ DECL_TEMPLATE(darwin, settid); // 285 // NYI settid_with_pid 311 // NYI __pthread_cond_timedwait 312 // NYI aio_fsync 313 -// NYI aio_return 314 -// NYI aio_suspend 315 +DECL_TEMPLATE(darwin, aio_return); // 314 +DECL_TEMPLATE(darwin, aio_suspend); // 315 // NYI aio_cancel 316 -// NYI aio_error 317 -// NYI aio_read 318 -// NYI aio_write 319 +DECL_TEMPLATE(darwin, aio_error); // 317 +DECL_TEMPLATE(darwin, aio_read); // 318 +DECL_TEMPLATE(darwin, aio_write); // 319 // NYI lio_listio 320 // NYI __pthread_cond_wait 321 // NYI iopolicysys 322 diff --git a/coregrind/m_syswrap/syswrap-darwin.c b/coregrind/m_syswrap/syswrap-darwin.c index 3bdc01a676..147e34b7ad 100644 --- a/coregrind/m_syswrap/syswrap-darwin.c +++ b/coregrind/m_syswrap/syswrap-darwin.c @@ -3355,6 +3355,51 @@ PRE(sigsuspend) } +PRE(aio_return) +{ + // This assumes that the kernel looks at the struct pointer, but not the + // contents of the struct. + PRINT( "aio_return ( %#lx )", ARG1 ); + PRE_REG_READ1(long, "aio_return", struct vki_aiocb*, aiocbp); +} + +PRE(aio_suspend) +{ + // This assumes that the kernel looks at the struct pointers in the list, + // but not the contents of the structs. + PRINT( "aio_suspend ( %#lx )", ARG1 ); + PRE_REG_READ3(long, "aio_suspend", + const struct vki_aiocb *, aiocbp, int, nent, + const struct vki_timespec *, timeout); + if (ARG2 > 0) + PRE_MEM_READ("aio_suspend(list)", ARG1, ARG2 * sizeof(struct vki_aiocb *)); + if (ARG3) + PRE_MEM_READ ("aio_suspend(timeout)", ARG3, sizeof(struct vki_timespec)); +} + +PRE(aio_error) +{ + // This assumes that the kernel looks at the struct pointer, but not the + // contents of the struct. + PRINT( "aio_error ( %#lx )", ARG1 ); + PRE_REG_READ1(long, "aio_error", struct vki_aiocb*, aiocbp); +} + +PRE(aio_read) +{ + PRINT( "aio_read ( %#lx )", ARG1 ); + PRE_REG_READ1(long, "aio_read", struct vki_aiocb*, aiocbp); + PRE_MEM_READ( "aio_read(aiocbp)", ARG1, sizeof(struct vki_aiocb)); +} + +PRE(aio_write) +{ + PRINT( "aio_write ( %#lx )", ARG1 ); + PRE_REG_READ1(long, "aio_write", struct vki_aiocb*, aiocbp); + PRE_MEM_READ( "aio_write(aiocbp)", ARG1, sizeof(struct vki_aiocb)); +} + + /* --------------------------------------------------------------------- mach_msg: formatted messages ------------------------------------------------------------------ */ @@ -7300,12 +7345,12 @@ const SyscallTableEntry ML_(syscall_table)[] = { // _____(__NR_settid_with_pid), // _____(__NR___pthread_cond_timedwait), // _____(__NR_aio_fsync), -// _____(__NR_aio_return), -// _____(__NR_aio_suspend), + MACX_(__NR_aio_return, aio_return), + MACX_(__NR_aio_suspend, aio_suspend), // _____(__NR_aio_cancel), -// _____(__NR_aio_error), -// _____(__NR_aio_read), -// _____(__NR_aio_write), + MACX_(__NR_aio_error, aio_error), + MACX_(__NR_aio_read, aio_read), + MACX_(__NR_aio_write, aio_write), // _____(__NR_lio_listio), // 320 // _____(__NR___pthread_cond_wait), // _____(__NR_iopolicysys), diff --git a/include/vki/vki-darwin.h b/include/vki/vki-darwin.h index cf5e5422b5..e65881d81a 100644 --- a/include/vki/vki-darwin.h +++ b/include/vki/vki-darwin.h @@ -1020,4 +1020,8 @@ struct ByteRangeLockPB2 #define VKI_A_SETKAUDIT A_SETKAUDIT +#include + +#define vki_aiocb aiocb + #endif diff --git a/memcheck/tests/darwin/scalar.c b/memcheck/tests/darwin/scalar.c index 6c43caf984..6015bbfd21 100644 --- a/memcheck/tests/darwin/scalar.c +++ b/memcheck/tests/darwin/scalar.c @@ -537,12 +537,24 @@ int main(void) // __NR_settid_with_pid 311 // __NR___pthread_cond_timedwait 312 // __NR_aio_fsync 313 - // __NR_aio_return 314 - // __NR_aio_suspend 315 + + GO(__NR_aio_return, 314, "1s 0m"); + SY(__NR_aio_return, x0); FAIL; + + GO(__NR_aio_suspend, 315, "1s 0m"); + SY(__NR_aio_suspend, x0, x0+1, x0); FAIL; + // __NR_aio_cancel 316 - // __NR_aio_error 317 - // __NR_aio_read 318 - // __NR_aio_write 319 + + GO(__NR_aio_error, 317, "1s 0m"); + SY(__NR_aio_error, x0); FAIL; + + GO(__NR_aio_read, 318, "1s 1m"); + SY(__NR_aio_read, x0); FAIL; + + GO(__NR_aio_write, 319, "1s 1m"); + SY(__NR_aio_write, x0); FAIL; + // __NR_lio_listio 320 // __NR___pthread_cond_wait 321 // __NR_iopolicysys 322 diff --git a/memcheck/tests/darwin/scalar.stderr.exp b/memcheck/tests/darwin/scalar.stderr.exp index 89f0580b82..904777f7e0 100644 --- a/memcheck/tests/darwin/scalar.stderr.exp +++ b/memcheck/tests/darwin/scalar.stderr.exp @@ -688,6 +688,54 @@ Syscall param lstat_extended(fsacl) points to unaddressable byte(s) (300): old shared_region_make_private_np ----------------------------------------------------- ----------------------------------------------------- +x200013a(314): __NR_aio_return 1s 0m +----------------------------------------------------- + +Syscall param aio_return(aiocbp) contains uninitialised byte(s) + ... +----------------------------------------------------- +x200013b(315): __NR_aio_suspend 1s 0m +----------------------------------------------------- + +Syscall param aio_suspend(aiocbp) contains uninitialised byte(s) + ... + +Syscall param aio_suspend(nent) contains uninitialised byte(s) + ... + +Syscall param aio_suspend(timeout) contains uninitialised byte(s) + ... + +Syscall param aio_suspend(list) points to unaddressable byte(s) + ... + Address 0x........ is not stack'd, malloc'd or (recently) free'd +----------------------------------------------------- +x200013d(317): __NR_aio_error 1s 0m +----------------------------------------------------- + +Syscall param aio_error(aiocbp) contains uninitialised byte(s) + ... +----------------------------------------------------- +x200013e(318): __NR_aio_read 1s 1m +----------------------------------------------------- + +Syscall param aio_read(aiocbp) contains uninitialised byte(s) + ... + +Syscall param aio_read(aiocbp) points to unaddressable byte(s) + ... + Address 0x........ is not stack'd, malloc'd or (recently) free'd +----------------------------------------------------- +x200013f(319): __NR_aio_write 1s 1m +----------------------------------------------------- + +Syscall param aio_write(aiocbp) contains uninitialised byte(s) + ... + +Syscall param aio_write(aiocbp) points to unaddressable byte(s) + ... + Address 0x........ is not stack'd, malloc'd or (recently) free'd +----------------------------------------------------- (323): unused ----------------------------------------------------- -----------------------------------------------------