libpmc: allow substring for list and add function for printing event details
This commit is contained in:
parent
cfb0dfa3c2
commit
fbf962e6bb
@ -235,7 +235,7 @@ pmc_pmu_enabled(void)
|
||||
}
|
||||
|
||||
void
|
||||
pmc_pmu_print_counters(void)
|
||||
pmc_pmu_print_counters(const char *event_name)
|
||||
{
|
||||
const struct pmu_events_map *pme;
|
||||
const struct pmu_event *pe;
|
||||
@ -253,6 +253,8 @@ pmc_pmu_print_counters(void)
|
||||
for (pe = pme->table; pe->name || pe->desc || pe->event; pe++) {
|
||||
if (pe->name == NULL)
|
||||
continue;
|
||||
if (event_name != NULL && strcasestr(pe->name, event_name) == NULL)
|
||||
continue;
|
||||
printf("\t%s\n", pe->name);
|
||||
if (do_debug)
|
||||
pmu_parse_event(&ped, pe->event);
|
||||
@ -296,6 +298,43 @@ pmc_pmu_print_counter_desc_long(const char *ev)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
pmc_pmu_print_counter_full(const char *ev)
|
||||
{
|
||||
const struct pmu_events_map *pme;
|
||||
const struct pmu_event *pe;
|
||||
|
||||
if ((pme = pmu_events_map_get()) == NULL)
|
||||
return;
|
||||
for (pe = pme->table; pe->name || pe->desc || pe->event; pe++) {
|
||||
if (pe->name == NULL)
|
||||
continue;
|
||||
if (strcasestr(pe->name, ev) == NULL)
|
||||
continue;
|
||||
printf("name: %s\n", pe->name);
|
||||
if (pe->long_desc != NULL)
|
||||
printf("desc: %s\n", pe->long_desc);
|
||||
else if (pe->desc != NULL)
|
||||
printf("desc: %s\n", pe->desc);
|
||||
if (pe->event != NULL)
|
||||
printf("event: %s\n", pe->event);
|
||||
if (pe->topic != NULL)
|
||||
printf("topic: %s\n", pe->topic);
|
||||
if (pe->pmu != NULL)
|
||||
printf("pmu: %s\n", pe->pmu);
|
||||
if (pe->unit != NULL)
|
||||
printf("unit: %s\n", pe->unit);
|
||||
if (pe->perpkg != NULL)
|
||||
printf("perpkg: %s\n", pe->perpkg);
|
||||
if (pe->metric_expr != NULL)
|
||||
printf("metric_expr: %s\n", pe->metric_expr);
|
||||
if (pe->metric_name != NULL)
|
||||
printf("metric_name: %s\n", pe->metric_name);
|
||||
if (pe->metric_group != NULL)
|
||||
printf("metric_group: %s\n", pe->metric_group);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
pmc_pmu_pmcallocate(const char *event_name, struct pmc_op_pmcallocate *pm)
|
||||
{
|
||||
@ -394,7 +433,7 @@ pmc_pmu_sample_rate_get(const char *event_name __unused)
|
||||
}
|
||||
|
||||
void
|
||||
pmc_pmu_print_counters(void)
|
||||
pmc_pmu_print_counters(const char *event_name __unused)
|
||||
{
|
||||
}
|
||||
|
||||
@ -408,6 +447,12 @@ pmc_pmu_print_counter_desc_long(const char *e __unused)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
pmc_pmu_print_counter_full(const char *e __unused)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
pmc_pmu_enabled(void)
|
||||
{
|
||||
|
@ -114,9 +114,10 @@ int pmc_event_names_of_class(enum pmc_class _cl, const char ***_eventnames,
|
||||
int *_nevents);
|
||||
|
||||
int pmc_pmu_enabled(void);
|
||||
void pmc_pmu_print_counters(void);
|
||||
void pmc_pmu_print_counters(const char *);
|
||||
void pmc_pmu_print_counter_desc(const char *);
|
||||
void pmc_pmu_print_counter_desc_long(const char *);
|
||||
void pmc_pmu_print_counter_full(const char *);
|
||||
uint64_t pmc_pmu_sample_rate_get(const char *);
|
||||
int pmc_pmu_pmcallocate(const char *, struct pmc_op_pmcallocate *);
|
||||
const char *pmc_pmu_event_get_by_idx(int idx);
|
||||
|
@ -820,7 +820,7 @@ main(int argc, char **argv)
|
||||
pmc_pmu_enabled() == 0)
|
||||
errx(EX_USAGE, "pmu features not supported on host or hwpmc not loaded");
|
||||
if (do_listcounters) {
|
||||
pmc_pmu_print_counters();
|
||||
pmc_pmu_print_counters(NULL);
|
||||
} else if (do_descr) {
|
||||
pmc_pmu_print_counter_desc(event);
|
||||
} else if (do_long_descr) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user