From: Paul Floyd Date: Thu, 22 Dec 2022 22:38:54 +0000 (+0100) Subject: Improve FreeBSD preadv/pwritev error messages X-Git-Tag: VALGRIND_3_21_0~269 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8b0105ba63ab18af6a17e55daafda6ab1371c141;p=thirdparty%2Fvalgrind.git Improve FreeBSD preadv/pwritev error messages Also correct a copy paste error in generic readv. --- diff --git a/coregrind/m_syswrap/syswrap-amd64-freebsd.c b/coregrind/m_syswrap/syswrap-amd64-freebsd.c index 2ef0f89451..3b2f9397d1 100644 --- a/coregrind/m_syswrap/syswrap-amd64-freebsd.c +++ b/coregrind/m_syswrap/syswrap-amd64-freebsd.c @@ -321,6 +321,7 @@ PRE(sys_preadv) { Int i; struct vki_iovec * vec; + char buf[sizeof("preadv(iov[])") + 11]; *flags |= SfMayBlock; PRINT("sys_preadv ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD "d, %" FMT_REGWORD "d )", SARG1, ARG2, SARG3, SARG4); @@ -333,12 +334,12 @@ PRE(sys_preadv) if ((Int)ARG3 > 0) PRE_MEM_READ( "preadv(iov)", ARG2, ARG3 * sizeof(struct vki_iovec) ); - // @todo PJF improve this like readv if (ML_(safe_to_deref)((struct vki_iovec *)ARG2, ARG3 * sizeof(struct vki_iovec))) { vec = (struct vki_iovec *)(Addr)ARG2; - for (i = 0; i < (Int)ARG3; i++) - PRE_MEM_WRITE( "preadv(iov[...])", - (Addr)vec[i].iov_base, vec[i].iov_len ); + for (i = 0; i < (Int)ARG3; i++) { + VG_(sprintf)(buf, "preadv(iov[%d])", i); + PRE_MEM_WRITE(buf, (Addr)vec[i].iov_base, vec[i].iov_len); + } } } } @@ -368,6 +369,7 @@ PRE(sys_pwritev) { Int i; struct vki_iovec * vec; + char buf[sizeof("pwritev(iov[])") + 11]; *flags |= SfMayBlock; PRINT("sys_pwritev ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD "d, %" FMT_REGWORD "d )", SARG1, ARG2, SARG3, SARG4); @@ -383,9 +385,10 @@ PRE(sys_pwritev) PRE_MEM_READ( "pwritev(vector)", ARG2, ARG3 * sizeof(struct vki_iovec) ); if (ML_(safe_to_deref)((struct vki_iovec *)ARG2, ARG3 * sizeof(struct vki_iovec))) { vec = (struct vki_iovec *)(Addr)ARG2; - for (i = 0; i < (Int)ARG3; i++) - PRE_MEM_READ( "pwritev(iov[...])", - (Addr)vec[i].iov_base, vec[i].iov_len ); + for (i = 0; i < (Int)ARG3; i++) { + VG_(sprintf)(buf, "pwritev(iov[%d])", i); + PRE_MEM_READ(buf, (Addr)vec[i].iov_base, vec[i].iov_len ); + } } } } diff --git a/coregrind/m_syswrap/syswrap-generic.c b/coregrind/m_syswrap/syswrap-generic.c index 4e10eea9fe..efdae60e10 100644 --- a/coregrind/m_syswrap/syswrap-generic.c +++ b/coregrind/m_syswrap/syswrap-generic.c @@ -4409,7 +4409,7 @@ PRE(sys_readv) { Int i; struct vki_iovec * vec; - char buf[sizeof("writev(vector[])") + 11]; + char buf[sizeof("readv(vector[])") + 11]; *flags |= SfMayBlock; PRINT("sys_readv ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", ARG1, ARG2, ARG3); @@ -4425,7 +4425,7 @@ PRE(sys_readv) if (ML_(safe_to_deref)((const void*)ARG2, ARG3*sizeof(struct vki_iovec *))) { vec = (struct vki_iovec *)(Addr)ARG2; for (i = 0; i < (Int)ARG3; i++) { - VG_(sprintf)(buf, "writev(vector[%d])", i); + VG_(sprintf)(buf, "readv(vector[%d])", i); PRE_MEM_WRITE(buf, (Addr)vec[i].iov_base, vec[i].iov_len ); } }