Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame^] | 1 | |
| 2 | %name-prefix "parse_events_" |
| 3 | %parse-param {struct list_head *list} |
| 4 | %parse-param {int *idx} |
| 5 | |
| 6 | %{ |
| 7 | |
| 8 | #define YYDEBUG 1 |
| 9 | |
| 10 | #include <linux/compiler.h> |
| 11 | #include <linux/list.h> |
| 12 | #include "types.h" |
| 13 | #include "util.h" |
| 14 | #include "parse-events.h" |
| 15 | |
| 16 | extern int parse_events_lex (void); |
| 17 | |
| 18 | #define ABORT_ON(val) \ |
| 19 | do { \ |
| 20 | if (val) \ |
| 21 | YYABORT; \ |
| 22 | } while (0) |
| 23 | |
| 24 | %} |
| 25 | |
| 26 | %token PE_VALUE PE_VALUE_SYM PE_RAW |
| 27 | %token PE_NAME |
| 28 | %token PE_MODIFIER_EVENT PE_MODIFIER_BP |
| 29 | %token PE_NAME_CACHE_TYPE PE_NAME_CACHE_OP_RESULT |
| 30 | %token PE_PREFIX_MEM PE_PREFIX_RAW |
| 31 | %token PE_ERROR |
| 32 | %type <num> PE_VALUE |
| 33 | %type <num> PE_VALUE_SYM |
| 34 | %type <num> PE_RAW |
| 35 | %type <str> PE_NAME |
| 36 | %type <str> PE_NAME_CACHE_TYPE |
| 37 | %type <str> PE_NAME_CACHE_OP_RESULT |
| 38 | %type <str> PE_MODIFIER_EVENT |
| 39 | %type <str> PE_MODIFIER_BP |
| 40 | |
| 41 | %union |
| 42 | { |
| 43 | char *str; |
| 44 | unsigned long num; |
| 45 | } |
| 46 | %% |
| 47 | |
| 48 | events: |
| 49 | events ',' event | event |
| 50 | |
| 51 | event: |
| 52 | event_def PE_MODIFIER_EVENT |
| 53 | { |
| 54 | ABORT_ON(parse_events_modifier(list, $2)); |
| 55 | } |
| 56 | | |
| 57 | event_def |
| 58 | |
| 59 | event_def: event_legacy_symbol sep_dc | |
| 60 | event_legacy_cache sep_dc | |
| 61 | event_legacy_mem | |
| 62 | event_legacy_tracepoint sep_dc | |
| 63 | event_legacy_numeric sep_dc | |
| 64 | event_legacy_raw sep_dc |
| 65 | |
| 66 | event_legacy_symbol: |
| 67 | PE_VALUE_SYM |
| 68 | { |
| 69 | int type = $1 >> 16; |
| 70 | int config = $1 & 255; |
| 71 | |
| 72 | ABORT_ON(parse_events_add_numeric(list, idx, type, config)); |
| 73 | } |
| 74 | |
| 75 | event_legacy_cache: |
| 76 | PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT |
| 77 | { |
| 78 | ABORT_ON(parse_events_add_cache(list, idx, $1, $3, $5)); |
| 79 | } |
| 80 | | |
| 81 | PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT |
| 82 | { |
| 83 | ABORT_ON(parse_events_add_cache(list, idx, $1, $3, NULL)); |
| 84 | } |
| 85 | | |
| 86 | PE_NAME_CACHE_TYPE |
| 87 | { |
| 88 | ABORT_ON(parse_events_add_cache(list, idx, $1, NULL, NULL)); |
| 89 | } |
| 90 | |
| 91 | event_legacy_mem: |
| 92 | PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc |
| 93 | { |
| 94 | ABORT_ON(parse_events_add_breakpoint(list, idx, (void *) $2, $4)); |
| 95 | } |
| 96 | | |
| 97 | PE_PREFIX_MEM PE_VALUE sep_dc |
| 98 | { |
| 99 | ABORT_ON(parse_events_add_breakpoint(list, idx, (void *) $2, NULL)); |
| 100 | } |
| 101 | |
| 102 | event_legacy_tracepoint: |
| 103 | PE_NAME ':' PE_NAME |
| 104 | { |
| 105 | ABORT_ON(parse_events_add_tracepoint(list, idx, $1, $3)); |
| 106 | } |
| 107 | |
| 108 | event_legacy_numeric: |
| 109 | PE_VALUE ':' PE_VALUE |
| 110 | { |
| 111 | ABORT_ON(parse_events_add_numeric(list, idx, $1, $3)); |
| 112 | } |
| 113 | |
| 114 | event_legacy_raw: |
| 115 | PE_RAW |
| 116 | { |
| 117 | ABORT_ON(parse_events_add_numeric(list, idx, PERF_TYPE_RAW, $1)); |
| 118 | } |
| 119 | |
| 120 | sep_dc: ':' | |
| 121 | |
| 122 | %% |
| 123 | |
| 124 | void parse_events_error(struct list_head *list __used, int *idx __used, |
| 125 | char const *msg __used) |
| 126 | { |
| 127 | } |