[PATCH v1] Extend -e flag to provide the user possibility of listing all system calls in a class.

Amin Khorsandi amin.khorsandi at gmail.com
Tue Jul 12 13:36:45 UTC 2016


Hi,

Please see the updated patch.
I add a new flag for this purpose.
The reason for not including all personalities was that some system calls
are repeated in different personalities.
Now it prints everything! Did not think of a clean way for excluding the
duplicates.

BR,
-Amin

On Mon, Jul 11, 2016 at 10:44 PM, Dmitry V. Levin <ldv at altlinux.org> wrote:

> On Thu, Jul 07, 2016 at 04:17:16PM +0200, aminkhorsandi at gmail.com wrote:
> > From: Amin Khorsandi <amin.khorsandi at infinera.com>
> >
> > ---
> >  strace.1  |  5 +++++
> >  syscall.c | 26 +++++++++++++++++++++++++-
> >  2 files changed, 30 insertions(+), 1 deletion(-)
> >
> > diff --git a/strace.1 b/strace.1
> > index b7dddc0..c2088fa 100644
> > --- a/strace.1
> > +++ b/strace.1
> > @@ -403,6 +403,11 @@ Furthermore, using the abbreviation will ensure
> that you don't
> >  accidentally forget to include a call like
> >  .B lstat
> >  in the list.  Betchya woulda forgot that one.
> > +To see a list of all system calls in a class you can use
> > +.BR "-e\ trace?" = classname .
> > +For example you can see what are the system calls in the network
> > +class running strace using the option
> > +.BR "-e\ trace?" = network .
>
> This extension of "-e trace=" syntax might appear to be confusing,
> especially if it isn't consistent with traditional "-e trace=" syntax,
> see below.
>
> >  .TP
> >  .BR "\-e\ trace" = process
> >  Trace all system calls which involve process management.  This
> > diff --git a/syscall.c b/syscall.c
> > index c61f827..fb20f65 100644
> > --- a/syscall.c
> > +++ b/syscall.c
> > @@ -503,6 +503,25 @@ lookup_class(const char *s)
> >       return -1;
> >  }
> >
> > +static void
> > +print_trace_class(const char* trace_class)
> > +{
> > +     unsigned int i;
> > +     unsigned pers = 0; /* only print system calls in personality 0 */
>
> Why?  Traditional "-e trace=" syntax is not limited to personality 0.
>
> > +     int class = lookup_class(trace_class);
>
> Traditional "-e trace=" syntax accepts lists.
>
> > +
> > +     if (class != -1) {
> > +             printf("List of system calls in %s class\n", trace_class);
> > +             printf("%s\n", "-------------------------------------");
>
> Why printf instead of traditional fprintf(shared_log)?
>
> > +             for (i = 0; i < nsyscall_vec[pers]; i++)
> > +                     if (sysent_vec[pers][i].sys_flags & class) {
> > +                     printf("\t%s \n", sysent_vec[pers][i].sys_name);
> > +             }
>
> This indentation is misleading.
>
> > +     } else {
> > +             error_msg_and_die("invalid class name '%s'", trace_class);
> > +     }
> > +}
> > +
> >  void
> >  qualify(const char *s)
> >  {
> > @@ -518,7 +537,12 @@ qualify(const char *s)
> >       opt = &qual_options[0];
> >       for (i = 0; (p = qual_options[i].option_name); i++) {
> >               unsigned int len = strlen(p);
> > -             if (strncmp(s, p, len) == 0 && s[len] == '=') {
> > +             if (strncmp(s, p, len) == 0 && s[len] == '?' && s[len + 1]
> == '=') {
> > +                     s += len + 2;
> > +                     print_trace_class(s);
> > +                     exit(0);
>
> Traditional "-e trace=" syntax doesn't stop after the first option.
>
> > +             }
> > +             else if (strncmp(s, p, len) == 0 && s[len] == '=') {
> >                       opt = &qual_options[i];
> >                       s += len + 1;
> >                       break;
>
> In short, either this new extension should match traditional "-e trace="
> syntax, or it shouldn't be called "-e trace?=".
>
>
> --
> ldv
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20160712/e667c249/attachment.html>


More information about the Strace-devel mailing list