diff options
Diffstat (limited to 'gprofng/common/hwcdrv.c')
-rw-r--r-- | gprofng/common/hwcdrv.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/gprofng/common/hwcdrv.c b/gprofng/common/hwcdrv.c index 0ada09d..0b4cfc3 100644 --- a/gprofng/common/hwcdrv.c +++ b/gprofng/common/hwcdrv.c @@ -34,6 +34,7 @@ #include "cpuid.c" /* ftns for identifying a chip */ +static hdrv_pcbe_api_t *pcbe_driver = NULL; static hdrv_pcbe_api_t hdrv_pcbe_core_api; static hdrv_pcbe_api_t hdrv_pcbe_opteron_api; static hdrv_pcbe_api_t *hdrv_pcbe_drivers[] = { @@ -94,8 +95,6 @@ hwcdrv_lookup_cpuver (const char * cpcN_cciname) * For M8, a 4-bit mask of supported PICs is stored in bits [23:20]. */ -IS_GLOBAL hwcdrv_get_eventnum_fn_t *hwcdrv_get_x86_eventnum = 0; - static const attr_info_t perfctr_sparc_attrs[] = { {NTXT ("user"), 0, 0x01, 16}, //usr {NTXT ("system"), 0, 0x01, 17}, //os @@ -132,8 +131,9 @@ myperfctr_get_x86_eventnum (const char *eventname, uint_t pmc, eventsel_t *eventsel, eventsel_t *valid_umask, uint_t *pmc_sel) { - if (hwcdrv_get_x86_eventnum && - !hwcdrv_get_x86_eventnum (eventname, pmc, eventsel, valid_umask, pmc_sel)) + if (pcbe_driver && pcbe_driver->hdrv_pcbe_get_eventnum && + !pcbe_driver->hdrv_pcbe_get_eventnum (eventname, pmc, eventsel, + valid_umask, pmc_sel)) return 0; /* check for numerically-specified counters */ @@ -214,7 +214,7 @@ set_x86_attr_bits (eventsel_t *result_mask, eventsel_t evnt_valid_umask, return 0; } -IS_GLOBAL int +static int hwcfuncs_get_x86_eventsel (unsigned int regno, const char *int_name, eventsel_t *return_event, uint_t *return_pmc_sel) { @@ -287,6 +287,7 @@ perf_event_open (struct perf_event_attr *hw_event_uptr, pid_t pid, rc = syscall (__NR_perf_event_open, hw_event_uptr, pid, cpu, group_fd, flags); if (rc != -1) return rc; + TprintfT (0, "perf_event_open %d: errno=%d %s\n", retry, errno, strerror(errno)); } return rc; } @@ -375,7 +376,6 @@ static struct int internal_open_called; hwcfuncs_tsd_get_fn_t find_vpc_ctx; unsigned hwcdef_cnt; /* number of *active* hardware counters */ - hwcdrv_get_events_fn_t *get_events; } hdrv_pcl_state; static hwcdrv_about_t hdrv_pcl_about = {.cpcN_cpuver = CPUVER_UNDEFINED}; @@ -813,14 +813,13 @@ hdrv_pcl_internal_open () hdrv_pcbe_api_t *ppcbe = hdrv_pcbe_drivers[ii]; if (!ppcbe->hdrv_pcbe_init ()) { + pcbe_driver = ppcbe; hdrv_pcl_about.cpcN_cciname = ppcbe->hdrv_pcbe_impl_name (); hdrv_pcl_about.cpcN_cpuver = hwcdrv_lookup_cpuver (hdrv_pcl_about.cpcN_cciname); if (hdrv_pcl_about.cpcN_cpuver == CPUVER_UNDEFINED) goto internal_open_error; hdrv_pcl_about.cpcN_npics = ppcbe->hdrv_pcbe_ncounters (); hdrv_pcl_about.cpcN_docref = ppcbe->hdrv_pcbe_cpuref (); - hdrv_pcl_state.get_events = ppcbe->hdrv_pcbe_get_events; - hwcdrv_get_x86_eventnum = ppcbe->hdrv_pcbe_get_eventnum; break; } } @@ -894,11 +893,12 @@ hwcdrv_enable_mt (hwcfuncs_tsd_get_fn_t tsd_ftn) } HWCDRV_API int -hwcdrv_get_descriptions (hwcf_hwc_cb_t *hwc_cb, hwcf_attr_cb_t *attr_cb) +hwcdrv_get_descriptions (hwcf_hwc_cb_t *hwc_cb, hwcf_attr_cb_t *attr_cb, + Hwcentry *raw_hwc_tbl) { int count = 0; - if (hwc_cb && hdrv_pcl_state.get_events) - count = hdrv_pcl_state.get_events (hwc_cb); + if (hwc_cb && pcbe_driver && pcbe_driver->hdrv_pcbe_get_events) + count = pcbe_driver->hdrv_pcbe_get_events (hwc_cb, raw_hwc_tbl); if (attr_cb) for (int ii = 0; perfctr_attrs_table && perfctr_attrs_table[ii].attrname; ii++) attr_cb (perfctr_attrs_table[ii].attrname); |