|
From: <sv...@va...> - 2015-03-07 08:36:28
|
Author: rhyskidd
Date: Sat Mar 7 08:36:20 2015
New Revision: 14987
Log:
Fix unhandled syscall: unix:348 (__pthread_chdir) and unhandled syscall: unix:349 (__pthread_fchdir) on OS X
bz#344512
- Support these two undocumented syscalls.
- New regression test case added.
Before:
== 588 tests, 239 stderr failures, 22 stdout failures, 0 stderrB failures, 0 stdoutB failures, 31 post failures ==
After:
== 589 tests, 239 stderr failures, 22 stdout failures, 0 stderrB failures, 0 stdoutB failures, 31 post failures ==
Added:
trunk/memcheck/tests/darwin/pth-undocumented.c
trunk/memcheck/tests/darwin/pth-undocumented.stderr.exp
trunk/memcheck/tests/darwin/pth-undocumented.stdout.exp
trunk/memcheck/tests/darwin/pth-undocumented.vgtest
Modified:
trunk/NEWS
trunk/coregrind/m_syswrap/priv_syswrap-darwin.h
trunk/coregrind/m_syswrap/syswrap-darwin.c
trunk/memcheck/tests/darwin/ (props changed)
trunk/memcheck/tests/darwin/Makefile.am
Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Sat Mar 7 08:36:20 2015
@@ -115,6 +115,8 @@
344499 Fix compilation for Linux kernel >= 4. With this, also require
a Linux kernel >= 2.6 as 2.4 is mostly untested and might trigger
obvious and non-obvious issues
+344512 Fix unhandled syscall: unix:348 (__pthread_chdir) and unhandled
+ syscall: unix:349 (__pthread_fchdir) on OS X
344560 Fix stack traces missing penultimate frame on OS X
344621 Fix memcheck/tests/err_disable4 test on OS X
344686 Fix suppression for pthread_rwlock_init on OS X 10.10
Modified: trunk/coregrind/m_syswrap/priv_syswrap-darwin.h
==============================================================================
--- trunk/coregrind/m_syswrap/priv_syswrap-darwin.h (original)
+++ trunk/coregrind/m_syswrap/priv_syswrap-darwin.h Sat Mar 7 08:36:20 2015
@@ -416,8 +416,8 @@
DECL_TEMPLATE(darwin, statfs64); // 345
DECL_TEMPLATE(darwin, fstatfs64); // 346
DECL_TEMPLATE(darwin, getfsstat64); // 347
-// NYI __pthread_chdir 348
-// NYI __pthread_fchdir 349
+DECL_TEMPLATE(darwin, __pthread_chdir); // 348
+DECL_TEMPLATE(darwin, __pthread_fchdir); // 349
// NYI audit 350
DECL_TEMPLATE(darwin, auditon); // 351
// 352
Modified: trunk/coregrind/m_syswrap/syswrap-darwin.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-darwin.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-darwin.c Sat Mar 7 08:36:20 2015
@@ -2186,6 +2186,22 @@
}
+PRE(__pthread_chdir)
+{
+ PRINT("__pthread_chdir ( %#lx(%s) )", ARG1, (char*)ARG1);
+ PRE_REG_READ1(long, "__pthread_chdir", const char *, path);
+ PRE_MEM_RASCIIZ( "__pthread_chdir(path)", ARG1 );
+}
+
+
+
+PRE(__pthread_fchdir)
+{
+ PRINT("__pthread_fchdir ( %ld )", ARG1);
+ PRE_REG_READ1(long, "__pthread_fchdir", unsigned int, fd);
+}
+
+
PRE(kdebug_trace)
{
PRINT("kdebug_trace(%ld, %ld, %ld, %ld, %ld, %ld)",
@@ -9671,8 +9687,8 @@
MACXY(__NR_statfs64, statfs64),
MACXY(__NR_fstatfs64, fstatfs64),
MACXY(__NR_getfsstat64, getfsstat64),
-// _____(__NR___pthread_chdir),
-// _____(__NR___pthread_fchdir),
+ MACX_(__NR___pthread_chdir, __pthread_chdir),
+ MACX_(__NR___pthread_fchdir, __pthread_fchdir),
// _____(__NR_audit),
MACXY(__NR_auditon, auditon),
_____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(352)), // ???
Modified: trunk/memcheck/tests/darwin/Makefile.am
==============================================================================
--- trunk/memcheck/tests/darwin/Makefile.am (original)
+++ trunk/memcheck/tests/darwin/Makefile.am Sat Mar 7 08:36:20 2015
@@ -10,6 +10,7 @@
deep_badparam.stderr.exp deep_badparam.stdout.exp deep_badparam.vgtest \
env.stderr.exp env.vgtest \
pth-supp.stderr.exp pth-supp.vgtest \
+ pth-undocumented.stderr.exp pth-undocumented.stdout.exp pth-undocumented.vgtest \
scalar.stderr.exp scalar.vgtest \
scalar_fork.stderr.exp scalar_fork.vgtest \
scalar_nocancel.stderr.exp scalar_nocancel.vgtest \
@@ -20,6 +21,7 @@
deep_badparam \
env \
pth-supp \
+ pth-undocumented \
scalar \
scalar_fork \
scalar_nocancel \
Added: trunk/memcheck/tests/darwin/pth-undocumented.c
==============================================================================
--- trunk/memcheck/tests/darwin/pth-undocumented.c (added)
+++ trunk/memcheck/tests/darwin/pth-undocumented.c Sat Mar 7 08:36:20 2015
@@ -0,0 +1,41 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <sys/syscall.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+#ifndef SYS___pthread_chdir
+# define SYS___pthread_chdir 348
+#endif
+
+#ifndef SYS___pthread_fchdir
+# define SYS___pthread_fchdir 349
+#endif
+
+int __pthread_chdir(const char *path)
+{
+ return syscall(SYS___pthread_chdir, path);
+}
+
+int __pthread_fchdir(int dirfd)
+{
+ return syscall(SYS___pthread_fchdir, dirfd);
+}
+
+int main(void)
+{
+ int dirfd;
+
+ dirfd = open("/", O_RDONLY);
+ if (dirfd == -1)
+ perror("open"), exit(1);
+
+ if (__pthread_chdir("/"))
+ perror("__pthread_chdir");
+
+ if (__pthread_fchdir(dirfd))
+ perror("__pthread_fchdir");
+
+ return 0;
+}
Added: trunk/memcheck/tests/darwin/pth-undocumented.stderr.exp
==============================================================================
(empty)
Added: trunk/memcheck/tests/darwin/pth-undocumented.stdout.exp
==============================================================================
(empty)
Added: trunk/memcheck/tests/darwin/pth-undocumented.vgtest
==============================================================================
--- trunk/memcheck/tests/darwin/pth-undocumented.vgtest (added)
+++ trunk/memcheck/tests/darwin/pth-undocumented.vgtest Sat Mar 7 08:36:20 2015
@@ -0,0 +1,2 @@
+prog: pth-undocumented
+vgopts: -q
|