PERFORCE change 167595 for review
Stanislav Sedov
stas at FreeBSD.org
Fri Aug 21 23:07:10 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=167595
Change 167595 by stas at stas_orion on 2009/08/21 23:06:20
- Add a basic ioctl handler. With this chane the basic vlagrind on amd64
should be mostly functional.
Affected files ...
.. //depot/projects/valgrind/coregrind/m_syswrap/priv_syswrap-freebsd.h#18 edit
.. //depot/projects/valgrind/coregrind/m_syswrap/syswrap-freebsd.c#37 edit
Differences ...
==== //depot/projects/valgrind/coregrind/m_syswrap/priv_syswrap-freebsd.h#18 (text+ko) ====
@@ -261,6 +261,8 @@
DECL_TEMPLATE(freebsd, sys_thr_new);
DECL_TEMPLATE(freebsd, sys_thr_kill);
DECL_TEMPLATE(freebsd, sys_thr_kill2);
+DECL_TEMPLATE(freebsd, sys_fcntl);
+DECL_TEMPLATE(freebsd, sys_ioctl);
#endif // __PRIV_SYSWRAP_FREEBSD_H
/*--------------------------------------------------------------------*/
==== //depot/projects/valgrind/coregrind/m_syswrap/syswrap-freebsd.c#37 (text+ko) ====
@@ -3102,6 +3102,58 @@
}
}
+PRE(sys_ioctl)
+{
+ UInt dir = _VKI_IOC_DIR(ARG2);
+ UInt size = _VKI_IOC_SIZE(ARG2);
+ *flags |= SfMayBlock;
+ PRINT("sys_ioctl ( %ld, 0x%lx, %#lx )",ARG1,ARG2,ARG3);
+ PRE_REG_READ3(long, "ioctl",
+ unsigned int, fd, unsigned int, request, unsigned long, arg);
+
+/* On FreeBSD, ALL ioctl's are IOR/IOW encoded. Just use the default decoder */
+ if (VG_(strstr)(VG_(clo_sim_hints), "lax-ioctls") != NULL) {
+ /*
+ * Be very lax about ioctl handling; the only
+ * assumption is that the size is correct. Doesn't
+ * require the full buffer to be initialized when
+ * writing. Without this, using some device
+ * drivers with a large number of strange ioctl
+ * commands becomes very tiresome.
+ */
+ } else if (/* size == 0 || */ dir == _VKI_IOC_NONE) {
+ static Int moans = 3;
+ if (moans > 0 && !VG_(clo_xml)) {
+ moans--;
+ VG_(message)(Vg_UserMsg,
+ "Warning: noted but unhandled ioctl 0x%lx"
+ " with no size/direction hints",
+ ARG2);
+ VG_(message)(Vg_UserMsg,
+ " This could cause spurious value errors"
+ " to appear.");
+ VG_(message)(Vg_UserMsg,
+ " See README_MISSING_SYSCALL_OR_IOCTL for "
+ "guidance on writing a proper wrapper." );
+ }
+ } else {
+ if ((dir & _VKI_IOC_WRITE) && size > 0)
+ PRE_MEM_READ( "ioctl(generic)", ARG3, size);
+ if ((dir & _VKI_IOC_READ) && size > 0)
+ PRE_MEM_WRITE( "ioctl(generic)", ARG3, size);
+ }
+}
+
+POST(sys_ioctl)
+{
+ UInt dir = _VKI_IOC_DIR(ARG2);
+ UInt size = _VKI_IOC_SIZE(ARG2);
+ vg_assert(SUCCESS);
+ if (size > 0 && (dir & _VKI_IOC_READ)
+ && RES == 0 && ARG3 != (Addr)NULL)
+ POST_MEM_WRITE(ARG3, size);
+}
+
#undef PRE
#undef POST
@@ -3173,7 +3225,7 @@
// 4.3 sigpending 52
GENXY(__NR_sigaltstack, sys_sigaltstack), // 53
-// GENXY(__NR_ioctl, sys_ioctl), // 54
+ BSDXY(__NR_ioctl, sys_ioctl), // 54
// BSDX_(__NR_reboot, sys_reboot), // 55
BSDX_(__NR_revoke, sys_revoke), // 56
More information about the p4-projects
mailing list