[GSOC 2014][PATCH 3/4] JSON: Add basic support for syscalls in io.c

yangmin zhu zym0017d at gmail.com
Tue Jul 8 15:46:47 UTC 2014


Hi Dmitry,

>
> In this example, since va_list processing is easier and more efficient
> than string parsing, I'd recommend
>         json_printf(JSON_ARG, JSON_SEP, 0L);
> instead of
>         json_printf("arg sepa");
>
> Also, when a function name ends with "printf", it is expected to take a
> printf-style format string.  If it doesn't, give it a different name.
>

I'm working on the refactor as we discussed earlier, you can see the
code in [1].
Once I finished the refactor I will clean and send the patches to the
mailing list.


I used a macro to add the 'JSON_LAST' automatically, and renamed
json_event() to json_output_event:
void json_output_event(json_type_event event, ...);
#define json_event(...) json_output_event( __VA_ARGS__ , JSON_LAST)


I also changed a lot of the inner implementation of
json_output_event(), but this will not affect how to use it.
I'm implementing the JSON support inside those detail-output
functions(such as printfd()),
so we could not care about how to use it, and just use it in normal
way and it will then finish all the JSON output automatically.

After this refactor, we can modify all sys_* functions like this one:
int
sys_read(struct tcb *tcp)
{
    if (entering(tcp)) {
        printfd(tcp, tcp->u_arg[0]);
        tprints(", ");
        json_event(JSON_SEPA);
    } else {
        if (syserror(tcp)) {
            tprintf("%#lx", tcp->u_arg[1]);
            json_event(JSON_ERROR);
        }
        else
            printstr(tcp, tcp->u_arg[1], tcp->u_rval);

        tprintf(", %lu", tcp->u_arg[2]);
        json_event(JSON_SEPA, JSON_ARG);
    }
    return 0;
}

[1] https://github.com/zym0017d/strace_GSOC/commits/refactor

Thank you!
---
YangMin




More information about the Strace-devel mailing list