Lines Matching +full:close +full:- +full:range
1 /*-
2 * Copyright (c) 2003-2008 Joseph Koshy
62 if (pr->pr_pmcid == pmcid) { in pmcstat_lookup_pmcid()
64 return pr->pr_merge; in pmcstat_lookup_pmcid()
86 if (pr->pr_pmcid == pmcid) { in pmcstat_pmcid_add()
87 pr->pr_pmcname = ps; in pmcstat_pmcid_add()
89 } else if (pr->pr_pmcname == ps) in pmcstat_pmcid_add()
99 pr->pr_pmcid = pmcid; in pmcstat_pmcid_add()
100 pr->pr_pmcname = ps; in pmcstat_pmcid_add()
101 pr->pr_pmcin = (*pmcstat_npmcs)++; in pmcstat_pmcid_add()
102 pr->pr_samples = 0; in pmcstat_pmcid_add()
103 pr->pr_dubious_frames = 0; in pmcstat_pmcid_add()
104 pr->pr_merge = prm == NULL ? pr : prm; in pmcstat_pmcid_add()
108 if (plugins[args->pa_pplugin].pl_newpmc != NULL) in pmcstat_pmcid_add()
109 plugins[args->pa_pplugin].pl_newpmc(ps, pr); in pmcstat_pmcid_add()
110 if (plugins[args->pa_plugin].pl_newpmc != NULL) in pmcstat_pmcid_add()
111 plugins[args->pa_plugin].pl_newpmc(ps, pr); in pmcstat_pmcid_add()
115 * Unmap images in the range [start..end) associated with process
130 * - we could have the range completely in the middle of an in pmcstat_image_unmap()
133 * - we could have the range covering multiple pcmaps; these in pmcstat_image_unmap()
135 * - we could have either 'start' or 'end' falling in the in pmcstat_image_unmap()
138 TAILQ_FOREACH_SAFE(pcm, &pp->pp_map, ppm_next, pcmtmp) { in pmcstat_image_unmap()
139 assert(pcm->ppm_lowpc < pcm->ppm_highpc); in pmcstat_image_unmap()
140 if (pcm->ppm_highpc <= start) in pmcstat_image_unmap()
142 if (pcm->ppm_lowpc >= end) in pmcstat_image_unmap()
144 if (pcm->ppm_lowpc >= start && pcm->ppm_highpc <= end) { in pmcstat_image_unmap()
147 * unmapped range: remove it entirely. in pmcstat_image_unmap()
149 TAILQ_REMOVE(&pp->pp_map, pcm, ppm_next); in pmcstat_image_unmap()
151 } else if (pcm->ppm_lowpc < start && pcm->ppm_highpc > end) { in pmcstat_image_unmap()
154 * current map to end at [start-1], and start in pmcstat_image_unmap()
161 pcmnew->ppm_image = pcm->ppm_image; in pmcstat_image_unmap()
163 pcmnew->ppm_lowpc = end; in pmcstat_image_unmap()
164 pcmnew->ppm_highpc = pcm->ppm_highpc; in pmcstat_image_unmap()
166 pcm->ppm_highpc = start; in pmcstat_image_unmap()
168 TAILQ_INSERT_AFTER(&pp->pp_map, pcm, pcmnew, ppm_next); in pmcstat_image_unmap()
171 } else if (pcm->ppm_lowpc < start && pcm->ppm_highpc <= end) in pmcstat_image_unmap()
172 pcm->ppm_highpc = start; in pmcstat_image_unmap()
173 else if (pcm->ppm_lowpc >= start && pcm->ppm_highpc > end) in pmcstat_image_unmap()
174 pcm->ppm_lowpc = end; in pmcstat_image_unmap()
181 * Convert a hwpmc(4) log to profile information. A system-wide
203 assert(args->pa_flags & FLAG_DO_ANALYSIS); in pmcstat_analyze_log()
208 while (pmclog_read(args->pa_logparser, &ev) == 0) { in pmcstat_analyze_log()
214 PMC_VERSION_MAJOR << 24 && args->pa_verbosity > 0) in pmcstat_analyze_log()
222 * Introduce an address range mapping for a in pmcstat_analyze_log()
223 * userland process or the kernel (pid == -1). in pmcstat_analyze_log()
227 * address range are mapped to the current in pmcstat_analyze_log()
231 if (pid == -1) in pmcstat_analyze_log()
241 image = pmcstat_image_from_path(image_path, pid == -1, in pmcstat_analyze_log()
243 if (image->pi_type == PMCSTAT_IMAGE_UNKNOWN) in pmcstat_analyze_log()
245 if (image->pi_type != PMCSTAT_IMAGE_INDETERMINABLE) in pmcstat_analyze_log()
255 if (pid == -1) in pmcstat_analyze_log()
268 pmcstat_stats->ps_samples_total++; in pmcstat_analyze_log()
274 if ((args->pa_flags & FLAG_FILTER_THREAD_ID) && in pmcstat_analyze_log()
275 args->pa_tid != ev.pl_u.pl_cc.pl_tid) { in pmcstat_analyze_log()
276 pmcstat_stats->ps_samples_skipped++; in pmcstat_analyze_log()
280 if (!CPU_ISSET(cpu, &(args->pa_cpumask))) { in pmcstat_analyze_log()
281 pmcstat_stats->ps_samples_skipped++; in pmcstat_analyze_log()
291 pmcr->pr_samples++; in pmcstat_analyze_log()
297 if (plugins[args->pa_pplugin].pl_process != NULL) in pmcstat_analyze_log()
298 plugins[args->pa_pplugin].pl_process( in pmcstat_analyze_log()
304 plugins[args->pa_plugin].pl_process( in pmcstat_analyze_log()
341 TAILQ_FOREACH_SAFE(ppm, &pp->pp_map, ppm_next, ppmtmp) { in pmcstat_analyze_log()
342 TAILQ_REMOVE(&pp->pp_map, ppm, ppm_next); in pmcstat_analyze_log()
371 pp->pp_isactive = 0; /* mark as a zombie */ in pmcstat_analyze_log()
378 pp->pp_isactive = 0; /* make a zombie */ in pmcstat_analyze_log()
398 TAILQ_FOREACH(ppm, &pp->pp_map, ppm_next) in pmcstat_analyze_log()
399 pmcstat_image_link(ppnew, ppm->ppm_image, in pmcstat_analyze_log()
400 ppm->ppm_lowpc); in pmcstat_analyze_log()
421 * The function returns the fd of a successfully opened log or -1 in
435 fd = -1; in pmcstat_open_log()
438 * If 'path' is "-" then open one of stdin or stdout depending in pmcstat_open_log()
447 if (path[0] == '-' && path[1] == '\0') in pmcstat_open_log()
453 hlen = p - path; in pmcstat_open_log()
471 fd = -1; in pmcstat_open_log()
472 for (res = res0; res; res = res->ai_next) { in pmcstat_open_log()
473 if ((fd = socket(res->ai_family, res->ai_socktype, in pmcstat_open_log()
474 res->ai_protocol)) < 0) { in pmcstat_open_log()
479 if (bind(fd, res->ai_addr, res->ai_addrlen) < 0) { in pmcstat_open_log()
481 (void) close(fd); in pmcstat_open_log()
482 fd = -1; in pmcstat_open_log()
487 (void) close(fd); in pmcstat_open_log()
490 fd = -1; in pmcstat_open_log()
495 if (connect(fd, res->ai_addr, res->ai_addrlen) < 0) { in pmcstat_open_log()
497 (void) close(fd); in pmcstat_open_log()
498 fd = -1; in pmcstat_open_log()
522 * Close a logfile, after first flushing all in-module queued data.
529 * and flush data. Kernel will close the file when data is flushed in pmcstat_close_log()
532 if (args->pa_logfd != -1) { in pmcstat_close_log()
537 return (args->pa_flags & FLAG_HAS_PIPE ? PMCSTAT_EXITING : in pmcstat_close_log()
565 * Create a fake 'process' entry for the kernel with pid -1. in pmcstat_initialize_logging()
569 if ((pmcstat_kp = pmcstat_process_lookup((pid_t) -1, in pmcstat_initialize_logging()
579 *pmcstat_mergepmc = args->pa_mergepmc; in pmcstat_initialize_logging()
585 if (plugins[args->pa_pplugin].pl_init != NULL) in pmcstat_initialize_logging()
586 plugins[args->pa_pplugin].pl_init(); in pmcstat_initialize_logging()
587 if (plugins[args->pa_plugin].pl_init != NULL) in pmcstat_initialize_logging()
588 plugins[args->pa_plugin].pl_init(); in pmcstat_initialize_logging()
608 if (args->pa_mapfilename != NULL) in pmcstat_shutdown_logging()
609 mf = (strcmp(args->pa_mapfilename, "-") == 0) ? in pmcstat_shutdown_logging()
610 args->pa_printfile : fopen(args->pa_mapfilename, "w"); in pmcstat_shutdown_logging()
612 if (mf == NULL && args->pa_flags & FLAG_DO_GPROF && in pmcstat_shutdown_logging()
613 args->pa_verbosity >= 2) in pmcstat_shutdown_logging()
614 mf = args->pa_printfile; in pmcstat_shutdown_logging()
623 if (plugins[args->pa_plugin].pl_shutdown != NULL) in pmcstat_shutdown_logging()
624 plugins[args->pa_plugin].pl_shutdown(mf); in pmcstat_shutdown_logging()
625 if (plugins[args->pa_pplugin].pl_shutdown != NULL) in pmcstat_shutdown_logging()
626 plugins[args->pa_pplugin].pl_shutdown(mf); in pmcstat_shutdown_logging()
631 if (plugins[args->pa_plugin].pl_shutdownimage != NULL) in pmcstat_shutdown_logging()
632 plugins[args->pa_plugin].pl_shutdownimage(pi); in pmcstat_shutdown_logging()
633 if (plugins[args->pa_pplugin].pl_shutdownimage != NULL) in pmcstat_shutdown_logging()
634 plugins[args->pa_pplugin].pl_shutdownimage(pi); in pmcstat_shutdown_logging()
636 free(pi->pi_symbols); in pmcstat_shutdown_logging()
637 if (pi->pi_addr2line != NULL) in pmcstat_shutdown_logging()
638 pclose(pi->pi_addr2line); in pmcstat_shutdown_logging()
645 TAILQ_FOREACH_SAFE(ppm, &pp->pp_map, ppm_next, ppmtmp) { in pmcstat_shutdown_logging()
646 TAILQ_REMOVE(&pp->pp_map, ppm, ppm_next); in pmcstat_shutdown_logging()
657 * Print errors unless -q was specified. Print all statistics in pmcstat_shutdown_logging()
661 if (pmcstat_stats->ps_##V || args->pa_verbosity >= 2) \ in pmcstat_shutdown_logging()
662 (void) fprintf(args->pa_printfile, " %-40s %d\n",\ in pmcstat_shutdown_logging()
663 N, pmcstat_stats->ps_##V); \ in pmcstat_shutdown_logging()
666 if (args->pa_verbosity >= 1 && (args->pa_flags & FLAG_DO_ANALYSIS)) { in pmcstat_shutdown_logging()
667 (void) fprintf(args->pa_printfile, "CONVERSION STATISTICS:\n"); in pmcstat_shutdown_logging()
674 PRINT("#samples/unknown-object", samples_indeterminable); in pmcstat_shutdown_logging()
675 PRINT("#samples/unknown-function", samples_unknown_function); in pmcstat_shutdown_logging()
676 PRINT("#callchain/dubious-frames", callchain_dubious_frames); in pmcstat_shutdown_logging()