|
33 | 33 | "# Only events with the given fields will be affected.\n" \
|
34 | 34 | "# If no events are modified, an error message will be displayed here"
|
35 | 35 |
|
36 |
| -enum filter_op_ids |
37 |
| -{ |
38 |
| - OP_OR, |
39 |
| - OP_AND, |
40 |
| - OP_GLOB, |
41 |
| - OP_NE, |
42 |
| - OP_EQ, |
43 |
| - OP_LT, |
44 |
| - OP_LE, |
45 |
| - OP_GT, |
46 |
| - OP_GE, |
47 |
| - OP_BAND, |
48 |
| - OP_NOT, |
49 |
| - OP_NONE, |
50 |
| - OP_OPEN_PAREN, |
51 |
| -}; |
| 36 | +#define OPS \ |
| 37 | + C( OP_OR, "||", 1 ), \ |
| 38 | + C( OP_AND, "&&", 2 ), \ |
| 39 | + C( OP_GLOB, "~", 4 ), \ |
| 40 | + C( OP_NE, "!=", 4 ), \ |
| 41 | + C( OP_EQ, "==", 4 ), \ |
| 42 | + C( OP_LT, "<", 5 ), \ |
| 43 | + C( OP_LE, "<=", 5 ), \ |
| 44 | + C( OP_GT, ">", 5 ), \ |
| 45 | + C( OP_GE, ">=", 5 ), \ |
| 46 | + C( OP_BAND, "&", 6 ), \ |
| 47 | + C( OP_NOT, "!", 6 ), \ |
| 48 | + C( OP_NONE, "OP_NONE", 0 ), \ |
| 49 | + C( OP_OPEN_PAREN, "(", 0 ), \ |
| 50 | + C( OP_MAX, NULL, 0 ) |
| 51 | + |
| 52 | +#undef C |
| 53 | +#define C(a, b, c) a |
| 54 | + |
| 55 | +enum filter_op_ids { OPS }; |
52 | 56 |
|
53 | 57 | struct filter_op {
|
54 | 58 | int id;
|
55 | 59 | char *string;
|
56 | 60 | int precedence;
|
57 | 61 | };
|
58 | 62 |
|
59 |
| -/* Order must be the same as enum filter_op_ids above */ |
60 |
| -static struct filter_op filter_ops[] = { |
61 |
| - { OP_OR, "||", 1 }, |
62 |
| - { OP_AND, "&&", 2 }, |
63 |
| - { OP_GLOB, "~", 4 }, |
64 |
| - { OP_NE, "!=", 4 }, |
65 |
| - { OP_EQ, "==", 4 }, |
66 |
| - { OP_LT, "<", 5 }, |
67 |
| - { OP_LE, "<=", 5 }, |
68 |
| - { OP_GT, ">", 5 }, |
69 |
| - { OP_GE, ">=", 5 }, |
70 |
| - { OP_BAND, "&", 6 }, |
71 |
| - { OP_NOT, "!", 6 }, |
72 |
| - { OP_NONE, "OP_NONE", 0 }, |
73 |
| - { OP_OPEN_PAREN, "(", 0 }, |
74 |
| -}; |
| 63 | +#undef C |
| 64 | +#define C(a, b, c) { a, b, c } |
75 | 65 |
|
76 |
| -enum { |
77 |
| - FILT_ERR_NONE, |
78 |
| - FILT_ERR_INVALID_OP, |
79 |
| - FILT_ERR_UNBALANCED_PAREN, |
80 |
| - FILT_ERR_TOO_MANY_OPERANDS, |
81 |
| - FILT_ERR_OPERAND_TOO_LONG, |
82 |
| - FILT_ERR_FIELD_NOT_FOUND, |
83 |
| - FILT_ERR_ILLEGAL_FIELD_OP, |
84 |
| - FILT_ERR_ILLEGAL_INTVAL, |
85 |
| - FILT_ERR_BAD_SUBSYS_FILTER, |
86 |
| - FILT_ERR_TOO_MANY_PREDS, |
87 |
| - FILT_ERR_MISSING_FIELD, |
88 |
| - FILT_ERR_INVALID_FILTER, |
89 |
| - FILT_ERR_IP_FIELD_ONLY, |
90 |
| - FILT_ERR_ILLEGAL_NOT_OP, |
91 |
| -}; |
| 66 | +static struct filter_op filter_ops[] = { OPS }; |
92 | 67 |
|
93 |
| -static char *err_text[] = { |
94 |
| - "No error", |
95 |
| - "Invalid operator", |
96 |
| - "Unbalanced parens", |
97 |
| - "Too many operands", |
98 |
| - "Operand too long", |
99 |
| - "Field not found", |
100 |
| - "Illegal operation for field type", |
101 |
| - "Illegal integer value", |
102 |
| - "Couldn't find or set field in one of a subsystem's events", |
103 |
| - "Too many terms in predicate expression", |
104 |
| - "Missing field name and/or value", |
105 |
| - "Meaningless filter expression", |
106 |
| - "Only 'ip' field is supported for function trace", |
107 |
| - "Illegal use of '!'", |
108 |
| -}; |
| 68 | +#define ERRORS \ |
| 69 | + C( NONE, "No error"), \ |
| 70 | + C( INVALID_OP, "Invalid operator"), \ |
| 71 | + C( UNBALANCED_PAREN, "Unbalanced parens"), \ |
| 72 | + C( TOO_MANY_OPERANDS, "Too many operands"), \ |
| 73 | + C( OPERAND_TOO_LONG, "Operand too long"), \ |
| 74 | + C( FIELD_NOT_FOUND, "Field not found"), \ |
| 75 | + C( ILLEGAL_FIELD_OP, "Illegal operation for field type"), \ |
| 76 | + C( ILLEGAL_INTVAL, "Illegal integer value"), \ |
| 77 | + C( BAD_SUBSYS_FILTER, "Couldn't find or set field in one of a subsystem's events"), \ |
| 78 | + C( TOO_MANY_PREDS, "Too many terms in predicate expression"), \ |
| 79 | + C( MISSING_FIELD, "Missing field name and/or value"), \ |
| 80 | + C( INVALID_FILTER, "Meaningless filter expression"), \ |
| 81 | + C( IP_FIELD_ONLY, "Only 'ip' field is supported for function trace"), \ |
| 82 | + C( ILLEGAL_NOT_OP, "Illegal use of '!'"), |
| 83 | + |
| 84 | +#undef C |
| 85 | +#define C(a, b) FILT_ERR_##a |
| 86 | + |
| 87 | +enum { ERRORS }; |
| 88 | + |
| 89 | +#undef C |
| 90 | +#define C(a, b) b |
| 91 | + |
| 92 | +static char *err_text[] = { ERRORS }; |
109 | 93 |
|
110 | 94 | struct opstack_op {
|
111 | 95 | enum filter_op_ids op;
|
|
0 commit comments