[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
Thu Jul 7 18:15:20 UTC 2016


Hi,

Please ignore this patch. I sent another one (the correct patch) later.

Best regards,
-Amin

On Thu, Jul 7, 2016 at 2:09 PM, <aminkhorsandi at gmail.com> wrote:

> From: Amin Khorsandi <amin.khorsandi at infinera.com>
>
> ---
>  strace.1  |  5 +++++
>  syscall.c | 31 ++++++++++++++++++++++++++++++-
>  2 files changed, 35 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 .
>  .TP
>  .BR "\-e\ trace" = process
>  Trace all system calls which involve process management.  This
> diff --git a/syscall.c b/syscall.c
> index c61f827..0df7fd9 100644
> --- a/syscall.c
> +++ b/syscall.c
> @@ -503,6 +503,30 @@ lookup_class(const char *s)
>         return -1;
>  }
>
> +static void
> +print_class_syscalls(int class)
> +{
> +       unsigned int i;
> +       unsigned pers = 0; /* only print system calls in personality 0 */
> +       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);
> +               }
> +}
> +
> +static void
> +print_trace_class(const char* trace_class)
> +{
> +       int class = lookup_class(trace_class);
> +       if (class != -1) {
> +               printf("List of system calls in %s class\n", trace_class);
> +               printf("%s\n", "-------------------------------------");
> +               print_class_syscalls(class);
> +       } else {
> +               error_msg_and_die("invalid class name '%s'", trace_class);
> +       }
> +}
> +
>  void
>  qualify(const char *s)
>  {
> @@ -518,7 +542,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);
> +               }
> +               else if (strncmp(s, p, len) == 0 && s[len] == '=') {
>                         opt = &qual_options[i];
>                         s += len + 1;
>                         break;
> --
> 2.4.10
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20160707/c3c70d9e/attachment.html>


More information about the Strace-devel mailing list