Yipes - my last checking borked the memcheck scalar test. This should
make it better.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3049 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/vg_syscalls.c b/coregrind/vg_syscalls.c
index 4b47203..c3701cf 100644
--- a/coregrind/vg_syscalls.c
+++ b/coregrind/vg_syscalls.c
@@ -4403,8 +4403,7 @@
PRE(sys_readlink, Special)
{
- char name[25];
-
+ int saved = SYSNO;
PRINT("sys_readlink ( %p, %p, %llu )", arg1,arg2,(ULong)arg3);
PRE_REG_READ3(long, "readlink",
const char *, path, char *, buf, int, bufsiz);
@@ -4412,21 +4411,24 @@
PRE_MEM_WRITE( "readlink(buf)", arg2,arg3 );
/*
- * Handle the single case where readlink failed reading /proc/self/exe.
+ * Handle the case where readlink is looking at /proc/self/exe or
+ * /proc/<pid>/exe.
*/
- VG_(sprintf)(name, "/proc/%d/exe", VG_(getpid)());
+ set_result( VG_(do_syscall)(saved, arg1, arg2, arg3));
+ if ((Int)res == -2) {
+ char name[25];
+
+ VG_(sprintf)(name, "/proc/%d/exe", VG_(getpid)());
- if (VG_(strcmp)((Char *)arg1, name) == 0 ||
- VG_(strcmp)((Char *)arg1, "/proc/self/exe") == 0) {
- VG_(sprintf)(name, "/proc/self/fd/%d", VG_(clexecfd));
- res = VG_(do_syscall)(SYSNO, name, arg2, arg3);
- }
- else {
- res = VG_(do_syscall)(SYSNO, arg1, arg2, arg3);
+ if (VG_(strcmp)((Char *)arg1, name) == 0 ||
+ VG_(strcmp)((Char *)arg1, "/proc/self/exe") == 0) {
+ VG_(sprintf)(name, "/proc/self/fd/%d", VG_(clexecfd));
+ set_result( VG_(do_syscall)(saved, name, arg2, arg3));
+ }
}
- if (res > 0)
+ if ((Int)res > 0)
POST_MEM_WRITE( arg2, res );
}