PERFORCE change 125071 for review
Peter Wemm
peter at FreeBSD.org
Sat Aug 11 15:56:36 PDT 2007
http://perforce.freebsd.org/chv.cgi?CH=125071
Change 125071 by peter at peter_work on 2007/08/11 22:55:57
Basic catchup for 7.x. Add wrappers for new mmap/lseek/etc syscall
numbers. Tidy up a few other loose ends. There are lots of 6.x and 7.x
syscalls that are likely to turn up that are not wrapped yet.
Affected files ...
.. //depot/projects/valgrind/coregrind/m_syswrap/priv_syswrap-freebsd.h#2 edit
.. //depot/projects/valgrind/coregrind/m_syswrap/syswrap-amd64-freebsd.c#2 edit
.. //depot/projects/valgrind/coregrind/m_syswrap/syswrap-freebsd.c#3 edit
.. //depot/projects/valgrind/coregrind/m_syswrap/syswrap-generic.c#3 edit
.. //depot/projects/valgrind/coregrind/m_syswrap/syswrap-x86-freebsd.c#2 edit
.. //depot/projects/valgrind/coregrind/vki_syscall-freebsd.h#2 edit
Differences ...
==== //depot/projects/valgrind/coregrind/m_syswrap/priv_syswrap-freebsd.h#2 (text+ko) ====
@@ -1,6 +1,6 @@
/*--------------------------------------------------------------------*/
-/*--- Linux-specific syscalls stuff. priv_syswrap-linux.h ---*/
+/*--- FreeBSD-specific syscalls stuff. priv_syswrap-freebsd.h ---*/
/*--------------------------------------------------------------------*/
/*
@@ -210,6 +210,13 @@
DECL_TEMPLATE(freebsd, sys_lkmnosys6);
DECL_TEMPLATE(freebsd, sys_lkmnosys7);
DECL_TEMPLATE(freebsd, sys_lkmnosys8);
+DECL_TEMPLATE(freebsd, sys_sigaction6);
+DECL_TEMPLATE(freebsd, sys_mmap7);
+DECL_TEMPLATE(freebsd, sys_lseek7);
+DECL_TEMPLATE(freebsd, sys_truncate7);
+DECL_TEMPLATE(freebsd, sys_ftruncate7);
+DECL_TEMPLATE(freebsd, sys_pread7);
+DECL_TEMPLATE(freebsd, sys_pwrite7);
#endif // __PRIV_SYSWRAP_FREEBSD_H
/*--------------------------------------------------------------------*/
==== //depot/projects/valgrind/coregrind/m_syswrap/syswrap-amd64-freebsd.c#2 (text+ko) ====
@@ -54,8 +54,7 @@
#include "priv_types_n_macros.h"
#include "priv_syswrap-generic.h" /* for decls of generic wrappers */
-#include "priv_syswrap-linux.h" /* for decls of linux-ish wrappers */
-#include "priv_syswrap-linux-variants.h" /* decls of linux variant wrappers */
+#include "priv_syswrap-freebsd.h" /* for decls of freebsd-ish wrappers */
#include "priv_syswrap-main.h"
#include "vki_unistd.h" /* for the __NR_* constants */
@@ -212,7 +211,7 @@
/* This is here because on x86 the off_t is passed in 2 regs. Don't ask about pad. */
/* caddr_t mmap(caddr_t addr, size_t len, int prot, int flags, int fd, int pad, off_t pos); */
-/* ARG1 ARG2 ARG3 ARG4 ARG5 ARG6 ARG7+ARG8 */
+/* ARG1 ARG2 ARG3 ARG4 ARG5 ARG6 ARG7 */
PRE(sys_mmap)
{
@@ -228,11 +227,34 @@
SET_STATUS_from_SysRes(r);
}
+/* FreeBSD-7 introduces a "regular" version of mmap etc. */
+PRE(sys_mmap7)
+{
+ SysRes r;
+
+ PRINT("sys_mmap ( %p, %lu, %d, %d, %d, 0x%lx)",
+ ARG1, (UWord)ARG2, ARG3, ARG4, ARG5, ARG6 );
+ PRE_REG_READ6(long, "mmap",
+ char *, addr, unsigned long, len, int, prot, int, flags,
+ int, fd, unsigned long, pos);
+
+ r = ML_(generic_PRE_sys_mmap)( tid, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6 );
+ SET_STATUS_from_SysRes(r);
+}
+
PRE(sys_lseek)
{
- PRINT("sys_lseek ( %d, 0x%x, %p, %d )", ARG1,ARG3,ARG4,ARG5);
+ PRINT("sys_lseek ( %d, 0x%x, %p, %d )", ARG1,ARG3,ARG4);
PRE_REG_READ4(long, "lseek",
- unsigned int, fd, int, pad, unsigned int, offset,
+ unsigned int, fd, int, pad, unsigned long, offset,
+ unsigned int, whence);
+}
+
+PRE(sys_lseek7)
+{
+ PRINT("sys_lseek ( %d, 0x%lx, %d )", ARG1,ARG2,ARG3);
+ PRE_REG_READ3(long, "lseek",
+ unsigned int, fd, unsigned long, offset,
unsigned int, whence);
}
@@ -256,14 +278,54 @@
POST_MEM_WRITE( ARG2, RES );
}
+PRE(sys_pread7)
+{
+ *flags |= SfMayBlock;
+ PRINT("sys_read ( %d, %p, %lu, %lu, %lu )", ARG1, ARG2, ARG3, ARG4);
+ PRE_REG_READ4(ssize_t, "read",
+ unsigned int, fd, char *, buf, vki_size_t, count,
+ unsigned long, off);
+
+ if (!ML_(fd_allowed)(ARG1, "read", tid, False))
+ SET_STATUS_Failure( VKI_EBADF );
+ else
+ PRE_MEM_WRITE( "read(buf)", ARG2, ARG3 );
+}
+
+POST(sys_pread7)
+{
+ vg_assert(SUCCESS);
+ POST_MEM_WRITE( ARG2, RES );
+}
+
PRE(sys_pwrite)
{
Bool ok;
*flags |= SfMayBlock;
- PRINT("sys_write ( %d, %p, %lu, %lu, %lu )", ARG1, ARG2, ARG3, ARG5, ARG6);
+ PRINT("sys_write ( %d, %p, %lu, %lu, %lu )", ARG1, ARG2, ARG3, ARG5);
PRE_REG_READ5(ssize_t, "write",
unsigned int, fd, const char *, buf, vki_size_t, count,
- int, pad, unsigned int, off);
+ int, pad, unsigned long, off);
+ /* check to see if it is allowed. If not, try for an exemption from
+ --sim-hints=enable-outer (used for self hosting). */
+ ok = ML_(fd_allowed)(ARG1, "write", tid, False);
+ if (!ok && ARG1 == 2/*stderr*/
+ && VG_(strstr)(VG_(clo_sim_hints),"enable-outer"))
+ ok = True;
+ if (!ok)
+ SET_STATUS_Failure( VKI_EBADF );
+ else
+ PRE_MEM_READ( "write(buf)", ARG2, ARG3 );
+}
+
+PRE(sys_pwrite7)
+{
+ Bool ok;
+ *flags |= SfMayBlock;
+ PRINT("sys_write ( %d, %p, %lu, %lu )", ARG1, ARG2, ARG3, ARG4);
+ PRE_REG_READ4(ssize_t, "write",
+ unsigned int, fd, const char *, buf, vki_size_t, count,
+ unsigned long, off);
/* check to see if it is allowed. If not, try for an exemption from
--sim-hints=enable-outer (used for self hosting). */
ok = ML_(fd_allowed)(ARG1, "write", tid, False);
@@ -284,13 +346,29 @@
unsigned int, length);
}
+PRE(sys_ftruncate7)
+{
+ *flags |= SfMayBlock;
+ PRINT("sys_ftruncate ( %d, %lu )", ARG1,ARG2);
+ PRE_REG_READ2(long, "ftruncate", unsigned int, fd,
+ unsigned long, length);
+}
+
PRE(sys_truncate)
{
*flags |= SfMayBlock;
PRINT("sys_truncate ( %p(%s), %lu )", ARG1,ARG1,ARG3);
PRE_REG_READ3(long, "truncate",
- const char *, path, int, pad,
- unsigned int, length);
+ const char *, path, int, pad, unsigned int, length);
+ PRE_MEM_RASCIIZ( "truncate(path)", ARG1 );
+}
+
+PRE(sys_truncate7)
+{
+ *flags |= SfMayBlock;
+ PRINT("sys_truncate ( %p(%s), %lu )", ARG1,ARG1,ARG2);
+ PRE_REG_READ2(long, "truncate",
+ const char *, path, unsigned long, length);
PRE_MEM_RASCIIZ( "truncate(path)", ARG1 );
}
==== //depot/projects/valgrind/coregrind/m_syswrap/syswrap-freebsd.c#3 (text+ko) ====
@@ -41,6 +41,7 @@
#include "pub_core_libcprint.h"
#include "pub_core_libcproc.h"
#include "pub_core_libcsignal.h"
+#include "pub_core_machine.h"
#include "pub_core_mallocfree.h"
#include "pub_core_tooliface.h"
#include "pub_core_options.h"
@@ -2670,19 +2671,24 @@
// thr_set_name 464
// aio_fsync 465
// rtprio_thread 466
+ // nosys 467
+
+ // nosys 468
+ // __getpath_fromfd 469
+ // __getpath_fromaddr 470
// sctp_peeloff 471
// sctp_generic_sendmsg 472
// sctp_generic_sendmsg_iov 473
// sctp_generic_recvmsg 474
- // pread 475
+ BSDXY(__NR_pread7, sys_pread7), // 475
- // pwrite 476
- // mmap 477
- // lseek 478
- // truncate 479
+ BSDX_(__NR_pwrite7, sys_pwrite7), // 476
+ BSDX_(__NR_mmap7, sys_mmap7), // 477
+ BSDX_(__NR_lseek7, sys_lseek7), // 478
+ BSDX_(__NR_truncate7, sys_truncate7), // 479
- // ftruncate 480
+ BSDX_(__NR_ftruncate7, sys_ftruncate7), // 480
};
==== //depot/projects/valgrind/coregrind/m_syswrap/syswrap-generic.c#3 (text+ko) ====
@@ -42,6 +42,7 @@
#include "pub_core_libcprint.h"
#include "pub_core_libcproc.h"
#include "pub_core_libcsignal.h"
+#include "pub_core_machine.h"
#include "pub_core_mallocfree.h"
#include "pub_core_options.h"
#include "pub_core_scheduler.h"
==== //depot/projects/valgrind/coregrind/m_syswrap/syswrap-x86-freebsd.c#2 (text+ko) ====
@@ -43,6 +43,7 @@
#include "pub_core_libcprint.h"
#include "pub_core_libcproc.h"
#include "pub_core_libcsignal.h"
+#include "pub_core_machine.h"
#include "pub_core_mallocfree.h"
#include "pub_core_options.h"
#include "pub_core_scheduler.h"
@@ -54,8 +55,7 @@
#include "priv_types_n_macros.h"
#include "priv_syswrap-generic.h" /* for decls of generic wrappers */
-#include "priv_syswrap-linux.h" /* for decls of linux-ish wrappers */
-#include "priv_syswrap-linux-variants.h" /* decls of linux variant wrappers */
+#include "priv_syswrap-freebsd.h" /* for decls of linux-ish wrappers */
#include "priv_syswrap-main.h"
#include "vki_unistd.h" /* for the __NR_* constants */
@@ -362,14 +362,36 @@
SET_STATUS_from_SysRes(r);
}
+PRE(sys_mmap7)
+{
+ SysRes r;
+
+ PRINT("sys_mmap ( %p, %lu, %d, %d, %d, lo0x%x hi0x%x)",
+ ARG1, (UWord)ARG2, ARG3, ARG4, ARG5, ARG6, ARG7 );
+ PRE_REG_READ7(long, "mmap",
+ char *, addr, unsigned long, len, int, prot, int, flags,
+ int, fd, unsigned long, lo, unsigned long, hi);
+
+ r = ML_(generic_PRE_sys_mmap)( tid, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6 + ((Off64T)ARG7 << 32) );
+ SET_STATUS_from_SysRes(r);
+}
+
PRE(sys_lseek)
{
- PRINT("sys_lseek ( %d, 0x%x, 0x%x, %p, %d )", ARG1,ARG3,ARG4,ARG5,ARG6);
+ PRINT("sys_lseek ( %d, 0x%x, 0x%x, %d )", ARG1,ARG3,ARG4,ARG5);
PRE_REG_READ5(long, "lseek",
unsigned int, fd, int, pad, unsigned int, offset_low,
unsigned int, offset_high, unsigned int, whence);
}
+PRE(sys_lseek7)
+{
+ PRINT("sys_lseek ( %d, 0x%x, 0x%x, %d )", ARG1,ARG2,ARG3,ARG4);
+ PRE_REG_READ4(long, "lseek",
+ unsigned int, fd, unsigned int, offset_low,
+ unsigned int, offset_high, unsigned int, whence);
+}
+
PRE(sys_pread)
{
*flags |= SfMayBlock;
@@ -390,6 +412,26 @@
POST_MEM_WRITE( ARG2, RES );
}
+PRE(sys_pread7)
+{
+ *flags |= SfMayBlock;
+ PRINT("sys_read ( %d, %p, %lu, %lu, %lu )", ARG1, ARG2, ARG3, ARG4, ARG5);
+ PRE_REG_READ5(ssize_t, "read",
+ unsigned int, fd, char *, buf, vki_size_t, count,
+ unsigned int, off_low, unsigned int, off_high);
+
+ if (!ML_(fd_allowed)(ARG1, "read", tid, False))
+ SET_STATUS_Failure( VKI_EBADF );
+ else
+ PRE_MEM_WRITE( "read(buf)", ARG2, ARG3 );
+}
+
+POST(sys_pread7)
+{
+ vg_assert(SUCCESS);
+ POST_MEM_WRITE( ARG2, RES );
+}
+
PRE(sys_pwrite)
{
Bool ok;
@@ -410,6 +452,26 @@
PRE_MEM_READ( "write(buf)", ARG2, ARG3 );
}
+PRE(sys_pwrite7)
+{
+ Bool ok;
+ *flags |= SfMayBlock;
+ PRINT("sys_write ( %d, %p, %lu, %lu, %lu )", ARG1, ARG2, ARG3, ARG4, ARG5);
+ PRE_REG_READ5(ssize_t, "write",
+ unsigned int, fd, const char *, buf, vki_size_t, count,
+ unsigned int, off_low, unsigned int, off_high);
+ /* check to see if it is allowed. If not, try for an exemption from
+ --sim-hints=enable-outer (used for self hosting). */
+ ok = ML_(fd_allowed)(ARG1, "write", tid, False);
+ if (!ok && ARG1 == 2/*stderr*/
+ && VG_(strstr)(VG_(clo_sim_hints),"enable-outer"))
+ ok = True;
+ if (!ok)
+ SET_STATUS_Failure( VKI_EBADF );
+ else
+ PRE_MEM_READ( "write(buf)", ARG2, ARG3 );
+}
+
PRE(sys_ftruncate)
{
*flags |= SfMayBlock;
@@ -418,6 +480,14 @@
unsigned int, length_low, unsigned int, length_high);
}
+PRE(sys_ftruncate7)
+{
+ *flags |= SfMayBlock;
+ PRINT("sys_ftruncate ( %d, %lu, %lu )", ARG1,ARG2,ARG3);
+ PRE_REG_READ3(long, "ftruncate", unsigned int, fd,
+ unsigned int, length_low, unsigned int, length_high);
+}
+
PRE(sys_truncate)
{
*flags |= SfMayBlock;
@@ -428,6 +498,16 @@
PRE_MEM_RASCIIZ( "truncate(path)", ARG1 );
}
+PRE(sys_truncate7)
+{
+ *flags |= SfMayBlock;
+ PRINT("sys_truncate ( %p(%s), %lu, %lu )", ARG1,ARG1,ARG2,ARG3);
+ PRE_REG_READ3(long, "truncate",
+ const char *, path,
+ unsigned int, length_low, unsigned int, length_high);
+ PRE_MEM_RASCIIZ( "truncate(path)", ARG1 );
+}
+
PRE(sys_sysarch)
{
ThreadState *tst;
==== //depot/projects/valgrind/coregrind/vki_syscall-freebsd.h#2 (text+ko) ====
@@ -352,6 +352,30 @@
#define __NR_auditctl 453
#define __NR__umtx_op 454
#define __NR_thr_new 455
-#define __NR_MAXSYSCALL 456
+#define __NR_sigqueue 456
+#define __NR_kmq_open 457
+#define __NR_kmq_setattr 458
+#define __NR_kmq_timedreceive 459
+#define __NR_kmq_timedsend 460
+#define __NR_kmq_notify 461
+#define __NR_kmq_unlink 462
+#define __NR_abort2 463
+#define __NR_thr_set_name 464
+#define __NR_aio_fsync 465
+#define __NR_rtprio_thread 466
+#define __NR_nosys467 467
+#define __NR_nosys468 468
+#define __NR___getpath_fromfd 469
+#define __NR___getpath_fromaddr 470
+#define __NR_sctp_peeloff 471
+#define __NR_sctp_generic_sendmsg 472
+#define __NR_sctp_generic_sendmsg_iov 473
+#define __NR_sctp_generic_recvmsg 474
+#define __NR_pread7 475
+#define __NR_pwrite7 476
+#define __NR_mmap7 477
+#define __NR_lseek7 478
+#define __NR_truncate7 479
+#define __NR_ftruncate7 480
#endif /* __VKI_UNISTD_FREEBSD_H */
More information about the p4-projects
mailing list