Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/pmcstat/pmcpl_callgraph.c
Show First 20 Lines • Show All 467 Lines • ▼ Show 20 Lines | pmcstat_callgraph_print(void) | ||||
struct pmcstat_pmcrecord *pmcr; | struct pmcstat_pmcrecord *pmcr; | ||||
LIST_FOREACH(pmcr, &pmcstat_pmcs, pr_next) | LIST_FOREACH(pmcr, &pmcstat_pmcs, pr_next) | ||||
pmcstat_callgraph_print_for_pmcid(pmcr); | pmcstat_callgraph_print_for_pmcid(pmcr); | ||||
} | } | ||||
static void | static void | ||||
pmcstat_cgnode_topprint(struct pmcstat_cgnode *cg, | pmcstat_cgnode_topprint(struct pmcstat_cgnode *cg, | ||||
int depth, uint32_t nsamples) | int depth __unused, uint32_t nsamples) | ||||
{ | { | ||||
int v_attrs, vs_len, ns_len, width, len, n, nchildren; | int v_attrs, vs_len, ns_len, width, len, n, nchildren; | ||||
float v; | float v; | ||||
char ns[30], vs[10]; | char ns[30], vs[10]; | ||||
struct pmcstat_symbol *sym; | struct pmcstat_symbol *sym; | ||||
struct pmcstat_cgnode **sortbuffer, **cgn, *pcg; | struct pmcstat_cgnode **sortbuffer, **cgn, *pcg; | ||||
(void) depth; | |||||
/* Format value. */ | /* Format value. */ | ||||
v = PMCPL_CG_COUNTP(cg); | v = PMCPL_CG_COUNTP(cg); | ||||
snprintf(vs, sizeof(vs), "%.1f", v); | snprintf(vs, sizeof(vs), "%.1f", v); | ||||
v_attrs = PMCSTAT_ATTRPERCENT(v); | v_attrs = PMCSTAT_ATTRPERCENT(v); | ||||
sym = NULL; | |||||
/* Format name. */ | /* Format name. */ | ||||
if (!(args.pa_flags & FLAG_SKIP_TOP_FN_RES)) | |||||
sym = pmcstat_symbol_search(cg->pcg_image, cg->pcg_func); | sym = pmcstat_symbol_search(cg->pcg_image, cg->pcg_func); | ||||
if (sym != NULL) { | if (sym != NULL) { | ||||
snprintf(ns, sizeof(ns), "%s", | snprintf(ns, sizeof(ns), "%s", | ||||
pmcstat_string_unintern(sym->ps_name)); | pmcstat_string_unintern(sym->ps_name)); | ||||
} else | } else | ||||
snprintf(ns, sizeof(ns), "%p", | snprintf(ns, sizeof(ns), "%p", | ||||
(void *)cg->pcg_func); | (void *)(cg->pcg_image->pi_vaddr + cg->pcg_func)); | ||||
PMCSTAT_ATTRON(v_attrs); | PMCSTAT_ATTRON(v_attrs); | ||||
PMCSTAT_PRINTW("%5.5s", vs); | PMCSTAT_PRINTW("%5.5s", vs); | ||||
PMCSTAT_ATTROFF(v_attrs); | PMCSTAT_ATTROFF(v_attrs); | ||||
PMCSTAT_PRINTW(" %-10.10s %-20.20s", | PMCSTAT_PRINTW(" %-15.15s %-22.22s", | ||||
pmcstat_string_unintern(cg->pcg_image->pi_name), | pmcstat_string_unintern(cg->pcg_image->pi_name), | ||||
ns); | ns); | ||||
nchildren = cg->pcg_nchildren; | nchildren = cg->pcg_nchildren; | ||||
if (nchildren == 0) { | if (nchildren == 0) { | ||||
PMCSTAT_PRINTW("\n"); | PMCSTAT_PRINTW("\n"); | ||||
return; | return; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | pmcpl_cg_topdisplay(void) | ||||
if (nentries == 0) { | if (nentries == 0) { | ||||
free(sortbuffer); | free(sortbuffer); | ||||
return; | return; | ||||
} | } | ||||
qsort(sortbuffer, nentries, sizeof(struct pmcstat_cgnode *), | qsort(sortbuffer, nentries, sizeof(struct pmcstat_cgnode *), | ||||
pmcstat_cgnode_compare); | pmcstat_cgnode_compare); | ||||
PMCSTAT_PRINTW("%5.5s %-10.10s %-20.20s %s\n", | PMCSTAT_PRINTW("%5.5s %-15.15s %-22.22s %s\n", | ||||
"%SAMP", "IMAGE", "FUNCTION", "CALLERS"); | "%SAMP", "IMAGE", "FUNCTION", "CALLERS"); | ||||
nentries = min(pmcstat_displayheight - 2, nentries); | nentries = min(pmcstat_displayheight - 2, nentries); | ||||
for (cgn = sortbuffer, n = 0; n < nentries; n++, cgn++) { | for (cgn = sortbuffer, n = 0; n < nentries; n++, cgn++) { | ||||
if (PMCPL_CG_COUNTP(*cgn) < pmcstat_threshold) | if (PMCPL_CG_COUNTP(*cgn) < pmcstat_threshold) | ||||
break; | break; | ||||
pmcstat_cgnode_topprint(*cgn, 0, nsamples); | pmcstat_cgnode_topprint(*cgn, 0, nsamples); | ||||
▲ Show 20 Lines • Show All 60 Lines • Show Last 20 Lines |