aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2012-06-15 02:31:38 -0400
committerIngo Molnar <mingo@kernel.org>2012-06-18 06:13:24 -0400
commit46010ab2607aed9484816a8f1679c2ec3c8e7dcf (patch)
tree1b54cb98c1744a5424a753123e05ac3b052dbb5b /tools/perf/util
parent7c94ee2e0917b2ea56498bff939c8aa55da27207 (diff)
perf/tool: Use data struct for arg passing in event parse function
Moving all the bison arguments into the structure. In upcomming patches we are going to: - add more arguments - reuse the grammer for term parsing so it's more clear to pack/separate related arguments. Signed-off-by: Jiri Olsa <jolsa@redhat.com> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1339741902-8449-10-git-send-email-zheng.z.yan@intel.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/perf/util')
-rw-r--r--tools/perf/util/parse-events.c16
-rw-r--r--tools/perf/util/parse-events.h8
-rw-r--r--tools/perf/util/parse-events.y52
3 files changed, 50 insertions, 26 deletions
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 05dbc8b3c767..c71b29ad26ec 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -26,7 +26,7 @@ struct event_symbol {
26#ifdef PARSER_DEBUG 26#ifdef PARSER_DEBUG
27extern int parse_events_debug; 27extern int parse_events_debug;
28#endif 28#endif
29int parse_events_parse(struct list_head *list, int *idx); 29int parse_events_parse(void *data);
30 30
31#define CHW(x) .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_##x 31#define CHW(x) .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_##x
32#define CSW(x) .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_##x 32#define CSW(x) .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_##x
@@ -789,25 +789,27 @@ int parse_events_modifier(struct list_head *list, char *str)
789 789
790int parse_events(struct perf_evlist *evlist, const char *str, int unset __used) 790int parse_events(struct perf_evlist *evlist, const char *str, int unset __used)
791{ 791{
792 LIST_HEAD(list); 792 struct parse_events_data__events data = {
793 LIST_HEAD(list_tmp); 793 .list = LIST_HEAD_INIT(data.list),
794 .idx = evlist->nr_entries,
795 };
794 YY_BUFFER_STATE buffer; 796 YY_BUFFER_STATE buffer;
795 int ret, idx = evlist->nr_entries; 797 int ret;
796 798
797 buffer = parse_events__scan_string(str); 799 buffer = parse_events__scan_string(str);
798 800
799#ifdef PARSER_DEBUG 801#ifdef PARSER_DEBUG
800 parse_events_debug = 1; 802 parse_events_debug = 1;
801#endif 803#endif
802 ret = parse_events_parse(&list, &idx); 804 ret = parse_events_parse(&data);
803 805
804 parse_events__flush_buffer(buffer); 806 parse_events__flush_buffer(buffer);
805 parse_events__delete_buffer(buffer); 807 parse_events__delete_buffer(buffer);
806 parse_events_lex_destroy(); 808 parse_events_lex_destroy();
807 809
808 if (!ret) { 810 if (!ret) {
809 int entries = idx - evlist->nr_entries; 811 int entries = data.idx - evlist->nr_entries;
810 perf_evlist__splice_list_tail(evlist, &list, entries); 812 perf_evlist__splice_list_tail(evlist, &data.list, entries);
811 return 0; 813 return 0;
812 } 814 }
813 815
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index 8cac57ab4ee6..dc3c83a0ab8a 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -63,6 +63,11 @@ struct parse_events__term {
63 struct list_head list; 63 struct list_head list;
64}; 64};
65 65
66struct parse_events_data__events {
67 struct list_head list;
68 int idx;
69};
70
66int parse_events__is_hardcoded_term(struct parse_events__term *term); 71int parse_events__is_hardcoded_term(struct parse_events__term *term);
67int parse_events__term_num(struct parse_events__term **_term, 72int parse_events__term_num(struct parse_events__term **_term,
68 int type_term, char *config, long num); 73 int type_term, char *config, long num);
@@ -83,8 +88,7 @@ int parse_events_add_pmu(struct list_head **list, int *idx,
83 char *pmu , struct list_head *head_config); 88 char *pmu , struct list_head *head_config);
84void parse_events_update_lists(struct list_head *list_event, 89void parse_events_update_lists(struct list_head *list_event,
85 struct list_head *list_all); 90 struct list_head *list_all);
86void parse_events_error(struct list_head *list_all, 91void parse_events_error(void *data, char const *msg);
87 int *idx, char const *msg);
88int parse_events__test(void); 92int parse_events__test(void);
89 93
90void print_events(const char *event_glob); 94void print_events(const char *event_glob);
diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
index 362cc59332ae..e533bf72ba9c 100644
--- a/tools/perf/util/parse-events.y
+++ b/tools/perf/util/parse-events.y
@@ -1,7 +1,6 @@
1 1
2%name-prefix "parse_events_" 2%name-prefix "parse_events_"
3%parse-param {struct list_head *list_all} 3%parse-param {void *_data}
4%parse-param {int *idx}
5 4
6%{ 5%{
7 6
@@ -64,18 +63,22 @@ events ',' event | event
64event: 63event:
65event_def PE_MODIFIER_EVENT 64event_def PE_MODIFIER_EVENT
66{ 65{
66 struct parse_events_data__events *data = _data;
67
67 /* 68 /*
68 * Apply modifier on all events added by single event definition 69 * Apply modifier on all events added by single event definition
69 * (there could be more events added for multiple tracepoint 70 * (there could be more events added for multiple tracepoint
70 * definitions via '*?'. 71 * definitions via '*?'.
71 */ 72 */
72 ABORT_ON(parse_events_modifier($1, $2)); 73 ABORT_ON(parse_events_modifier($1, $2));
73 parse_events_update_lists($1, list_all); 74 parse_events_update_lists($1, &data->list);
74} 75}
75| 76|
76event_def 77event_def
77{ 78{
78 parse_events_update_lists($1, list_all); 79 struct parse_events_data__events *data = _data;
80
81 parse_events_update_lists($1, &data->list);
79} 82}
80 83
81event_def: event_pmu | 84event_def: event_pmu |
@@ -89,9 +92,10 @@ event_def: event_pmu |
89event_pmu: 92event_pmu:
90PE_NAME '/' event_config '/' 93PE_NAME '/' event_config '/'
91{ 94{
95 struct parse_events_data__events *data = _data;
92 struct list_head *list = NULL; 96 struct list_head *list = NULL;
93 97
94 ABORT_ON(parse_events_add_pmu(&list, idx, $1, $3)); 98 ABORT_ON(parse_events_add_pmu(&list, &data->idx, $1, $3));
95 parse_events__free_terms($3); 99 parse_events__free_terms($3);
96 $$ = list; 100 $$ = list;
97} 101}
@@ -99,91 +103,106 @@ PE_NAME '/' event_config '/'
99event_legacy_symbol: 103event_legacy_symbol:
100PE_VALUE_SYM '/' event_config '/' 104PE_VALUE_SYM '/' event_config '/'
101{ 105{
106 struct parse_events_data__events *data = _data;
102 struct list_head *list = NULL; 107 struct list_head *list = NULL;
103 int type = $1 >> 16; 108 int type = $1 >> 16;
104 int config = $1 & 255; 109 int config = $1 & 255;
105 110
106 ABORT_ON(parse_events_add_numeric(&list, idx, type, config, $3)); 111 ABORT_ON(parse_events_add_numeric(&list, &data->idx,
112 type, config, $3));
107 parse_events__free_terms($3); 113 parse_events__free_terms($3);
108 $$ = list; 114 $$ = list;
109} 115}
110| 116|
111PE_VALUE_SYM sep_slash_dc 117PE_VALUE_SYM sep_slash_dc
112{ 118{
119 struct parse_events_data__events *data = _data;
113 struct list_head *list = NULL; 120 struct list_head *list = NULL;
114 int type = $1 >> 16; 121 int type = $1 >> 16;
115 int config = $1 & 255; 122 int config = $1 & 255;
116 123
117 ABORT_ON(parse_events_add_numeric(&list, idx, type, config, NULL)); 124 ABORT_ON(parse_events_add_numeric(&list, &data->idx,
125 type, config, NULL));
118 $$ = list; 126 $$ = list;
119} 127}
120 128
121event_legacy_cache: 129event_legacy_cache:
122PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT 130PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT
123{ 131{
132 struct parse_events_data__events *data = _data;
124 struct list_head *list = NULL; 133 struct list_head *list = NULL;
125 134
126 ABORT_ON(parse_events_add_cache(&list, idx, $1, $3, $5)); 135 ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, $3, $5));
127 $$ = list; 136 $$ = list;
128} 137}
129| 138|
130PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT 139PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT
131{ 140{
141 struct parse_events_data__events *data = _data;
132 struct list_head *list = NULL; 142 struct list_head *list = NULL;
133 143
134 ABORT_ON(parse_events_add_cache(&list, idx, $1, $3, NULL)); 144 ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, $3, NULL));
135 $$ = list; 145 $$ = list;
136} 146}
137| 147|
138PE_NAME_CACHE_TYPE 148PE_NAME_CACHE_TYPE
139{ 149{
150 struct parse_events_data__events *data = _data;
140 struct list_head *list = NULL; 151 struct list_head *list = NULL;
141 152
142 ABORT_ON(parse_events_add_cache(&list, idx, $1, NULL, NULL)); 153 ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, NULL, NULL));
143 $$ = list; 154 $$ = list;
144} 155}
145 156
146event_legacy_mem: 157event_legacy_mem:
147PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc 158PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
148{ 159{
160 struct parse_events_data__events *data = _data;
149 struct list_head *list = NULL; 161 struct list_head *list = NULL;
150 162
151 ABORT_ON(parse_events_add_breakpoint(&list, idx, (void *) $2, $4)); 163 ABORT_ON(parse_events_add_breakpoint(&list, &data->idx,
164 (void *) $2, $4));
152 $$ = list; 165 $$ = list;
153} 166}
154| 167|
155PE_PREFIX_MEM PE_VALUE sep_dc 168PE_PREFIX_MEM PE_VALUE sep_dc
156{ 169{
170 struct parse_events_data__events *data = _data;
157 struct list_head *list = NULL; 171 struct list_head *list = NULL;
158 172
159 ABORT_ON(parse_events_add_breakpoint(&list, idx, (void *) $2, NULL)); 173 ABORT_ON(parse_events_add_breakpoint(&list, &data->idx,
174 (void *) $2, NULL));
160 $$ = list; 175 $$ = list;
161} 176}
162 177
163event_legacy_tracepoint: 178event_legacy_tracepoint:
164PE_NAME ':' PE_NAME 179PE_NAME ':' PE_NAME
165{ 180{
181 struct parse_events_data__events *data = _data;
166 struct list_head *list = NULL; 182 struct list_head *list = NULL;
167 183
168 ABORT_ON(parse_events_add_tracepoint(&list, idx, $1, $3)); 184 ABORT_ON(parse_events_add_tracepoint(&list, &data->idx, $1, $3));
169 $$ = list; 185 $$ = list;
170} 186}
171 187
172event_legacy_numeric: 188event_legacy_numeric:
173PE_VALUE ':' PE_VALUE 189PE_VALUE ':' PE_VALUE
174{ 190{
191 struct parse_events_data__events *data = _data;
175 struct list_head *list = NULL; 192 struct list_head *list = NULL;
176 193
177 ABORT_ON(parse_events_add_numeric(&list, idx, $1, $3, NULL)); 194 ABORT_ON(parse_events_add_numeric(&list, &data->idx, $1, $3, NULL));
178 $$ = list; 195 $$ = list;
179} 196}
180 197
181event_legacy_raw: 198event_legacy_raw:
182PE_RAW 199PE_RAW
183{ 200{
201 struct parse_events_data__events *data = _data;
184 struct list_head *list = NULL; 202 struct list_head *list = NULL;
185 203
186 ABORT_ON(parse_events_add_numeric(&list, idx, PERF_TYPE_RAW, $1, NULL)); 204 ABORT_ON(parse_events_add_numeric(&list, &data->idx,
205 PERF_TYPE_RAW, $1, NULL));
187 $$ = list; 206 $$ = list;
188} 207}
189 208
@@ -267,8 +286,7 @@ sep_slash_dc: '/' | ':' |
267 286
268%% 287%%
269 288
270void parse_events_error(struct list_head *list_all __used, 289void parse_events_error(void *data __used,
271 int *idx __used,
272 char const *msg __used) 290 char const *msg __used)
273{ 291{
274} 292}