Lines Matching full:term

10 #include "term.h"
159 struct parse_events_term *term; in get_config_str() local
164 list_for_each_entry(term, &head_terms->terms, list) in get_config_str()
165 if (term->type_term == type_term) in get_config_str()
166 return term->val.str; in get_config_str()
182 * fix_raw - For each raw term see if there is an event (aka alias) in pmu that
184 * event then change the term to be an event, if not then change it to
185 * be a config term. For example, "read" may be an event of the PMU or
189 * @config_terms: the list of terms that may contain a raw term.
194 struct parse_events_term *term; in fix_raw() local
196 list_for_each_entry(term, &config_terms->terms, list) { in fix_raw()
199 if (term->type_term != PARSE_EVENTS__TERM_TYPE_RAW) in fix_raw()
202 if (perf_pmu__have_event(pmu, term->val.str)) { in fix_raw()
203 zfree(&term->config); in fix_raw()
204 term->config = term->val.str; in fix_raw()
205 term->type_val = PARSE_EVENTS__TERM_TYPE_NUM; in fix_raw()
206 term->type_term = PARSE_EVENTS__TERM_TYPE_USER; in fix_raw()
207 term->val.num = 1; in fix_raw()
208 term->no_value = true; in fix_raw()
212 zfree(&term->config); in fix_raw()
213 term->config = strdup("config"); in fix_raw()
215 num = strtoull(term->val.str + 1, NULL, 16); in fix_raw()
217 free(term->val.str); in fix_raw()
218 term->type_val = PARSE_EVENTS__TERM_TYPE_NUM; in fix_raw()
219 term->type_term = PARSE_EVENTS__TERM_TYPE_CONFIG; in fix_raw()
220 term->val.num = num; in fix_raw()
221 term->no_value = false; in fix_raw()
360 struct parse_events_term *term,
363 struct parse_events_term *term,
778 static int check_type_val(struct parse_events_term *term, in check_type_val() argument
782 if (type == term->type_val) in check_type_val()
786 parse_events_error__handle(err, term->err_val, in check_type_val()
803 [PARSE_EVENTS__TERM_TYPE_USER] = "<sysfs term>", in config_term_name()
831 return "unknown term"; in config_term_name()
895 struct parse_events_term *term, in config_term_common() argument
900 if (check_type_val(term, err, PARSE_EVENTS__TERM_TYPE_ ## type)) \ in config_term_common()
904 switch (term->type_term) { in config_term_common()
907 attr->config = term->val.num; in config_term_common()
911 attr->config1 = term->val.num; in config_term_common()
915 attr->config2 = term->val.num; in config_term_common()
919 attr->config3 = term->val.num; in config_term_common()
929 if (strcmp(term->val.str, "no") && in config_term_common()
930 parse_branch_str(term->val.str, in config_term_common()
932 parse_events_error__handle(err, term->err_val, in config_term_common()
940 if (term->val.num > 1) { in config_term_common()
941 parse_events_error__handle(err, term->err_val, in config_term_common()
982 if ((unsigned int)term->val.num > 1) { in config_term_common()
983 parse_events_error__handle(err, term->err_val, in config_term_common()
994 if (term->val.num > UINT_MAX) { in config_term_common()
995 parse_events_error__handle(err, term->err_val, in config_term_common()
1006 parse_events_error__handle(err, term->err_term, in config_term_common()
1007 strdup(config_term_name(term->type_term)), in config_term_common()
1013 * Check term availability after basic checking so in config_term_common()
1017 * user will see "'<sysfs term>' is not usable in 'perf stat'" in config_term_common()
1018 * if an invalid config term is provided for legacy events in config_term_common()
1021 if (!config_term_avail(term->type_term, err)) in config_term_common()
1028 struct parse_events_term *term, in config_term_pmu() argument
1031 if (term->type_term == PARSE_EVENTS__TERM_TYPE_LEGACY_CACHE) { in config_term_pmu()
1038 parse_events_error__handle(err, term->err_term, in config_term_pmu()
1048 !perf_pmu__have_event(pmu, term->config)) { in config_term_pmu()
1050 return parse_events__decode_legacy_cache(term->config, pmu->type, in config_term_pmu()
1053 term->type_term = PARSE_EVENTS__TERM_TYPE_USER; in config_term_pmu()
1054 term->no_value = true; in config_term_pmu()
1057 if (term->type_term == PARSE_EVENTS__TERM_TYPE_HARDWARE) { in config_term_pmu()
1064 parse_events_error__handle(err, term->err_term, in config_term_pmu()
1072 if (perf_pmu__have_event(pmu, term->config)) { in config_term_pmu()
1073 term->type_term = PARSE_EVENTS__TERM_TYPE_USER; in config_term_pmu()
1074 term->no_value = true; in config_term_pmu()
1077 attr->config = term->val.num; in config_term_pmu()
1083 if (term->type_term == PARSE_EVENTS__TERM_TYPE_USER || in config_term_pmu()
1084 term->type_term == PARSE_EVENTS__TERM_TYPE_DRV_CFG) { in config_term_pmu()
1091 return config_term_common(attr, term, err); in config_term_pmu()
1096 struct parse_events_term *term, in config_term_tracepoint() argument
1099 switch (term->type_term) { in config_term_tracepoint()
1110 return config_term_common(attr, term, err); in config_term_tracepoint()
1129 parse_events_error__handle(err, term->err_term, in config_term_tracepoint()
1130 strdup(config_term_name(term->type_term)), in config_term_tracepoint()
1145 struct parse_events_term *term; in config_attr() local
1147 list_for_each_entry(term, &head->terms, list) in config_attr()
1148 if (config_term(attr, term, err)) in config_attr()
1186 struct parse_events_term *term; in get_config_terms() local
1188 list_for_each_entry(term, &head_config->terms, list) { in get_config_terms()
1189 switch (term->type_term) { in get_config_terms()
1191 ADD_CONFIG_TERM_VAL(PERIOD, period, term->val.num, term->weak); in get_config_terms()
1194 ADD_CONFIG_TERM_VAL(FREQ, freq, term->val.num, term->weak); in get_config_terms()
1197 ADD_CONFIG_TERM_VAL(TIME, time, term->val.num, term->weak); in get_config_terms()
1200 ADD_CONFIG_TERM_STR(CALLGRAPH, term->val.str, term->weak); in get_config_terms()
1203 ADD_CONFIG_TERM_STR(BRANCH, term->val.str, term->weak); in get_config_terms()
1207 term->val.num, term->weak); in get_config_terms()
1211 term->val.num ? 1 : 0, term->weak); in get_config_terms()
1215 term->val.num ? 0 : 1, term->weak); in get_config_terms()
1219 term->val.num, term->weak); in get_config_terms()
1223 term->val.num, term->weak); in get_config_terms()
1227 term->val.num ? 1 : 0, term->weak); in get_config_terms()
1231 term->val.num ? 0 : 1, term->weak); in get_config_terms()
1234 ADD_CONFIG_TERM_STR(DRV_CFG, term->val.str, term->weak); in get_config_terms()
1238 term->val.num ? true : false, term->weak); in get_config_terms()
1242 term->val.num ? 1 : 0, term->weak); in get_config_terms()
1246 term->val.num, term->weak); in get_config_terms()
1272 struct parse_events_term *term; in get_config_chgs() local
1276 list_for_each_entry(term, &head_config->terms, list) { in get_config_chgs()
1277 switch (term->type_term) { in get_config_chgs()
1279 type = perf_pmu__format_type(pmu, term->config); in get_config_chgs()
1282 bits |= perf_pmu__format_bits(pmu, term->config); in get_config_chgs()
1433 struct evsel_config_term *term; in config_term_percore() local
1435 list_for_each_entry(term, config_terms, list) { in config_term_percore()
1436 if (term->type == EVSEL__CONFIG_TERM_PERCORE) in config_term_percore()
1437 return term->val.percore; in config_term_percore()
1574 struct parse_events_term *term; in parse_events_multi_pmu_add() local
1596 if (parse_events_term__num(&term, in parse_events_multi_pmu_add()
1603 list_add_tail(&term->list, &parsed_terms.terms); in parse_events_multi_pmu_add()
2522 int parse_events__is_hardcoded_term(struct parse_events_term *term) in parse_events__is_hardcoded_term() argument
2524 return term->type_term != PARSE_EVENTS__TERM_TYPE_USER; in parse_events__is_hardcoded_term()
2531 struct parse_events_term *term; in new_term() local
2533 term = malloc(sizeof(*term)); in new_term()
2534 if (!term) in new_term()
2537 *term = *temp; in new_term()
2538 INIT_LIST_HEAD(&term->list); in new_term()
2539 term->weak = false; in new_term()
2541 switch (term->type_val) { in new_term()
2543 term->val.num = num; in new_term()
2546 term->val.str = str; in new_term()
2549 free(term); in new_term()
2553 *_term = term; in new_term()
2557 int parse_events_term__num(struct parse_events_term **term, in parse_events_term__num() argument
2575 return new_term(term, &temp, /*str=*/NULL, num); in parse_events_term__num()
2578 int parse_events_term__str(struct parse_events_term **term, in parse_events_term__str() argument
2594 return new_term(term, &temp, str, /*num=*/0); in parse_events_term__str()
2597 int parse_events_term__term(struct parse_events_term **term, in parse_events_term__term() argument
2602 return parse_events_term__str(term, term_lhs, NULL, in parse_events_term__term()
2608 const struct parse_events_term *term) in parse_events_term__clone() argument
2611 struct parse_events_term temp = *term; in parse_events_term__clone()
2614 if (term->config) { in parse_events_term__clone()
2615 temp.config = strdup(term->config); in parse_events_term__clone()
2619 if (term->type_val == PARSE_EVENTS__TERM_TYPE_NUM) in parse_events_term__clone()
2620 return new_term(new, &temp, /*str=*/NULL, term->val.num); in parse_events_term__clone()
2622 str = strdup(term->val.str); in parse_events_term__clone()
2630 void parse_events_term__delete(struct parse_events_term *term) in parse_events_term__delete() argument
2632 if (term->type_val != PARSE_EVENTS__TERM_TYPE_NUM) in parse_events_term__delete()
2633 zfree(&term->val.str); in parse_events_term__delete()
2635 zfree(&term->config); in parse_events_term__delete()
2636 free(term); in parse_events_term__delete()
2642 struct parse_events_term *term; in parse_events_terms__copy() local
2644 list_for_each_entry (term, &src->terms, list) { in parse_events_terms__copy()
2648 ret = parse_events_term__clone(&n, term); in parse_events_terms__copy()
2664 struct parse_events_term *term, *h; in parse_events_terms__exit() local
2666 list_for_each_entry_safe(term, h, &terms->terms, list) { in parse_events_terms__exit()
2667 list_del_init(&term->list); in parse_events_terms__exit()
2668 parse_events_term__delete(term); in parse_events_terms__exit()
2682 struct parse_events_term *term; in parse_events_terms__to_strbuf() local
2688 list_for_each_entry(term, &terms->terms, list) { in parse_events_terms__to_strbuf()
2698 if (term->type_val == PARSE_EVENTS__TERM_TYPE_NUM) in parse_events_terms__to_strbuf()
2699 if (term->no_value) { in parse_events_terms__to_strbuf()
2700 assert(term->val.num == 1); in parse_events_terms__to_strbuf()
2701 ret = strbuf_addf(sb, "%s", term->config); in parse_events_terms__to_strbuf()
2703 ret = strbuf_addf(sb, "%s=%#"PRIx64, term->config, term->val.num); in parse_events_terms__to_strbuf()
2704 else if (term->type_val == PARSE_EVENTS__TERM_TYPE_STR) { in parse_events_terms__to_strbuf()
2705 if (term->config) { in parse_events_terms__to_strbuf()
2706 ret = strbuf_addf(sb, "%s=", term->config); in parse_events_terms__to_strbuf()
2709 } else if ((unsigned int)term->type_term < __PARSE_EVENTS__TERM_TYPE_NR) { in parse_events_terms__to_strbuf()
2710 ret = strbuf_addf(sb, "%s=", config_term_name(term->type_term)); in parse_events_terms__to_strbuf()
2714 assert(!term->no_value); in parse_events_terms__to_strbuf()
2715 ret = strbuf_addf(sb, "%s", term->val.str); in parse_events_terms__to_strbuf()