On Wed, May 28, 2014 at 09:20:04PM +0530, zubin.mit...@gmail.com wrote:
> From: Zubin Mithra <zubin.mit...@gmail.com>
> 
> * Type of `show_fd_path` changed from `bool` to `unsigned int` to
>   support the `-yy` flag.

This change is no longer needed in this patch.

> * util.c (returns_fd): New function that checks if the tcb refers
>   to a function that returns a file descriptor.
> * (trace_syscall_exiting): Use returns_fd to determine whether
>   tcp->u_rval is a file descriptor.

Please have a look at GNU ChangeLog style guideline:
http://www.gnu.org/prep/standards/html_node/Change-Logs.html

* defs.h (returns_fd): New prototype.
* util.c (returns_fd): New function that checks if the tcb refers
to a function that returns a file descriptor.
* syscall.c (trace_syscall_exiting): Use returns_fd to determine whether
tcp->u_rval is a file descriptor.

> diff --git a/syscall.c b/syscall.c
> index 28bdb66..4932bbe 100644
> --- a/syscall.c
> +++ b/syscall.c
> @@ -2669,7 +2669,12 @@ trace_syscall_exiting(struct tcb *tcp)
>                               tprintf("= %lu", tcp->u_rval);
>                               break;
>                       case RVAL_DECIMAL:
> -                             tprintf("= %ld", tcp->u_rval);
> +                             if ( show_fd_path && returns_fd(tcp) ) {

Please don't add a space after the opening parenthesis and before the
closing parenthesis.

> diff --git a/util.c b/util.c
> index ff18b87..b1f1e90 100644
> --- a/util.c
> +++ b/util.c
> @@ -1549,3 +1549,16 @@ clearbpt(struct tcb *tcp)
>       tcp->flags &= ~TCB_BPTSET;
>       return 0;
>  }
> +
> +bool
> +returns_fd(struct tcb *tcp)
> +{
> +     if ( tcp->s_ent->sys_func == sys_open   ||
> +          tcp->s_ent->sys_func == sys_openat ||
> +          tcp->s_ent->sys_func == sys_creat  ||
> +          tcp->s_ent->sys_func == sys_dup    ||
> +          tcp->s_ent->sys_func == sys_dup2   ||
> +          tcp->s_ent->sys_func == sys_dup3 )
> +             return 1;
> +     return 0;
> +}

This could be simplified to
        return tcp->s_ent->sys_func == sys_open   ||
               tcp->s_ent->sys_func == sys_openat ||
               tcp->s_ent->sys_func == sys_creat  ||
               tcp->s_ent->sys_func == sys_dup    ||
               tcp->s_ent->sys_func == sys_dup2   ||
               tcp->s_ent->sys_func == sys_dup3;


-- 
ldv

Attachment: pgpSHAjWadg38.pgp
Description: PGP signature

------------------------------------------------------------------------------
Time is money. Stop wasting it! Get your web API in 5 minutes.
www.restlet.com/download
http://p.sf.net/sfu/restlet
_______________________________________________
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to