|
From: <sv...@va...> - 2005-07-10 00:55:28
|
Author: sewardj
Date: 2005-07-10 01:55:26 +0100 (Sun, 10 Jul 2005)
New Revision: 4143
Log:
Get rid of endianness assumptions in the PRRAn macro, which is
important for doing checks of scalar syscall args.
Modified:
trunk/coregrind/m_syswrap/priv_types_n_macros.h
Modified: trunk/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
--- trunk/coregrind/m_syswrap/priv_types_n_macros.h 2005-07-10 00:53:42 U=
TC (rev 4142)
+++ trunk/coregrind/m_syswrap/priv_types_n_macros.h 2005-07-10 00:55:26 U=
TC (rev 4143)
@@ -252,6 +252,7 @@
}
=20
=20
+
/* Set the current result status/value in various ways. */
#define SET_STATUS_Success(zzz) \
do { status->what =3D SsSuccess; \
@@ -281,6 +282,7 @@
VG_(printf)(format, ## args)
=20
=20
+
/* Macros used to tell tools about uses of scalar arguments. Note,
these assume little-endianness. These can only be used in
pre-wrappers, and they refer to the layout parameter passed in. */
@@ -288,12 +290,58 @@
PRRSN =3D=3D "pre-register-read-syscall"
*/
=20
+/* Tell the tool that the syscall number is being read. */
#define PRRSN \
VG_(tdict).track_pre_reg_read(Vg_CoreSysCall, tid, "(syscallno)", =
\
layout->o_sysno, sizeof(UWord));
-#define PRRAn(n,s,t,a) \
- VG_(tdict).track_pre_reg_read(Vg_CoreSysCall, tid, s"("#a")", \
- layout->o_arg##n, sizeof(t));
+
+
+/* PRRAn: Tell the tool that the register holding the n-th syscall
+ argument is being read, at type 't' which must be at most the size
+ of a register but can be smaller. In the latter case we need to be
+ careful about endianness. */
+
+/* little-endian: the part of the guest state being read is
+ let here =3D offset_of_reg
+ in [here .. here + sizeof(t) - 1]
+ since the least significant parts of the guest register are stored
+ in memory at the lowest address.
+*/
+#define PRRAn_LE(n,s,t,a) \
+ do { \
+ Int here =3D layout->o_arg##n; \
+ vg_assert(sizeof(t) <=3D sizeof(UWord)); \
+ VG_(tdict).track_pre_reg_read( \
+ Vg_CoreSysCall, tid, s"("#a")", \
+ here, sizeof(t) \
+ ); \
+ } while (0)
+
+/* big-endian: the part of the guest state being read is
+ let next =3D offset_of_reg + sizeof(reg)=20
+ in [next - sizeof(t) .. next - 1]
+ since the least significant parts of the guest register are stored
+ in memory at the highest address.
+*/
+#define PRRAn_BE(n,s,t,a) \
+ do { \
+ Int next =3D layout->o_arg##n + sizeof(UWord); \
+ vg_assert(sizeof(t) <=3D sizeof(UWord)); \
+ VG_(tdict).track_pre_reg_read( \
+ Vg_CoreSysCall, tid, s"("#a")", \
+ next-sizeof(t), sizeof(t) \
+ ); \
+ } while (0)
+
+#if defined(VG_BIGENDIAN)
+# define PRRAn(n,s,t,a) PRRAn_BE(n,s,t,a)
+#elif defined(VG_LITTLEENDIAN)
+# define PRRAn(n,s,t,a) PRRAn_LE(n,s,t,a)
+#else
+# error "Unknown endianness"
+#endif
+
+
#define PRE_REG_READ0(tr, s) \
if (VG_(tdict).track_pre_reg_read) { \
PRRSN; \
|