}
static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name,
- char *desc, char *val, char *long_desc)
+ char *desc, char *val, char *long_desc,
+ char *topic)
{
struct perf_pmu_alias *alias;
int ret;
alias->desc = desc ? strdup(desc) : NULL;
alias->long_desc = long_desc ? strdup(long_desc) :
desc ? strdup(desc) : NULL;
+ alias->topic = topic ? strdup(topic) : NULL;
list_add_tail(&alias->list, list);
buf[ret] = 0;
- return __perf_pmu__new_alias(list, dir, name, NULL, buf, NULL);
+ return __perf_pmu__new_alias(list, dir, name, NULL, buf, NULL, NULL);
}
static inline bool pmu_alias_info_file(char *name)
/* need type casts to override 'const' */
__perf_pmu__new_alias(head, NULL, (char *)pe->name,
(char *)pe->desc, (char *)pe->event,
- (char *)pe->long_desc);
+ (char *)pe->long_desc, (char *)pe->topic);
}
out:
return buf;
}
-struct pair {
+struct sevent {
char *name;
char *desc;
+ char *topic;
};
-static int cmp_pair(const void *a, const void *b)
+static int cmp_sevent(const void *a, const void *b)
{
- const struct pair *as = a;
- const struct pair *bs = b;
+ const struct sevent *as = a;
+ const struct sevent *bs = b;
/* Put extra events last */
if (!!as->desc != !!bs->desc)
return !!as->desc - !!bs->desc;
+ if (as->topic && bs->topic) {
+ int n = strcmp(as->topic, bs->topic);
+
+ if (n)
+ return n;
+ }
return strcmp(as->name, bs->name);
}
char buf[1024];
int printed = 0;
int len, j;
- struct pair *aliases;
+ struct sevent *aliases;
int numdesc = 0;
int columns = pager_get_columns();
+ char *topic = NULL;
pmu = NULL;
len = 0;
if (pmu->selectable)
len++;
}
- aliases = zalloc(sizeof(struct pair) * len);
+ aliases = zalloc(sizeof(struct sevent) * len);
if (!aliases)
goto out_enomem;
pmu = NULL;
aliases[j].desc = long_desc ? alias->long_desc :
alias->desc;
+ aliases[j].topic = alias->topic;
j++;
}
if (pmu->selectable &&
}
}
len = j;
- qsort(aliases, len, sizeof(struct pair), cmp_pair);
+ qsort(aliases, len, sizeof(struct sevent), cmp_sevent);
for (j = 0; j < len; j++) {
if (name_only) {
printf("%s ", aliases[j].name);
if (aliases[j].desc && !quiet_flag) {
if (numdesc++ == 0)
printf("\n");
+ if (aliases[j].topic && (!topic ||
+ strcmp(topic, aliases[j].topic))) {
+ printf("%s%s:\n", topic ? "\n" : "",
+ aliases[j].topic);
+ topic = aliases[j].topic;
+ }
printf(" %-50s\n", aliases[j].name);
printf("%*s", 8, "[");
wordwrap(aliases[j].desc, 8, columns, 0);