decoding of input/output args ?

Patrik Jakobsson patrik.jakobsson at linux.intel.com
Mon Aug 24 09:01:39 UTC 2015


On Thu, Aug 20, 2015 at 01:43:33AM +0300, Dmitry V. Levin wrote:
> On Wed, Aug 19, 2015 at 04:59:38PM -0400, Mike Frysinger wrote:
> > On 19 Aug 2015 22:36, Dmitry V. Levin wrote:
> > > On Wed, Aug 19, 2015 at 03:17:39PM -0400, Mike Frysinger wrote:
> > > > some syscalls have arguments that are read/write.  for example, getsockopt 
> > > > passes in a pointer to a length that has to be set correctly first, and then
> > > > the kernel will adjust it when returning.  being able to see both values is
> > > > important when getting an error so you can see what the user sent up and what
> > > > the kernel sent back.
> > > > 
> > > > are there examples in strace to look at ?  perhaps something like:
> > > > getsockopt(4, SOL_IP, IPT_SO_GET_ENTRIES, "...", [2900->2804]) = 0
> > > > and when you get an error it'd be:
> > > > getsockopt(4, SOL_IP, IPT_SO_GET_ENTRIES, 0x12345, [2900->2900]) = EINVAL
> > > 
> > > I think there is no need to print it in case of an error,
> > > when it's known to be unchanged.
> > > 
> > > We have several examples in the code:
> > > $ git grep '[^a-z] => ' *.c
> > > mtd.c:			tprints(" => ");
> > > mtd.c:			tprints(" => ");
> > > sendfile.c:			tprints(" => ");
> > > sendfile.c:			tprints(" => ");
> > > sock.c:	tprints(" => ");
> > > v4l2.c:			tprints(exiting(tcp) && code != VIDIOC_G_FMT ? " => " : ", ");
> > > v4l2.c:		tprints(exiting(tcp) && code == VIDIOC_S_PARM ? " => {" : ", {");
> > > v4l2.c:			tprints(exiting(tcp) ? " => " : ", {id=");
> > > v4l2.c:		tprints(code != VIDIOC_G_EXT_CTRLS && exiting(tcp) ? " => " : ", ");
> > > 
> > > The most recent one is from commits v4.10-319-g22f8b27 and
> > > v4.10-320-g4918285.
> > 
> > output format looks fine.
> 
> [before => after] might look better, but
> [before] => [after] is easier to implement.
> 
> > but there's another wrinkle here :).  sendfile is 
> > easy -- the leading args are input only, and the last one is input/output,
> > so incremental output is not an issue.  getsockopt is inputs, then output,
> > then input/output.  so i can't print the last input in the entering code path
> > and then print the output in the exiting code path.  i need to read the curr
> > value, save it in the tcp structure somehow (?), and then read that back out
> > in the exiting code path.
> 
> This is not the first time a necessity to save some data between entering
> and exiting stages of a syscall parser is mentioned.  For example, there
> was a discussion back in July about adding a private data field
> to struct tcb: http://sourceforge.net/p/strace/mailman/message/34262875/
> 
> However, none of those ideas have been implemented yet.

I have an implementation for private data in struct tcb and will send out
patches very soon. Meanwhile you can have a look at
https://github.com/patjak/strace-i915 i915-v4

-Patrik
> 
> 
> -- 
> ldv



> ------------------------------------------------------------------------------

> _______________________________________________
> Strace-devel mailing list
> Strace-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/strace-devel





More information about the Strace-devel mailing list