[PATCHv2 3/4] Add functions for dumping iovecs in mmsghdr used in sendmmsg and recvmmsg

Dmitry V. Levin ldv at altlinux.org
Fri Nov 7 04:05:36 UTC 2014


On Fri, Nov 07, 2014 at 11:38:21AM +0900, Masatake YAMATO wrote:
[...]
> +void
> +dumpiov_in_mmsghdr(struct tcb *tcp, long addr)
> +{
> +	unsigned int len = tcp->u_rval;
> +	unsigned int i;
> +	struct mmsghdr mmsg;
> +
> +	for (i = 0; i < len; ++i)
> +	{
> +		if (extractmmsghdr(tcp, addr, i, &mmsg))
> +		{
> +			tprintf(" = %lu buffers in vector %u\n", mmsg.msg_hdr.msg_iovlen, i);
> +			dumpiov(tcp, mmsg.msg_hdr.msg_iovlen, (long)mmsg.msg_hdr.msg_iov);
> +		}
> +	}
> +}
> +

This new function is derived from printmmsghdr and decode_mmsg,
so I'd place it after them.
Note that we put curly braces on line with "if" and "for".

[...]
> --- a/syscall.c
> +++ b/syscall.c
> @@ -2501,6 +2501,10 @@ dumpio(struct tcb *tcp)
>  		else if (func == sys_recvmsg)
>  			dumpiov_in_msghdr(tcp, tcp->u_arg[1]);
>  #endif
> +#if HAVE_SENDMMSG
> +		else if (func == sys_recvmmsg)
> +			dumpiov_in_mmsghdr(tcp, tcp->u_arg[1]);
> +#endif
>  		return;
>  	}
>  	if (qual_flags[tcp->u_arg[0]] & QUAL_WRITE) {
> @@ -2515,6 +2519,10 @@ dumpio(struct tcb *tcp)
>  		else if (func == sys_sendmsg)
>  			dumpiov_in_msghdr(tcp, tcp->u_arg[1]);
>  #endif
> +#if HAVE_SENDMMSG
> +		else if (func == sys_sendmmsg)
> +			dumpiov_in_mmsghdr(tcp, tcp->u_arg[1]);
> +#endif
>  		return;
>  	}
>  }

I think we could do without HAVE_SENDMMSG here and reuse HAVE_SENDMSG,
since the code in net.c depends only on HAVE_SENDMSG.

That is, the configure test for sendmmsg is not needed for this patch,
but it may be needed later in tests/mmsg.c (like similar tests for
preadv/pwritev in tests/uio.c).


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20141107/3988ab0e/attachment.bin>


More information about the Strace-devel mailing list