|
From: <sv...@va...> - 2006-10-13 20:24:22
|
Author: sewardj
Date: 2006-10-13 21:24:17 +0100 (Fri, 13 Oct 2006)
New Revision: 6220
Log:
Tidy up macros for pulling results out of the SyscallStatus structure.
This fixes a subtle bug introduced by the simplification of the
SyscallStatus structure in the AIX branch. Fortunately
memcheck/tests/post-syscall caught it.
Modified:
branches/AIX5/coregrind/m_syswrap/priv_types_n_macros.h
branches/AIX5/coregrind/m_syswrap/syswrap-aix5.c
branches/AIX5/coregrind/m_syswrap/syswrap-generic.c
branches/AIX5/coregrind/m_syswrap/syswrap-linux.c
Modified: branches/AIX5/coregrind/m_syswrap/priv_types_n_macros.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
--- branches/AIX5/coregrind/m_syswrap/priv_types_n_macros.h 2006-10-13 11=
:10:21 UTC (rev 6219)
+++ branches/AIX5/coregrind/m_syswrap/priv_types_n_macros.h 2006-10-13 20=
:24:17 UTC (rev 6220)
@@ -271,26 +271,13 @@
#define ARG7 (arrghs->arg7)
#define ARG8 (arrghs->arg8)
=20
-/* Reference to the syscall's current result status/value. Note that
- =20
- (1) status->val by itself is meaningless -- you have to consider it
- together with status->what, which is why RES uses a helper
- function (this also has the desirable effect of turning RES
- into a non-lvalue).
-
- (2) post-wrappers will not get called in case of failure (unless
- PostOnFail is set, which is rare). This is why the assertion
- in getRES is viable.
-
- If you really really want to just get hold of status->val without
- inspecting status->what, use RES_unchecked. This is dangerous and
- therefore discouraged. =20
-*/
+/* Reference to the syscall's current result status/value. General
+ paranoia all round. */
#define SUCCESS (status->what =3D=3D SsComplete && !status->sres.i=
sError)
#define FAILURE (status->what =3D=3D SsComplete && status->sres.i=
sError)
#define SWHAT (status->what)
-#define RES_unchecked (status->sres.res) /* do not use! */
-#define RES (getRES(status)) /* use this instead, if possibl=
e */
+#define RES (getRES(status))
+#define ERR (getERR(status))
=20
static inline UWord getRES ( SyscallStatus* st ) {
vg_assert(st->what =3D=3D SsComplete);
@@ -298,6 +285,11 @@
return st->sres.res;
}
=20
+static inline UWord getERR ( SyscallStatus* st ) {
+ vg_assert(st->what =3D=3D SsComplete);
+ vg_assert(st->sres.isError);
+ return st->sres.err;
+}
=20
=20
/* Set the current result status/value in various ways. */
Modified: branches/AIX5/coregrind/m_syswrap/syswrap-aix5.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
--- branches/AIX5/coregrind/m_syswrap/syswrap-aix5.c 2006-10-13 11:10:21 =
UTC (rev 6219)
+++ branches/AIX5/coregrind/m_syswrap/syswrap-aix5.c 2006-10-13 20:24:17 =
UTC (rev 6220)
@@ -1033,7 +1033,7 @@
hosed:
vg_assert(FAILURE);
VG_(message)(Vg_UserMsg, "execve(%p(%s), %p, %p) failed, errno %d",
- ARG1, ARG1, ARG2, ARG3, RES_unchecked);
+ ARG1, ARG1, ARG2, ARG3, ERR);
VG_(message)(Vg_UserMsg, "EXEC FAILED: I can't recover from "
"execve() failing, so I'm dying.");
VG_(message)(Vg_UserMsg, "Add more stringent tests in PRE(sys_execve)=
, "
Modified: branches/AIX5/coregrind/m_syswrap/syswrap-generic.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
--- branches/AIX5/coregrind/m_syswrap/syswrap-generic.c 2006-10-13 11:10:=
21 UTC (rev 6219)
+++ branches/AIX5/coregrind/m_syswrap/syswrap-generic.c 2006-10-13 20:24:=
17 UTC (rev 6220)
@@ -2548,7 +2548,7 @@
hosed:
vg_assert(FAILURE);
VG_(message)(Vg_UserMsg, "execve(%p(%s), %p, %p) failed, errno %d",
- ARG1, ARG1, ARG2, ARG3, RES_unchecked);
+ ARG1, ARG1, ARG2, ARG3, ERR);
VG_(message)(Vg_UserMsg, "EXEC FAILED: I can't recover from "
"execve() failing, so I'm dying.");
VG_(message)(Vg_UserMsg, "Add more stringent tests in PRE(sys_execve)=
, "
@@ -4940,7 +4940,7 @@
POST(sys_nanosleep)
{
vg_assert(SUCCESS || FAILURE);
- if (ARG2 !=3D 0 && FAILURE && RES_unchecked =3D=3D VKI_EINTR)
+ if (ARG2 !=3D 0 && FAILURE && ERR =3D=3D VKI_EINTR)
POST_MEM_WRITE( ARG2, sizeof(struct vki_timespec) );
}
=20
Modified: branches/AIX5/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
--- branches/AIX5/coregrind/m_syswrap/syswrap-linux.c 2006-10-13 11:10:21=
UTC (rev 6219)
+++ branches/AIX5/coregrind/m_syswrap/syswrap-linux.c 2006-10-13 20:24:17=
UTC (rev 6220)
@@ -1498,7 +1498,7 @@
}
POST(sys_clock_nanosleep)
{
- if (ARG4 !=3D 0 && FAILURE && RES_unchecked =3D=3D VKI_EINTR)
+ if (ARG4 !=3D 0 && FAILURE && ERR =3D=3D VKI_EINTR)
POST_MEM_WRITE( ARG4, sizeof(struct vki_timespec) );
}
=20
|