]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix unhandled syscall: unix:348 (__pthread_chdir) and unhandled syscall: unix:349...
authorRhys Kidd <rhyskidd@gmail.com>
Sat, 7 Mar 2015 08:36:20 +0000 (08:36 +0000)
committerRhys Kidd <rhyskidd@gmail.com>
Sat, 7 Mar 2015 08:36:20 +0000 (08:36 +0000)
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 ==

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14987

NEWS
coregrind/m_syswrap/priv_syswrap-darwin.h
coregrind/m_syswrap/syswrap-darwin.c
memcheck/tests/darwin/Makefile.am
memcheck/tests/darwin/pth-undocumented.c [new file with mode: 0644]
memcheck/tests/darwin/pth-undocumented.stderr.exp [new file with mode: 0644]
memcheck/tests/darwin/pth-undocumented.stdout.exp [new file with mode: 0644]
memcheck/tests/darwin/pth-undocumented.vgtest [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index b7d2680e1833a5c07705614c48305441a3bc584b..dbef0d4dec9b79b93bab2a9ff2cd2311137f6823 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -115,6 +115,8 @@ where XXXXXX is the bug number as listed below.
 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
index 9351b81b7578dd590b1122cedc24d320b7d2c4eb..1360719fd4e501556fc0517f7efbe677701cff9f 100644 (file)
@@ -416,8 +416,8 @@ DECL_TEMPLATE(darwin, getdirentries64);         // 344
 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
index cd4043aa5f5c5d55cbfe3452a4e9172ad74012a8..84e2ba1d3fb99e8bf6c428961166d09e44cba705 100644 (file)
@@ -2186,6 +2186,22 @@ PRE(__disable_threadsignal)
 }
 
 
+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 @@ const SyscallTableEntry ML_(syscall_table)[] = {
    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)),   // ???
index b3d2508ac9b4d40250a1f48aa5a5cc69d14278a8..f5deb34a5101779732d8937a1da7ccec5c4ae6df 100644 (file)
@@ -10,6 +10,7 @@ EXTRA_DIST = \
        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 @@ check_PROGRAMS = \
        deep_badparam \
        env \
        pth-supp \
+       pth-undocumented \
        scalar \
        scalar_fork \
        scalar_nocancel \
diff --git a/memcheck/tests/darwin/pth-undocumented.c b/memcheck/tests/darwin/pth-undocumented.c
new file mode 100644 (file)
index 0000000..d9a5192
--- /dev/null
@@ -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;
+}
diff --git a/memcheck/tests/darwin/pth-undocumented.stderr.exp b/memcheck/tests/darwin/pth-undocumented.stderr.exp
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/memcheck/tests/darwin/pth-undocumented.stdout.exp b/memcheck/tests/darwin/pth-undocumented.stdout.exp
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/memcheck/tests/darwin/pth-undocumented.vgtest b/memcheck/tests/darwin/pth-undocumented.vgtest
new file mode 100644 (file)
index 0000000..58d09df
--- /dev/null
@@ -0,0 +1,2 @@
+prog: pth-undocumented
+vgopts: -q