blob: f6c0b74ea285c306dfc21cebf58ea5c5856041b5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
%option prefix="perf_bpf_filter_"
%option noyywrap
%{
#include <stdio.h>
#include <stdlib.h>
#include <linux/perf_event.h>
#include "bpf-filter.h"
#include "bpf-filter-bison.h"
static int sample(unsigned long sample_flag)
{
perf_bpf_filter_lval.sample = sample_flag;
return BFT_SAMPLE;
}
static int operator(enum perf_bpf_filter_op op)
{
perf_bpf_filter_lval.op = op;
return BFT_OP;
}
static int value(int base)
{
long num;
errno = 0;
num = strtoul(perf_bpf_filter_text, NULL, base);
if (errno)
return BFT_ERROR;
perf_bpf_filter_lval.num = num;
return BFT_NUM;
}
static int error(const char *str)
{
printf("perf_bpf_filter: Unexpected filter %s: %s\n", str, perf_bpf_filter_text);
return BFT_ERROR;
}
%}
num_dec [0-9]+
num_hex 0[Xx][0-9a-fA-F]+
space [ \t]+
ident [_a-zA-Z][_a-zA-Z0-9]+
%%
{num_dec} { return value(10); }
{num_hex} { return value(16); }
{space} { }
ip { return sample(PERF_SAMPLE_IP); }
id { return sample(PERF_SAMPLE_ID); }
tid { return sample(PERF_SAMPLE_TID); }
cpu { return sample(PERF_SAMPLE_CPU); }
time { return sample(PERF_SAMPLE_TIME); }
addr { return sample(PERF_SAMPLE_ADDR); }
period { return sample(PERF_SAMPLE_PERIOD); }
txn { return sample(PERF_SAMPLE_TRANSACTION); }
weight { return sample(PERF_SAMPLE_WEIGHT); }
phys_addr { return sample(PERF_SAMPLE_PHYS_ADDR); }
code_pgsz { return sample(PERF_SAMPLE_CODE_PAGE_SIZE); }
data_pgsz { return sample(PERF_SAMPLE_DATA_PAGE_SIZE); }
"==" { return operator(PBF_OP_EQ); }
"!=" { return operator(PBF_OP_NEQ); }
">" { return operator(PBF_OP_GT); }
"<" { return operator(PBF_OP_LT); }
">=" { return operator(PBF_OP_GE); }
"<=" { return operator(PBF_OP_LE); }
"&" { return operator(PBF_OP_AND); }
"," { return ','; }
{ident} { return error("ident"); }
. { return error("input"); }
%%
|