On Fri, Aug 11, 2017 at 05:43:49PM +0700, Nikolay Marchuk wrote:
> * filter_action.c (default_flags): Add default flags variable.
> (add_action): Update default flags.
> (filter_syscall): Add default_flags to qual_flg.
> (filtering_parse_finish): Init trace action for pathtracing.
> * strace.c (init): Remove default filters.
> ---
>  filter_action.c | 10 ++++++++++
>  strace.c        |  3 ---
>  2 files changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/filter_action.c b/filter_action.c
> index c040eda6..be4af4d3 100644
> --- a/filter_action.c
> +++ b/filter_action.c
> @@ -94,6 +94,7 @@ struct filter_action {
>       void *_priv_data;
>  };
>  
> +static int default_flags = DEFAULT_QUAL_FLAGS;
>  static struct filter_action *filter_actions;
>  static unsigned int nfilter_actions;
>  
> @@ -124,6 +125,10 @@ filtering_parsing_finish(void)
>       unsigned int maxfilters = 0;
>       unsigned int i;
>  
> +     /* Init trace action if pathtracing is enabled */
> +     if (tracing_paths && (default_flags & QUAL_TRACE))
> +             parse_qualify_filter("trace=all");
Btw, you can post-process -P option as adding && path(...) to trace
action. This would save for all these pathtrace-specific kludges here
and in apply_trace.

> +
>       /* Sort actions by priority */
>       if (nfilter_actions == 0)
>               return;
> @@ -155,6 +160,10 @@ add_action(const struct filter_action_type *type)
>  {
>       struct filter_action *action;
>  
> +     /* Update default_flags */
> +     if (default_flags & type->qual_flg)
> +             default_flags &= ~type->qual_flg;
> +
>       filter_actions = xreallocarray(filter_actions, ++nfilter_actions,
>                                      sizeof(struct filter_action));
>       action = &filter_actions[nfilter_actions - 1];
> @@ -212,6 +221,7 @@ filter_syscall(struct tcb *tcp)
>  {
>       unsigned int i;
>  
> +     tcp->qual_flg |= default_flags;
>       for (i = 0; i < nfilter_actions; ++i)
>               run_filter_action(tcp, &filter_actions[i]);
>  }
> diff --git a/strace.c b/strace.c
> index 88f7168e..6162d3b3 100644
> --- a/strace.c
> +++ b/strace.c
> @@ -1577,9 +1577,6 @@ init(int argc, char *argv[])
>       shared_log = stderr;
>       set_sortby(DEFAULT_SORTBY);
>       set_personality(DEFAULT_PERSONALITY);
> -     parse_qualify_filter("trace=all");
> -     parse_qualify_filter("abbrev=all");
> -     parse_qualify_filter("verbose=all");
>  #if DEFAULT_QUAL_FLAGS != (QUAL_TRACE | QUAL_ABBREV | QUAL_VERBOSE)
>  # error Bug in DEFAULT_QUAL_FLAGS
>  #endif
> -- 
> 2.11.0

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to