[PATCH v2] Add -m flag to list system calls of a class.

Amin Khorsandi amin.khorsandi at gmail.com
Fri Jul 15 06:48:53 UTC 2016


On Thu, Jul 14, 2016 at 7:43 PM, Dmitry V. Levin <ldv at altlinux.org> wrote:

> On Tue, Jul 12, 2016 at 03:30:37PM +0200, Amin Khorsandiaghai wrote:
> > ---
> >  strace.1  |  5 +++++
> >  strace.c  |  6 +++++-
> >  syscall.c | 21 +++++++++++++++++++++
> >  3 files changed, 31 insertions(+), 1 deletion(-)
> >
> > diff --git a/strace.1 b/strace.1
> > index b7dddc0..5f5c1cc 100644
> > --- a/strace.1
> > +++ b/strace.1
> > @@ -488,6 +488,11 @@ When strace can be interrupted by signals (such as
> pressing ^C).
> >  4: fatal signals and SIGTSTP (^Z) are always blocked (useful to make
> >  strace -o FILE PROG not stop on ^Z).
> >  .TP
> > +.BI "\-m " traceclass
> > +List all system calls in a trace class. For example
> > +.BR "\-m file"
> > +prints the list of all system calls in file class.
> > +.TP
>
> Why -m?
>
> It was not taken already! :P
May I choose something like -e class=file?


> > @@ -1601,6 +1601,10 @@ init(int argc, char *argv[])
> >               case 'e':
> >                       qualify(optarg);
> >                       break;
> > +             case 'm':
> > +                     print_trace_class(optarg);
>
> The code shouldn't cause compilation warnings.
>
> I did not get any warnings when doing make!


> > --- a/syscall.c
> > +++ b/syscall.c
> > @@ -504,6 +504,27 @@ lookup_class(const char *s)
> >  }
> >
> >  void
> > +print_trace_class(const char *trace_class)
> > +{
> > +     unsigned int i;
> > +     unsigned pers;
> > +     int rc;
> > +
> > +     if ((rc = lookup_class(trace_class)) != -1) {
> > +             fprintf(stdout, "List of system calls in %s class\n",
> trace_class);
>
> Shouldn't there be a separate line printed for each personality?
> Shouldn't shared_log be used instead of stdout?
>
> See e.g. call_summary().
>
OK!

>
> > +             fprintf(stdout, "-------------------------------------\n");
> > +             for (pers = 0; pers < SUPPORTED_PERSONALITIES; pers++) {
> > +                     for (i = 0; i < nsyscall_vec[pers]; i++)
> > +                             if (sysent_vec[pers][i].sys_flags & rc) {
> > +                                     fprintf(stdout, "\t%s \n",
> sysent_vec[pers][i].sys_name);
>
> This line's too long.
>
What is the line length limit?


> > +                             }
> > +             }
> > +     } else {
> > +             error_msg_and_die("invalid class '%s'", trace_class);
> > +     }
>
> The preferred style is
>
>         int rc = lookup_class(trace_class);
>
>         if (rc < 0)
>                 error_msg_and_die("invalid class '%s'", trace_class);
>
>         ...
>
> --
> ldv
>
>
> ------------------------------------------------------------------------------
> What NetFlow Analyzer can do for you? Monitors network bandwidth and
> traffic
> patterns at an interface-level. Reveals which users, apps, and protocols
> are
> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
> J-Flow, sFlow and other flows. Make informed decisions using capacity
> planning
> reports.http://sdm.link/zohodev2dev
> _______________________________________________
> Strace-devel mailing list
> Strace-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/strace-devel
>
>

Also do you know how can I filter out the duplicated system calls which are
shared between
personalities? Should I implement a solution for it or is there already a
way for this?
For example open system call exist in all three personalities available in
x86_64 systems.
I want to only print one of them.

BR,
-Amin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20160715/e5245fc1/attachment.html>


More information about the Strace-devel mailing list