|
From: <sv...@va...> - 2005-08-30 02:45:46
|
Author: njn
Date: 2005-08-30 03:45:44 +0100 (Tue, 30 Aug 2005)
New Revision: 4581
Log:
Group Linux-specific syscalls a bit.
Modified:
trunk/coregrind/m_syswrap/priv_syswrap-linux.h
trunk/coregrind/m_syswrap/syswrap-linux.c
Modified: trunk/coregrind/m_syswrap/priv_syswrap-linux.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_syswrap/priv_syswrap-linux.h 2005-08-30 02:38:01 UT=
C (rev 4580)
+++ trunk/coregrind/m_syswrap/priv_syswrap-linux.h 2005-08-30 02:45:44 UT=
C (rev 4581)
@@ -36,29 +36,26 @@
// Run a thread from beginning to end.=20
extern VgSchedReturnCode ML_(thread_wrapper)(Word /*ThreadId*/ tid);
=20
-DECL_TEMPLATE(linux, sys_exit_group);
-
DECL_TEMPLATE(linux, sys_mount);
DECL_TEMPLATE(linux, sys_oldumount);
DECL_TEMPLATE(linux, sys_umount);
=20
-DECL_TEMPLATE(linux, sys_llseek);
-DECL_TEMPLATE(linux, sys_adjtimex);
-
DECL_TEMPLATE(linux, sys_setfsuid16);
-DECL_TEMPLATE(linux, sys_setfsgid16);
-DECL_TEMPLATE(linux, sys_setresuid16); // man page says "non-standard";
-DECL_TEMPLATE(linux, sys_getresuid16);
-DECL_TEMPLATE(linux, sys_setresgid16); // man page says "non-standard"
-DECL_TEMPLATE(linux, sys_getresgid16);
-
DECL_TEMPLATE(linux, sys_setfsuid);
+DECL_TEMPLATE(linux, sys_setfsgid16);
DECL_TEMPLATE(linux, sys_setfsgid);
+DECL_TEMPLATE(linux, sys_setresuid16); // man page says "non-standard";
DECL_TEMPLATE(linux, sys_setresuid); // man page says "non-standard"
+DECL_TEMPLATE(linux, sys_getresuid16);
DECL_TEMPLATE(linux, sys_getresuid);
+DECL_TEMPLATE(linux, sys_setresgid16); // man page says "non-standard"
DECL_TEMPLATE(linux, sys_setresgid); // man page says "non-standard"
+DECL_TEMPLATE(linux, sys_getresgid16);
DECL_TEMPLATE(linux, sys_getresgid);
=20
+DECL_TEMPLATE(linux, sys_exit_group);
+DECL_TEMPLATE(linux, sys_llseek);
+DECL_TEMPLATE(linux, sys_adjtimex);
DECL_TEMPLATE(linux, sys_ioperm);
DECL_TEMPLATE(linux, sys_syslog);
DECL_TEMPLATE(linux, sys_vhangup);
@@ -66,7 +63,6 @@
DECL_TEMPLATE(linux, sys_personality);
DECL_TEMPLATE(linux, sys_sysctl);
DECL_TEMPLATE(linux, sys_prctl);
-
DECL_TEMPLATE(linux, sys_sendfile);
DECL_TEMPLATE(linux, sys_sendfile64);
DECL_TEMPLATE(linux, sys_futex);
@@ -136,7 +132,8 @@
DECL_TEMPLATE(linux, sys_fchown16);
//DECL_TEMPLATE(linux, sys_lchown16); // not yet encountered
=20
-// Are these POSIX? In Darwin they have an extra parameter 'position'.
+// Are these POSIX? In Darwin they have an extra parameter 'position',
+// so put them here.
DECL_TEMPLATE(linux, sys_setxattr);
DECL_TEMPLATE(linux, sys_lsetxattr);
DECL_TEMPLATE(linux, sys_fsetxattr);
@@ -150,6 +147,7 @@
DECL_TEMPLATE(linux, sys_lremovexattr);
DECL_TEMPLATE(linux, sys_fremovexattr);
=20
+// Are these Posix? Darwin doesn't have them, so put them here for now.
DECL_TEMPLATE(linux, sys_sched_setparam);
DECL_TEMPLATE(linux, sys_sched_getparam);
DECL_TEMPLATE(linux, sys_sched_setscheduler);
Modified: trunk/coregrind/m_syswrap/syswrap-linux.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_syswrap/syswrap-linux.c 2005-08-30 02:38:01 UTC (re=
v 4580)
+++ trunk/coregrind/m_syswrap/syswrap-linux.c 2005-08-30 02:45:44 UTC (re=
v 4581)
@@ -106,44 +106,10 @@
// Combine two 32-bit values into a 64-bit value
#define LOHI64(lo,hi) ( (lo) | ((ULong)(hi) << 32) )
=20
-PRE(sys_set_tid_address)
-{
- PRINT("sys_set_tid_address ( %p )", ARG1);
- PRE_REG_READ1(long, "set_tid_address", int *, tidptr);
-}
+/* ---------------------------------------------------------------------
+ *mount wrappers
+ ------------------------------------------------------------------ */
=20
-PRE(sys_exit_group)
-{
- ThreadId t;
- ThreadState* tst;
-
- PRINT("exit_group( %d )", ARG1);
- PRE_REG_READ1(void, "exit_group", int, exit_code);
-
- tst =3D VG_(get_ThreadState)(tid);
-
- /* A little complex; find all the threads with the same threadgroup
- as this one (including this one), and mark them to exit */
- for (t =3D 1; t < VG_N_THREADS; t++) {
- if ( /* not alive */
- VG_(threads)[t].status =3D=3D VgTs_Empty=20
- ||
- /* not our group */
- VG_(threads)[t].os_state.threadgroup !=3D tst->os_state.threa=
dgroup
- )
- continue;
-
- VG_(threads)[t].exitreason =3D VgSrc_ExitSyscall;
- VG_(threads)[t].os_state.exitcode =3D ARG1;
-
- if (t !=3D tid)
- VG_(kill_thread)(t); /* unblock it, if blocked */
- }
-
- /* We have to claim the syscall already succeeded. */
- SET_STATUS_Success(0);
-}
-
PRE(sys_mount)
{
// Nb: depending on 'flags', the 'type' and 'data' args may be ignore=
d.
@@ -173,52 +139,10 @@
PRE_MEM_RASCIIZ( "umount2(path)", ARG1);
}
=20
-PRE(sys_llseek)
-{
- PRINT("sys_llseek ( %d, 0x%x, 0x%x, %p, %d )", ARG1,ARG2,ARG3,ARG4,AR=
G5);
- PRE_REG_READ5(long, "llseek",
- unsigned int, fd, unsigned long, offset_high,
- unsigned long, offset_low, vki_loff_t *, result,
- unsigned int, whence);
- PRE_MEM_WRITE( "llseek(result)", ARG4, sizeof(vki_loff_t));
-}
+/* ---------------------------------------------------------------------
+ 16- and 32-bit uid/gid wrappers
+ ------------------------------------------------------------------ */
=20
-POST(sys_llseek)
-{
- vg_assert(SUCCESS);
- if (RES =3D=3D 0)
- POST_MEM_WRITE( ARG4, sizeof(vki_loff_t) );
-}
-
-//zz PRE(sys_adjtimex, 0)
-//zz {
-//zz struct vki_timex *tx =3D (struct vki_timex *)ARG1;
-//zz PRINT("sys_adjtimex ( %p )", ARG1);
-//zz PRE_REG_READ1(long, "adjtimex", struct timex *, buf);
-//zz PRE_MEM_READ( "adjtimex(timex->modes)", ARG1, sizeof(tx->modes))=
;
-//zz=20
-#if 0 //zz (avoiding warnings about multi-line comments)
-zz #define ADJX(bit,field) \
-zz if (tx->modes & bit) \
-zz PRE_MEM_READ( "adjtimex(timex->"#field")", \
-zz (Addr)&tx->field, sizeof(tx->field))
-#endif
-//zz ADJX(ADJ_FREQUENCY, freq);
-//zz ADJX(ADJ_MAXERROR, maxerror);
-//zz ADJX(ADJ_ESTERROR, esterror);
-//zz ADJX(ADJ_STATUS, status);
-//zz ADJX(ADJ_TIMECONST, constant);
-//zz ADJX(ADJ_TICK, tick);
-//zz #undef ADJX
-//zz =20
-//zz PRE_MEM_WRITE( "adjtimex(timex)", ARG1, sizeof(struct vki_timex)=
);
-//zz }
-//zz=20
-//zz POST(sys_adjtimex)
-//zz {
-//zz POST_MEM_WRITE( ARG1, sizeof(struct vki_timex) );
-//zz }
-
PRE(sys_setfsuid16)
{
PRINT("sys_setfsuid16 ( %d )", ARG1);
@@ -340,7 +264,6 @@
PRE_MEM_WRITE( "getresgid(egid)", ARG2, sizeof(vki_gid_t) );
PRE_MEM_WRITE( "getresgid(sgid)", ARG3, sizeof(vki_gid_t) );
}
-
POST(sys_getresgid)
{
vg_assert(SUCCESS);
@@ -351,6 +274,87 @@
}
}
=20
+/* ---------------------------------------------------------------------
+ miscellaneous wrappers
+ ------------------------------------------------------------------ */
+
+PRE(sys_exit_group)
+{
+ ThreadId t;
+ ThreadState* tst;
+
+ PRINT("exit_group( %d )", ARG1);
+ PRE_REG_READ1(void, "exit_group", int, exit_code);
+
+ tst =3D VG_(get_ThreadState)(tid);
+
+ /* A little complex; find all the threads with the same threadgroup
+ as this one (including this one), and mark them to exit */
+ for (t =3D 1; t < VG_N_THREADS; t++) {
+ if ( /* not alive */
+ VG_(threads)[t].status =3D=3D VgTs_Empty=20
+ ||
+ /* not our group */
+ VG_(threads)[t].os_state.threadgroup !=3D tst->os_state.threa=
dgroup
+ )
+ continue;
+
+ VG_(threads)[t].exitreason =3D VgSrc_ExitSyscall;
+ VG_(threads)[t].os_state.exitcode =3D ARG1;
+
+ if (t !=3D tid)
+ VG_(kill_thread)(t); /* unblock it, if blocked */
+ }
+
+ /* We have to claim the syscall already succeeded. */
+ SET_STATUS_Success(0);
+}
+
+PRE(sys_llseek)
+{
+ PRINT("sys_llseek ( %d, 0x%x, 0x%x, %p, %d )", ARG1,ARG2,ARG3,ARG4,AR=
G5);
+ PRE_REG_READ5(long, "llseek",
+ unsigned int, fd, unsigned long, offset_high,
+ unsigned long, offset_low, vki_loff_t *, result,
+ unsigned int, whence);
+ PRE_MEM_WRITE( "llseek(result)", ARG4, sizeof(vki_loff_t));
+}
+POST(sys_llseek)
+{
+ vg_assert(SUCCESS);
+ if (RES =3D=3D 0)
+ POST_MEM_WRITE( ARG4, sizeof(vki_loff_t) );
+}
+
+//zz PRE(sys_adjtimex, 0)
+//zz {
+//zz struct vki_timex *tx =3D (struct vki_timex *)ARG1;
+//zz PRINT("sys_adjtimex ( %p )", ARG1);
+//zz PRE_REG_READ1(long, "adjtimex", struct timex *, buf);
+//zz PRE_MEM_READ( "adjtimex(timex->modes)", ARG1, sizeof(tx->modes))=
;
+//zz=20
+#if 0 //zz (avoiding warnings about multi-line comments)
+zz #define ADJX(bit,field) \
+zz if (tx->modes & bit) \
+zz PRE_MEM_READ( "adjtimex(timex->"#field")", \
+zz (Addr)&tx->field, sizeof(tx->field))
+#endif
+//zz ADJX(ADJ_FREQUENCY, freq);
+//zz ADJX(ADJ_MAXERROR, maxerror);
+//zz ADJX(ADJ_ESTERROR, esterror);
+//zz ADJX(ADJ_STATUS, status);
+//zz ADJX(ADJ_TIMECONST, constant);
+//zz ADJX(ADJ_TICK, tick);
+//zz #undef ADJX
+//zz =20
+//zz PRE_MEM_WRITE( "adjtimex(timex)", ARG1, sizeof(struct vki_timex)=
);
+//zz }
+//zz=20
+//zz POST(sys_adjtimex)
+//zz {
+//zz POST_MEM_WRITE( ARG1, sizeof(struct vki_timex) );
+//zz }
+
PRE(sys_ioperm)
{
PRINT("sys_ioperm ( %d, %d, %d )", ARG1, ARG2, ARG3 );
@@ -373,7 +377,6 @@
break;
}
}
-
POST(sys_syslog)
{
switch (ARG1) {
@@ -397,7 +400,6 @@
PRE_REG_READ1(long, "sysinfo", struct sysinfo *, info);
PRE_MEM_WRITE( "sysinfo(info)", ARG1, sizeof(struct vki_sysinfo) );
}
-
POST(sys_sysinfo)
{
POST_MEM_WRITE( ARG1, sizeof(struct vki_sysinfo) );
@@ -429,7 +431,6 @@
PRE_MEM_WRITE("sysctl(oldval)", (Addr)args->oldval, *args->oldlenp=
);
}
}
-
POST(sys_sysctl)
{
struct __vki_sysctl_args *args;
@@ -529,7 +530,6 @@
break;
}
}
-
POST(sys_futex)
{
vg_assert(SUCCESS);
@@ -545,6 +545,10 @@
}
}
=20
+/* ---------------------------------------------------------------------
+ epoll_* wrappers
+ ------------------------------------------------------------------ */
+
PRE(sys_epoll_create)
{
PRINT("sys_epoll_create ( %d )", ARG1);
@@ -593,12 +597,22 @@
POST_MEM_WRITE( ARG2, sizeof(struct vki_epoll_event)*RES ) ;
}
=20
+/* ---------------------------------------------------------------------
+ tid-related wrappers
+ ------------------------------------------------------------------ */
+
PRE(sys_gettid)
{
PRINT("sys_gettid ()");
PRE_REG_READ0(long, "gettid");
}
=20
+PRE(sys_set_tid_address)
+{
+ PRINT("sys_set_tid_address ( %p )", ARG1);
+ PRE_REG_READ1(long, "set_tid_address", int *, tidptr);
+}
+
//zz PRE(sys_tkill, Special)
//zz {
//zz /* int tkill(pid_t tid, int sig); */
@@ -646,7 +660,6 @@
/* Check to see if this kill gave us a pending signal */
*flags |=3D SfPollAfter;
}
-
POST(sys_tgkill)
{
if (VG_(clo_trace_signals))
@@ -654,6 +667,10 @@
ARG3, ARG1, ARG2);
}
=20
+/* ---------------------------------------------------------------------
+ fadvise64* wrappers
+ ------------------------------------------------------------------ */
+
PRE(sys_fadvise64)
{
PRINT("sys_fadvise64 ( %d, %lld, %lu, %d )",
@@ -672,6 +689,10 @@
vki_u32, len_low, vki_u32, len_high, int, advice);
}
=20
+/* ---------------------------------------------------------------------
+ io_* wrappers
+ ------------------------------------------------------------------ */
+
// Nb: this wrapper has to pad/unpad memory around the syscall itself,
// and this allows us to control exactly the code that gets run while
// the padding is in place.
@@ -830,12 +851,15 @@
PRE_MEM_READ( "io_cancel(iocb)", ARG2, sizeof(struct vki_iocb) );
PRE_MEM_WRITE( "io_cancel(result)", ARG3, sizeof(struct vki_io_event)=
);
}
-
POST(sys_io_cancel)
{
POST_MEM_WRITE( ARG3, sizeof(struct vki_io_event) );
}
=20
+/* ---------------------------------------------------------------------
+ *_mempolicy wrappers
+ ------------------------------------------------------------------ */
+
PRE(sys_set_mempolicy)
{
PRINT("sys_set_mempolicy ( %d, %p, %d )", ARG1,ARG2,ARG3);
@@ -867,6 +891,10 @@
POST_MEM_WRITE( ARG2, VG_ROUNDUP( ARG3, sizeof(UWord) * 8 ) / size=
of(UWord) );
}
=20
+/* ---------------------------------------------------------------------
+ inotify_* wrappers
+ ------------------------------------------------------------------ */
+
PRE(sys_inotify_init)
{
PRINT("sys_inotify_init ( )");
@@ -897,6 +925,10 @@
PRE_REG_READ2(long, "inotify_rm_watch", int, fd, int, wd);
}
=20
+/* ---------------------------------------------------------------------
+ mq_* wrappers
+ ------------------------------------------------------------------ */
+
PRE(sys_mq_open)
{
PRINT("sys_mq_open( %p(%s), %d, %lld, %p )",
@@ -1015,6 +1047,10 @@
POST_MEM_WRITE( ARG3, sizeof(struct vki_mq_attr) );
}
=20
+/* ---------------------------------------------------------------------
+ clock_* wrappers
+ ------------------------------------------------------------------ */
+
PRE(sys_clock_settime)
{
PRINT("sys_clock_settime( %d, %p )", ARG1,ARG2);
@@ -1068,6 +1104,10 @@
POST_MEM_WRITE( ARG4, sizeof(struct vki_timespec) );
}
=20
+/* ---------------------------------------------------------------------
+ timer_* wrappers
+ ------------------------------------------------------------------ */
+
PRE(sys_timer_create)
{
PRINT("sys_timer_create( %d, %p, %p )", ARG1,ARG2,ARG3);
@@ -1127,6 +1167,10 @@
PRE_REG_READ1(long, "timer_delete", vki_timer_t, timerid);
}
=20
+/* ---------------------------------------------------------------------
+ capabilities wrappers
+ ------------------------------------------------------------------ */
+
PRE(sys_capget)
{
PRINT("sys_capget ( %p, %p )", ARG1, ARG2 );
@@ -1155,6 +1199,10 @@
ARG2, sizeof(struct __vki_user_cap_data_struct) );
}
=20
+/* ---------------------------------------------------------------------
+ 16-bit uid/gid/groups wrappers
+ ------------------------------------------------------------------ */
+
PRE(sys_getuid16)
{
PRINT("sys_getuid16 ( )");
@@ -1225,6 +1273,10 @@
PRE_MEM_READ( "setgroups16(list)", ARG2, ARG1 * sizeof(vki_old_gid=
_t) );
}
=20
+/* ---------------------------------------------------------------------
+ *chown16 wrappers
+ ------------------------------------------------------------------ */
+
PRE(sys_chown16)
{
PRINT("sys_chown16 ( %p, 0x%x, 0x%x )", ARG1,ARG2,ARG3);
@@ -1241,6 +1293,10 @@
unsigned int, fd, vki_old_uid_t, owner, vki_old_gid_t, =
group);
}
=20
+/* ---------------------------------------------------------------------
+ *xattr wrappers
+ ------------------------------------------------------------------ */
+
PRE(sys_setxattr)
{
*flags |=3D SfMayBlock;
@@ -1400,6 +1456,10 @@
PRE_MEM_RASCIIZ( "fremovexattr(name)", ARG2 );
}
=20
+/* ---------------------------------------------------------------------
+ sched_* wrappers
+ ------------------------------------------------------------------ */
+
PRE(sys_sched_setparam)
{
PRINT("sched_setparam ( %d, %p )", ARG1, ARG2 );
|