[PATCH v10 01/16] Introduce new filtering architecture

Dmitry V. Levin ldv at altlinux.org
Mon Aug 28 17:47:27 UTC 2017


On Mon, Aug 28, 2017 at 03:54:38PM +0700, Nikolay Marchuk wrote:
> This change introduces new filtering architecture primitives: filter,
> filter_action and bool_expression. Filtering is now done after decoding of
> syscall and tcp->qual_flg stores filtering results.
> 
> * basic_actions.c: New file.
> * filter_action.c: Likewise.
> * filter_expression.c: Likewise.
> * filter.c: Likewise.
> * basic_filters.c (parse_syscall_filter, run_syscall_filter,
> free_syscall_filter): New functions.
> * defs.h (filter_syscall, filtering_parsing_finish): Add new declarations.
> * filter.h: Add new declarations.
> * filter_qualify.c (abbrev_set, raw_set, trace_set, verbose_set):
> Remove set variables.
> (qualify_trace, qualify_abbrev, qualify_verbose, qualify_raw):
> Use new filtering API.
> (qual_flags): Remove QUAL_* flags for trace, abbrev, verbose, raw.
> * strace.c (init): Call filtering_parse_finish after command line parsing.
> (trace_syscall): Add filtering after syscall decoding.
> * Makefile.am (strace_SOURCES): Add new files.
[...]
> --- a/defs.h
> +++ b/defs.h
> @@ -648,6 +648,8 @@ extern void print_ifindex(unsigned int);
>  
>  extern void qualify(const char *);
>  extern unsigned int qual_flags(const unsigned int);
> +extern void filtering_parsing_finish(void);

What an unusual name for a function.  What's this function expected to do?

[...]
> +void
> +set_filters_qualify_mode(struct filter **filters, unsigned int *nfilters,
> +			 unsigned int filters_left)

As *filters and nfilters are tightly coupled,
I'd recommend creating a type that would hold both
"struct filter *filters" and "unsigned int nfilters",
and pass a pointer to this type instead of two pointers.

This set_filters_qualify_mode looks like a generic function,
what does it have to do with qualify mode?

> +{
> +	unsigned int i;
> +
> +	for (i = 0; i < *nfilters - filters_left; ++i)
> +		free_filter(*filters + i);
> +	for (i = 0; i < filters_left; ++i)
> +		(*filters)[i] = (*filters)[*nfilters - filters_left + i];

memmove?


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20170828/a37ba6ce/attachment.bin>


More information about the Strace-devel mailing list