diff options
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/util/pmu.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index bfbecf7abd38..48411674da0f 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c | |||
@@ -819,10 +819,36 @@ void perf_pmu__set_format(unsigned long *bits, long from, long to) | |||
819 | set_bit(b, bits); | 819 | set_bit(b, bits); |
820 | } | 820 | } |
821 | 821 | ||
822 | static int sub_non_neg(int a, int b) | ||
823 | { | ||
824 | if (b > a) | ||
825 | return 0; | ||
826 | return a - b; | ||
827 | } | ||
828 | |||
822 | static char *format_alias(char *buf, int len, struct perf_pmu *pmu, | 829 | static char *format_alias(char *buf, int len, struct perf_pmu *pmu, |
823 | struct perf_pmu_alias *alias) | 830 | struct perf_pmu_alias *alias) |
824 | { | 831 | { |
825 | snprintf(buf, len, "%s/%s/", pmu->name, alias->name); | 832 | struct parse_events_term *term; |
833 | int used = snprintf(buf, len, "%s/%s", pmu->name, alias->name); | ||
834 | |||
835 | list_for_each_entry(term, &alias->terms, list) { | ||
836 | if (term->type_val == PARSE_EVENTS__TERM_TYPE_STR) | ||
837 | used += snprintf(buf + used, sub_non_neg(len, used), | ||
838 | ",%s=%s", term->config, | ||
839 | term->val.str); | ||
840 | } | ||
841 | |||
842 | if (sub_non_neg(len, used) > 0) { | ||
843 | buf[used] = '/'; | ||
844 | used++; | ||
845 | } | ||
846 | if (sub_non_neg(len, used) > 0) { | ||
847 | buf[used] = '\0'; | ||
848 | used++; | ||
849 | } else | ||
850 | buf[len - 1] = '\0'; | ||
851 | |||
826 | return buf; | 852 | return buf; |
827 | } | 853 | } |
828 | 854 | ||