Changeset View
Changeset View
Standalone View
Standalone View
lib/libpmc/libpmc.c
Show All 29 Lines | |||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <sys/types.h> | #include <sys/types.h> | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/module.h> | #include <sys/module.h> | ||||
#include <sys/pmc.h> | #include <sys/pmc.h> | ||||
#include <sys/syscall.h> | #include <sys/syscall.h> | ||||
#include <assert.h> | |||||
#include <ctype.h> | #include <ctype.h> | ||||
#include <errno.h> | #include <errno.h> | ||||
#include <err.h> | #include <err.h> | ||||
#include <fcntl.h> | #include <fcntl.h> | ||||
#include <pmc.h> | #include <pmc.h> | ||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <string.h> | #include <string.h> | ||||
▲ Show 20 Lines • Show All 1,033 Lines • ▼ Show 20 Lines | pmc_allocate(const char *ctrspec, enum pmc_mode mode, | ||||
/* | /* | ||||
* Try to pull the raw event ID directly from the pmu-events table. If | * Try to pull the raw event ID directly from the pmu-events table. If | ||||
* this is unsupported on the platform, or the event is not found, | * this is unsupported on the platform, or the event is not found, | ||||
* continue with searching the regular event tables. | * continue with searching the regular event tables. | ||||
*/ | */ | ||||
r = spec_copy = strdup(ctrspec); | r = spec_copy = strdup(ctrspec); | ||||
ctrname = strsep(&r, ","); | ctrname = strsep(&r, ","); | ||||
if (pmc_pmu_enabled()) { | if (pmc_pmu_enabled()) { | ||||
if (pmc_pmu_pmcallocate(ctrname, &pmc_config) == 0) | if (pmc_pmu_pmcallocate(ctrname, &pmc_config) == 0) { | ||||
/* | |||||
* XXX: pmclog_get_event exploits this to disambiguate | |||||
* PMU from PMC event codes in PMCALLOCATE events. | |||||
*/ | |||||
assert(pmc_config.pm_ev < PMC_EVENT_FIRST); | |||||
goto found; | goto found; | ||||
} | |||||
/* Otherwise, reset any changes */ | /* Otherwise, reset any changes */ | ||||
pmc_config.pm_ev = 0; | pmc_config.pm_ev = 0; | ||||
pmc_config.pm_caps = 0; | pmc_config.pm_caps = 0; | ||||
pmc_config.pm_class = 0; | pmc_config.pm_class = 0; | ||||
} | } | ||||
free(spec_copy); | free(spec_copy); | ||||
spec_copy = NULL; | spec_copy = NULL; | ||||
▲ Show 20 Lines • Show All 855 Lines • Show Last 20 Lines |