Hi YangMin,

On Thu, Jun 19, 2014 at 12:29:49AM +0800, Zhu YangMin wrote:
> The basic means that all the arguments are simply wrapped in
> a string value even for those complicated arguments printed by
> specific functions such as printflags(). We need to do more work
> to change those functions to be more like JSON-style.
> 
> * io.c(sys_read, sys_write, sys_readv, sys_writev,
> sys_pread, sys_pwrite, sys_preadv, sys_pwritev,
> sys_sendfile, sys_sendfile64, sys_tee, sys_splice,
> sys_vmsplice, sys_ioctl): Modified to use the hook
> framework to support printing in JSON format. Note: The
> support of ioctl() is very limited and need to be improved.

Thanks for these examples.  Let's have a look at the first one:

> int
> sys_read(struct tcb *tcp)
> {
>       JSON_BEGIN_META_MODE;
> 
>       if (entering(tcp)) {
>               JSON_META( printfd(tcp, tcp->u_arg[0]); );
>               tprints(", ");
> 
>               json_event(1, EVENT_ARG | SEPARATOR);
>       } else {
>               json_type_event first;
> 
>               if (syserror(tcp)) {
>                       tprintf("%#lx", tcp->u_arg[1]);
>                       first = EVENT_ERROR;
>               }
>               else {
>                       JSON_META( printstr(tcp, tcp->u_arg[1], tcp->u_rval) );
>                       first = EVENT_ARG;
>               }
>               tprintf(", %lu", tcp->u_arg[2]);
> 
>               json_event(2, first | SEPARATOR, EVENT_ARG);
>       }
>       return 0;
> }

Well, compared to the original code, it looks rather complicated.
I thought it could be something easier to read, for example,

int
sys_read(struct tcb *tcp)
{
        if (entering(tcp)) {
                print_args_open();
                print_arg_fd(tcp->u_arg[0]);
        } else {
                if (syserror(tcp))
                        print_arg_fmt("%#lx", tcp->u_arg[1]);
                else
                        print_arg_str_at(tcp->u_arg[1], tcp->u_rval);
                print_arg_fmt("%lu", tcp->u_arg[2]);
                print_args_close();
        }
        return 0;
}

That is, with all JSON related details hidden from syscall parsers.
What do you think?


-- 
ldv

Attachment: pgp2nAeCFjqgW.pgp
Description: PGP signature

------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to