Lines Matching full:term

10 #include "term.h"
158 struct parse_events_term *term; in get_config_str() local
163 list_for_each_entry(term, head_terms, list) in get_config_str()
164 if (term->type_term == type_term) in get_config_str()
165 return term->val.str; in get_config_str()
181 * fix_raw - For each raw term see if there is an event (aka alias) in pmu that
183 * event then change the term to be an event, if not then change it to
184 * be a config term. For example, "read" may be an event of the PMU or
188 * @config_terms: the list of terms that may contain a raw term.
193 struct parse_events_term *term; in fix_raw() local
195 list_for_each_entry(term, config_terms, list) { in fix_raw()
198 if (term->type_term != PARSE_EVENTS__TERM_TYPE_RAW) in fix_raw()
201 if (perf_pmu__have_event(pmu, term->val.str)) { in fix_raw()
202 zfree(&term->config); in fix_raw()
203 term->config = term->val.str; in fix_raw()
204 term->type_val = PARSE_EVENTS__TERM_TYPE_NUM; in fix_raw()
205 term->type_term = PARSE_EVENTS__TERM_TYPE_USER; in fix_raw()
206 term->val.num = 1; in fix_raw()
207 term->no_value = true; in fix_raw()
211 zfree(&term->config); in fix_raw()
212 term->config = strdup("config"); in fix_raw()
214 num = strtoull(term->val.str + 1, NULL, 16); in fix_raw()
216 free(term->val.str); in fix_raw()
217 term->type_val = PARSE_EVENTS__TERM_TYPE_NUM; in fix_raw()
218 term->type_term = PARSE_EVENTS__TERM_TYPE_CONFIG; in fix_raw()
219 term->val.num = num; in fix_raw()
220 term->no_value = false; in fix_raw()
353 struct parse_events_term *term,
356 struct parse_events_term *term,
723 static int check_type_val(struct parse_events_term *term, in check_type_val() argument
727 if (type == term->type_val) in check_type_val()
731 parse_events_error__handle(err, term->err_val, in check_type_val()
748 [PARSE_EVENTS__TERM_TYPE_USER] = "<sysfs term>", in config_term_name()
776 return "unknown term"; in config_term_name()
840 struct parse_events_term *term, in config_term_common() argument
845 if (check_type_val(term, err, PARSE_EVENTS__TERM_TYPE_ ## type)) \ in config_term_common()
849 switch (term->type_term) { in config_term_common()
852 attr->config = term->val.num; in config_term_common()
856 attr->config1 = term->val.num; in config_term_common()
860 attr->config2 = term->val.num; in config_term_common()
864 attr->config3 = term->val.num; in config_term_common()
874 if (strcmp(term->val.str, "no") && in config_term_common()
875 parse_branch_str(term->val.str, in config_term_common()
877 parse_events_error__handle(err, term->err_val, in config_term_common()
885 if (term->val.num > 1) { in config_term_common()
886 parse_events_error__handle(err, term->err_val, in config_term_common()
927 if ((unsigned int)term->val.num > 1) { in config_term_common()
928 parse_events_error__handle(err, term->err_val, in config_term_common()
939 if (term->val.num > UINT_MAX) { in config_term_common()
940 parse_events_error__handle(err, term->err_val, in config_term_common()
951 parse_events_error__handle(err, term->err_term, in config_term_common()
952 strdup(config_term_name(term->type_term)), in config_term_common()
958 * Check term availability after basic checking so in config_term_common()
962 * user will see "'<sysfs term>' is not usable in 'perf stat'" in config_term_common()
963 * if an invalid config term is provided for legacy events in config_term_common()
966 if (!config_term_avail(term->type_term, err)) in config_term_common()
973 struct parse_events_term *term, in config_term_pmu() argument
976 if (term->type_term == PARSE_EVENTS__TERM_TYPE_LEGACY_CACHE) { in config_term_pmu()
983 parse_events_error__handle(err, term->err_term, in config_term_pmu()
989 return parse_events__decode_legacy_cache(term->config, pmu->type, in config_term_pmu()
992 term->type_term = PARSE_EVENTS__TERM_TYPE_USER; in config_term_pmu()
994 if (term->type_term == PARSE_EVENTS__TERM_TYPE_HARDWARE) { in config_term_pmu()
1001 parse_events_error__handle(err, term->err_term, in config_term_pmu()
1006 attr->config = term->val.num; in config_term_pmu()
1011 if (term->type_term == PARSE_EVENTS__TERM_TYPE_USER || in config_term_pmu()
1012 term->type_term == PARSE_EVENTS__TERM_TYPE_DRV_CFG) { in config_term_pmu()
1019 return config_term_common(attr, term, err); in config_term_pmu()
1024 struct parse_events_term *term, in config_term_tracepoint() argument
1027 switch (term->type_term) { in config_term_tracepoint()
1038 return config_term_common(attr, term, err); in config_term_tracepoint()
1057 parse_events_error__handle(err, term->err_term, in config_term_tracepoint()
1058 strdup(config_term_name(term->type_term)), in config_term_tracepoint()
1073 struct parse_events_term *term; in config_attr() local
1075 list_for_each_entry(term, head, list) in config_attr()
1076 if (config_term(attr, term, err)) in config_attr()
1114 struct parse_events_term *term; in get_config_terms() local
1116 list_for_each_entry(term, head_config, list) { in get_config_terms()
1117 switch (term->type_term) { in get_config_terms()
1119 ADD_CONFIG_TERM_VAL(PERIOD, period, term->val.num, term->weak); in get_config_terms()
1122 ADD_CONFIG_TERM_VAL(FREQ, freq, term->val.num, term->weak); in get_config_terms()
1125 ADD_CONFIG_TERM_VAL(TIME, time, term->val.num, term->weak); in get_config_terms()
1128 ADD_CONFIG_TERM_STR(CALLGRAPH, term->val.str, term->weak); in get_config_terms()
1131 ADD_CONFIG_TERM_STR(BRANCH, term->val.str, term->weak); in get_config_terms()
1135 term->val.num, term->weak); in get_config_terms()
1139 term->val.num ? 1 : 0, term->weak); in get_config_terms()
1143 term->val.num ? 0 : 1, term->weak); in get_config_terms()
1147 term->val.num, term->weak); in get_config_terms()
1151 term->val.num, term->weak); in get_config_terms()
1155 term->val.num ? 1 : 0, term->weak); in get_config_terms()
1159 term->val.num ? 0 : 1, term->weak); in get_config_terms()
1162 ADD_CONFIG_TERM_STR(DRV_CFG, term->val.str, term->weak); in get_config_terms()
1166 term->val.num ? true : false, term->weak); in get_config_terms()
1170 term->val.num ? 1 : 0, term->weak); in get_config_terms()
1174 term->val.num, term->weak); in get_config_terms()
1200 struct parse_events_term *term; in get_config_chgs() local
1204 list_for_each_entry(term, head_config, list) { in get_config_chgs()
1205 switch (term->type_term) { in get_config_chgs()
1207 type = perf_pmu__format_type(pmu, term->config); in get_config_chgs()
1210 bits |= perf_pmu__format_bits(pmu, term->config); in get_config_chgs()
1360 struct evsel_config_term *term; in config_term_percore() local
1362 list_for_each_entry(term, config_terms, list) { in config_term_percore()
1363 if (term->type == EVSEL__CONFIG_TERM_PERCORE) in config_term_percore()
1364 return term->val.percore; in config_term_percore()
1490 struct parse_events_term *term; in parse_events_multi_pmu_add() local
1511 if (parse_events_term__num(&term, in parse_events_multi_pmu_add()
1518 list_add_tail(&term->list, head); in parse_events_multi_pmu_add()
2432 int parse_events__is_hardcoded_term(struct parse_events_term *term) in parse_events__is_hardcoded_term() argument
2434 return term->type_term != PARSE_EVENTS__TERM_TYPE_USER; in parse_events__is_hardcoded_term()
2441 struct parse_events_term *term; in new_term() local
2443 term = malloc(sizeof(*term)); in new_term()
2444 if (!term) in new_term()
2447 *term = *temp; in new_term()
2448 INIT_LIST_HEAD(&term->list); in new_term()
2449 term->weak = false; in new_term()
2451 switch (term->type_val) { in new_term()
2453 term->val.num = num; in new_term()
2456 term->val.str = str; in new_term()
2459 free(term); in new_term()
2463 *_term = term; in new_term()
2467 int parse_events_term__num(struct parse_events_term **term, in parse_events_term__num() argument
2485 return new_term(term, &temp, /*str=*/NULL, num); in parse_events_term__num()
2488 int parse_events_term__str(struct parse_events_term **term, in parse_events_term__str() argument
2504 return new_term(term, &temp, str, /*num=*/0); in parse_events_term__str()
2507 int parse_events_term__term(struct parse_events_term **term, in parse_events_term__term() argument
2512 return parse_events_term__str(term, term_lhs, NULL, in parse_events_term__term()
2518 struct parse_events_term *term) in parse_events_term__clone() argument
2521 struct parse_events_term temp = *term; in parse_events_term__clone()
2524 if (term->config) { in parse_events_term__clone()
2525 temp.config = strdup(term->config); in parse_events_term__clone()
2529 if (term->type_val == PARSE_EVENTS__TERM_TYPE_NUM) in parse_events_term__clone()
2530 return new_term(new, &temp, /*str=*/NULL, term->val.num); in parse_events_term__clone()
2532 str = strdup(term->val.str); in parse_events_term__clone()
2538 void parse_events_term__delete(struct parse_events_term *term) in parse_events_term__delete() argument
2540 if (term->type_val != PARSE_EVENTS__TERM_TYPE_NUM) in parse_events_term__delete()
2541 zfree(&term->val.str); in parse_events_term__delete()
2543 zfree(&term->config); in parse_events_term__delete()
2544 free(term); in parse_events_term__delete()
2550 struct parse_events_term *term, *n; in parse_events_copy_term_list() local
2563 list_for_each_entry (term, old, list) { in parse_events_copy_term_list()
2564 ret = parse_events_term__clone(&n, term); in parse_events_copy_term_list()
2574 struct parse_events_term *term, *h; in parse_events_terms__purge() local
2576 list_for_each_entry_safe(term, h, terms, list) { in parse_events_terms__purge()
2577 list_del_init(&term->list); in parse_events_terms__purge()
2578 parse_events_term__delete(term); in parse_events_terms__purge()
2592 struct parse_events_term *term; in parse_events_term__to_strbuf() local
2598 list_for_each_entry(term, term_list, list) { in parse_events_term__to_strbuf()
2608 if (term->type_val == PARSE_EVENTS__TERM_TYPE_NUM) in parse_events_term__to_strbuf()
2609 if (term->no_value) { in parse_events_term__to_strbuf()
2610 assert(term->val.num == 1); in parse_events_term__to_strbuf()
2611 ret = strbuf_addf(sb, "%s", term->config); in parse_events_term__to_strbuf()
2613 ret = strbuf_addf(sb, "%s=%#"PRIx64, term->config, term->val.num); in parse_events_term__to_strbuf()
2614 else if (term->type_val == PARSE_EVENTS__TERM_TYPE_STR) { in parse_events_term__to_strbuf()
2615 if (term->config) { in parse_events_term__to_strbuf()
2616 ret = strbuf_addf(sb, "%s=", term->config); in parse_events_term__to_strbuf()
2619 } else if ((unsigned int)term->type_term < __PARSE_EVENTS__TERM_TYPE_NR) { in parse_events_term__to_strbuf()
2620 ret = strbuf_addf(sb, "%s=", config_term_name(term->type_term)); in parse_events_term__to_strbuf()
2624 assert(!term->no_value); in parse_events_term__to_strbuf()
2625 ret = strbuf_addf(sb, "%s", term->val.str); in parse_events_term__to_strbuf()