}
+
/* Set the current result status/value in various ways. */
#define SET_STATUS_Success(zzz) \
do { status->what = SsSuccess; \
VG_(printf)(format, ## args)
+
/* 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. */
PRRSN == "pre-register-read-syscall"
*/
+/* 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 = 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 = layout->o_arg##n; \
+ vg_assert(sizeof(t) <= 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 = offset_of_reg + sizeof(reg)
+ 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 = layout->o_arg##n + sizeof(UWord); \
+ vg_assert(sizeof(t) <= 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; \