1 %parse-param {struct list_head *expr_head}
2 %define parse.error verbose
12 #include <linux/compiler.h>
13 #include <linux/list.h>
14 #include "bpf-filter.h"
17 int perf_bpf_filter_lex(void);
19 /* To indicate if the current term needs a pathname or not */
20 int perf_bpf_filter_needs_path;
22 static void perf_bpf_filter_error(struct list_head *expr __maybe_unused,
25 printf("perf_bpf_filter: %s\n", msg);
35 enum perf_bpf_filter_term term;
38 enum perf_bpf_filter_op op;
39 struct perf_bpf_filter_expr *expr;
42 %token BFT_SAMPLE BFT_SAMPLE_PATH BFT_OP BFT_ERROR BFT_NUM BFT_LOGICAL_OR BFT_PATH
43 %type <expr> filter_term filter_expr
44 %destructor { free ($$); } <expr>
45 %type <sample> BFT_SAMPLE BFT_SAMPLE_PATH
53 filter ',' filter_term
55 list_add_tail(&$3->list, expr_head);
60 list_add_tail(&$1->list, expr_head);
64 filter_term BFT_LOGICAL_OR filter_expr
66 struct perf_bpf_filter_expr *expr;
68 if ($1->op == PBF_OP_GROUP_BEGIN) {
71 expr = perf_bpf_filter_expr__new(PBF_TERM_NONE, /*part=*/0,
72 PBF_OP_GROUP_BEGIN, /*val=*/1);
73 list_add_tail(&$1->list, &expr->groups);
76 list_add_tail(&$3->list, &expr->groups);
86 BFT_SAMPLE BFT_OP BFT_NUM
88 $$ = perf_bpf_filter_expr__new($1.term, $1.part, $2, $3);
91 BFT_SAMPLE_PATH BFT_OP BFT_PATH
94 unsigned long cgroup_id = 0;
96 if ($2 != PBF_OP_EQ && $2 != PBF_OP_NEQ) {
97 printf("perf_bpf_filter: cgroup accepts '==' or '!=' only\n");
101 cgrp = cgroup__new($3, /*do_open=*/false);
102 if (cgrp && read_cgroup_id(cgrp) == 0)
103 cgroup_id = cgrp->id;
105 $$ = perf_bpf_filter_expr__new($1.term, $1.part, $2, cgroup_id);