|
From: Nicholas N. <nj...@ca...> - 2004-11-14 17:03:51
|
CVS commit by nethercote:
Converted a couple more
M +43 -42 coregrind/vg_syscalls.c 1.195
M +20 -0 include/linux/vki.h 1.6
M +11 -8 memcheck/tests/scalar.c 1.26
M +103 -0 memcheck/tests/scalar.stderr.exp 1.21
--- valgrind/coregrind/vg_syscalls.c #1.194:1.195
@@ -2547,15 +2547,16 @@ POSTx(sys_getrlimit)
}
-PRE(getrusage)
+PREx(sys_getrusage, 0)
{
/* int getrusage (int who, struct rusage *usage); */
- PRINT("getrusage ( %d, %p )", arg1,arg2);
+ PRINT("sys_getrusage ( %d, %p )", arg1,arg2);
+ PRE_REG_READ2(long, "getrusage", int, who, struct rusage *, usage);
PRE_MEM_WRITE( "getrusage(usage)", arg2, sizeof(struct vki_rusage) );
}
-POST(getrusage)
+POSTx(sys_getrusage)
{
if (res == 0)
- VG_TRACK( post_mem_write,arg2, sizeof(struct vki_rusage) );
+ VG_TRACK( post_mem_write, arg2, sizeof(struct vki_rusage) );
}
@@ -4546,24 +4547,4 @@ POST(nanosleep)
}
-PRE(_newselect)
-{
- /* int select(int n,
- fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
- struct timeval *timeout);
- */
- PRINT("newselect ( %d, %p, %p, %p, %p )", arg1,arg2,arg3,arg4,arg5);
- if (arg2 != 0)
- PRE_MEM_READ( "newselect(readfds)",
- arg2, arg1/8 /* __FD_SETSIZE/8 */ );
- if (arg3 != 0)
- PRE_MEM_READ( "newselect(writefds)",
- arg3, arg1/8 /* __FD_SETSIZE/8 */ );
- if (arg4 != 0)
- PRE_MEM_READ( "newselect(exceptfds)",
- arg4, arg1/8 /* __FD_SETSIZE/8 */ );
- if (arg5 != 0)
- PRE_MEM_READ( "newselect(timeout)", arg5, sizeof(struct vki_timeval) );
-}
-
PREx(sys_open, MayBlock)
{
@@ -4839,5 +4820,5 @@ PRE(sched_yield)
}
-PRE(select)
+PREx(old_select, MayBlock)
{
/* struct sel_arg_struct {
@@ -4846,7 +4827,7 @@ PRE(select)
struct timeval *tvp;
};
- int old_select(struct sel_arg_struct *arg);
*/
- PRE_MEM_READ( "select(args)", arg1, 5*sizeof(UInt) );
+ PRE_REG_READ1(long, "old_select", struct sel_arg_struct *, args);
+ PRE_MEM_READ( "old_select(args)", arg1, 5*sizeof(UInt) );
{
@@ -4860,16 +4841,36 @@ PRE(select)
a5 = arg_struct[4];
- PRINT("select ( %d, %p, %p, %p, %p )", a1,a2,a3,a4,a5);
+ PRINT("old_select ( %d, %p, %p, %p, %p )", a1,a2,a3,a4,a5);
if (a2 != (Addr)NULL)
- PRE_MEM_READ( "select(readfds)", a2, a1/8 /* __FD_SETSIZE/8 */ );
+ PRE_MEM_READ( "old_select(readfds)", a2, a1/8 /* __FD_SETSIZE/8 */ );
if (a3 != (Addr)NULL)
- PRE_MEM_READ( "select(writefds)", a3, a1/8 /* __FD_SETSIZE/8 */ );
+ PRE_MEM_READ( "old_select(writefds)", a3, a1/8 /* __FD_SETSIZE/8 */ );
if (a4 != (Addr)NULL)
- PRE_MEM_READ( "select(exceptfds)", a4, a1/8 /* __FD_SETSIZE/8 */ );
+ PRE_MEM_READ( "old_select(exceptfds)", a4, a1/8 /* __FD_SETSIZE/8 */ );
if (a5 != (Addr)NULL)
- PRE_MEM_READ( "select(timeout)", a5, sizeof(struct vki_timeval) );
+ PRE_MEM_READ( "old_select(timeout)", a5, sizeof(struct vki_timeval) );
}
}
+PREx(sys_select, MayBlock)
+{
+ PRINT("sys_select ( %d, %p, %p, %p, %p )", arg1,arg2,arg3,arg4,arg5);
+ PRE_REG_READ5(long, "select",
+ int, n, vki_fd_set *, readfds, vki_fd_set *, writefds,
+ vki_fd_set *, exceptfds, struct timeval *, timeout);
+ // XXX: this possibly understates how much memory is read.
+ if (arg2 != 0)
+ PRE_MEM_READ( "select(readfds)",
+ arg2, arg1/8 /* __FD_SETSIZE/8 */ );
+ if (arg3 != 0)
+ PRE_MEM_READ( "select(writefds)",
+ arg3, arg1/8 /* __FD_SETSIZE/8 */ );
+ if (arg4 != 0)
+ PRE_MEM_READ( "select(exceptfds)",
+ arg4, arg1/8 /* __FD_SETSIZE/8 */ );
+ if (arg5 != 0)
+ PRE_MEM_READ( "select(timeout)", arg5, sizeof(struct vki_timeval) );
+}
+
PRE(setitimer)
{
@@ -6354,6 +6355,6 @@ static const struct sys_info sys_info[]
SYSX_(__NR_setrlimit, sys_setrlimit), // 75 * (SVr4,BSD4.3)
- SYSXY(__NR_getrlimit, sys_old_getrlimit), // 76 * (SVr4,BSD4.3)
- SYSBA(__NR_getrusage, sys_getrusage, 0), // 77 *
+ SYSXY(__NR_getrlimit, sys_old_getrlimit),// 76 * (SVr4,BSD4.3)
+ SYSXY(__NR_getrusage, sys_getrusage), // 77 * (SVr4,BSD4.3)
SYSXY(__NR_gettimeofday, sys_gettimeofday), // 78 * P
SYSX_(__NR_settimeofday, sys_settimeofday), // 79 * almost-P
@@ -6361,5 +6362,5 @@ static const struct sys_info sys_info[]
SYSXY(__NR_getgroups, sys_getgroups16), // 80 ## P
SYSX_(__NR_setgroups, sys_setgroups16), // 81 ## almost-P
- SYSB_(__NR_select, old_select, MayBlock), // 82 old_select
+ SYSX_(__NR_select, old_select), // 82 (x86) (4.4BSD)
SYSB_(__NR_symlink, sys_symlink, MayBlock), // 83 *
// (__NR_oldlstat, sys_lstat), // 84 * L -- obsolete
@@ -6435,5 +6436,5 @@ static const struct sys_info sys_info[]
SYSBA(__NR__llseek, sys_llseek, 0), // 140 *
SYSBA(__NR_getdents, sys_getdents, MayBlock), // 141 *
- SYSB_(__NR__newselect, sys_select, MayBlock), // 142 *
+ SYSX_(__NR__newselect, sys_select), // 142 * (4.4BSD...)
SYSB_(__NR_flock, sys_flock, MayBlock), // 143 *
SYSB_(__NR_msync, sys_msync, MayBlock), // 144 *
--- valgrind/include/linux/vki.h #1.5:1.6
@@ -81,4 +81,23 @@
//----------------------------------------------------------------------
+#undef __VKI_NFDBITS
+#define __VKI_NFDBITS (8 * sizeof(unsigned long))
+
+#undef __VKI_FD_SETSIZE
+#define __VKI_FD_SETSIZE 1024
+
+#undef __VKI_FDSET_LONGS
+#define __VKI_FDSET_LONGS (__VKI_FD_SETSIZE/__VKI_NFDBITS)
+
+#undef __VKI_FDELT
+#define __VKI_FDELT(d) ((d) / __VKI_NFDBITS)
+
+#undef __VKI_FDMASK
+#define __VKI_FDMASK(d) (1UL << ((d) % __VKI_NFDBITS))
+
+typedef struct {
+ unsigned long fds_bits [__VKI_FDSET_LONGS];
+} __vki_kernel_fd_set;
+
typedef int __vki_kernel_key_t;
@@ -87,4 +106,5 @@ typedef int __vki_kernel_key_t;
//----------------------------------------------------------------------
+typedef __vki_kernel_fd_set vki_fd_set;
typedef __vki_kernel_mode_t vki_mode_t;
typedef __vki_kernel_off_t vki_off_t;
--- valgrind/memcheck/tests/scalar.c #1.25:1.26
@@ -312,6 +312,6 @@ int main(void)
// __NR_getrusage 77
- //GO(__NR_getrusage, ".s .m");
- //SY(__NR_getrusage);
+ GO(__NR_getrusage, "2s 1m");
+ SY(__NR_getrusage, x0, x0);
// __NR_gettimeofday 78 --> sys_gettimeofday()
@@ -331,7 +331,10 @@ int main(void)
SY(__NR_setgroups, x0+1, x0+1);
- // __NR_select 82
- //GO(__NR_select, ".s .m");
- //SY(__NR_select);
+ // __NR_select 82 --> old_select()
+ {
+ long args[5] = { x0+8, x0+0xffffffee, x0+1, x0+1, x0+1 };
+ GO(__NR_select, "1s 4m");
+ SY(__NR_select, args+x0);
+ }
// __NR_symlink 83
@@ -565,7 +568,7 @@ int main(void)
//SY(__NR_getdents);
- // __NR__newselect 142
- //GO(__NR__newselect, ".s .m");
- //SY(__NR__newselect);
+ // __NR__newselect 142 --> sys_select()
+ GO(__NR__newselect, "5s 4m");
+ SY(__NR__newselect, x0+8, x0+0xffffffff, x0+1, x0+1, x0+1);
// __NR_flock 143
--- valgrind/memcheck/tests/scalar.stderr.exp #1.20:1.21
@@ -848,4 +848,23 @@
Address 0x........ is not stack'd, malloc'd or (recently) free'd
-----------------------------------------------------
+ 77: __NR_getrusage 2s 1m
+-----------------------------------------------------
+
+Syscall param getrusage(who) contains uninitialised byte(s)
+ at 0x........: syscall (in /...libc...)
+ by 0x........: __libc_start_main (...libc...)
+ by 0x........: ...
+
+Syscall param getrusage(usage) contains uninitialised byte(s)
+ at 0x........: syscall (in /...libc...)
+ by 0x........: __libc_start_main (...libc...)
+ by 0x........: ...
+
+Syscall param getrusage(usage) points to unaddressable byte(s)
+ at 0x........: syscall (in /...libc...)
+ by 0x........: __libc_start_main (...libc...)
+ by 0x........: ...
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+-----------------------------------------------------
78: __NR_gettimeofday 2s 2m
-----------------------------------------------------
@@ -936,4 +955,36 @@
Address 0x........ is not stack'd, malloc'd or (recently) free'd
-----------------------------------------------------
+ 82: __NR_select 1s 4m
+-----------------------------------------------------
+
+Syscall param old_select(args) contains uninitialised byte(s)
+ at 0x........: syscall (in /...libc...)
+ by 0x........: __libc_start_main (...libc...)
+ by 0x........: ...
+
+Syscall param old_select(readfds) points to unaddressable byte(s)
+ at 0x........: syscall (in /...libc...)
+ by 0x........: __libc_start_main (...libc...)
+ by 0x........: ...
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
+Syscall param old_select(writefds) points to unaddressable byte(s)
+ at 0x........: syscall (in /...libc...)
+ by 0x........: __libc_start_main (...libc...)
+ by 0x........: ...
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
+Syscall param old_select(exceptfds) points to unaddressable byte(s)
+ at 0x........: syscall (in /...libc...)
+ by 0x........: __libc_start_main (...libc...)
+ by 0x........: ...
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
+Syscall param old_select(timeout) points to unaddressable byte(s)
+ at 0x........: syscall (in /...libc...)
+ by 0x........: __libc_start_main (...libc...)
+ by 0x........: ...
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+-----------------------------------------------------
95: __NR_fchown 3s 0m
-----------------------------------------------------
@@ -1068,4 +1119,56 @@
by 0x........: ...
-----------------------------------------------------
+142: __NR__newselect 5s 4m
+-----------------------------------------------------
+
+Syscall param select(n) contains uninitialised byte(s)
+ at 0x........: syscall (in /...libc...)
+ by 0x........: __libc_start_main (...libc...)
+ by 0x........: ...
+
+Syscall param select(readfds) contains uninitialised byte(s)
+ at 0x........: syscall (in /...libc...)
+ by 0x........: __libc_start_main (...libc...)
+ by 0x........: ...
+
+Syscall param select(writefds) contains uninitialised byte(s)
+ at 0x........: syscall (in /...libc...)
+ by 0x........: __libc_start_main (...libc...)
+ by 0x........: ...
+
+Syscall param select(exceptfds) contains uninitialised byte(s)
+ at 0x........: syscall (in /...libc...)
+ by 0x........: __libc_start_main (...libc...)
+ by 0x........: ...
+
+Syscall param select(timeout) contains uninitialised byte(s)
+ at 0x........: syscall (in /...libc...)
+ by 0x........: __libc_start_main (...libc...)
+ by 0x........: ...
+
+Syscall param select(readfds) points to unaddressable byte(s)
+ at 0x........: syscall (in /...libc...)
+ by 0x........: __libc_start_main (...libc...)
+ by 0x........: ...
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
+Syscall param select(writefds) points to unaddressable byte(s)
+ at 0x........: syscall (in /...libc...)
+ by 0x........: __libc_start_main (...libc...)
+ by 0x........: ...
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
+Syscall param select(exceptfds) points to unaddressable byte(s)
+ at 0x........: syscall (in /...libc...)
+ by 0x........: __libc_start_main (...libc...)
+ by 0x........: ...
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
+Syscall param select(timeout) points to unaddressable byte(s)
+ at 0x........: syscall (in /...libc...)
+ by 0x........: __libc_start_main (...libc...)
+ by 0x........: ...
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+-----------------------------------------------------
153: __NR_munlockall 0e
-----------------------------------------------------
|