pmcstat.c (147708) | pmcstat.c (147863) |
---|---|
1/*- 2 * Copyright (c) 2003-2005, Joseph Koshy 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2003-2005, Joseph Koshy 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/usr.sbin/pmcstat/pmcstat.c 147708 2005-06-30 19:01:26Z jkoshy $"); | 28__FBSDID("$FreeBSD: head/usr.sbin/pmcstat/pmcstat.c 147863 2005-07-09 17:08:46Z jkoshy $"); |
29 30#include <sys/types.h> 31#include <sys/event.h> 32#include <sys/queue.h> 33#include <sys/socket.h> 34#include <sys/stat.h> 35#include <sys/time.h> 36#include <sys/ttycom.h> --- 46 unchanged lines hidden (view full) --- 83 * cleanup 84 */ 85 86void 87pmcstat_cleanup(struct pmcstat_args *a) 88{ 89 struct pmcstat_ev *ev, *tmp; 90 | 29 30#include <sys/types.h> 31#include <sys/event.h> 32#include <sys/queue.h> 33#include <sys/socket.h> 34#include <sys/stat.h> 35#include <sys/time.h> 36#include <sys/ttycom.h> --- 46 unchanged lines hidden (view full) --- 83 * cleanup 84 */ 85 86void 87pmcstat_cleanup(struct pmcstat_args *a) 88{ 89 struct pmcstat_ev *ev, *tmp; 90 |
91 /* de-configure the log file if present. */ 92 if (a->pa_flags & (FLAG_HAS_PIPE | FLAG_HAS_OUTPUT_LOGFILE)) 93 (void) pmc_configure_logfile(-1); 94 | |
95 /* release allocated PMCs. */ 96 STAILQ_FOREACH_SAFE(ev, &a->pa_head, ev_next, tmp) 97 if (ev->ev_pmcid != PMC_ID_INVALID) { 98 if (pmc_release(ev->ev_pmcid) < 0) 99 err(EX_OSERR, "ERROR: cannot release pmc " 100 "0x%x \"%s\"", ev->ev_pmcid, ev->ev_name); 101 free(ev->ev_name); 102 free(ev->ev_spec); 103 STAILQ_REMOVE(&a->pa_head, ev, pmcstat_ev, ev_next); 104 free(ev); 105 } 106 | 91 /* release allocated PMCs. */ 92 STAILQ_FOREACH_SAFE(ev, &a->pa_head, ev_next, tmp) 93 if (ev->ev_pmcid != PMC_ID_INVALID) { 94 if (pmc_release(ev->ev_pmcid) < 0) 95 err(EX_OSERR, "ERROR: cannot release pmc " 96 "0x%x \"%s\"", ev->ev_pmcid, ev->ev_name); 97 free(ev->ev_name); 98 free(ev->ev_spec); 99 STAILQ_REMOVE(&a->pa_head, ev, pmcstat_ev, ev_next); 100 free(ev); 101 } 102 |
103 /* de-configure the log file if present. */ 104 if (a->pa_flags & (FLAG_HAS_PIPE | FLAG_HAS_OUTPUT_LOGFILE)) 105 (void) pmc_configure_logfile(-1); 106 |
|
107 if (a->pa_logparser) { 108 pmclog_close(a->pa_logparser); 109 a->pa_logparser = NULL; 110 } 111 112 if (a->pa_flags & (FLAG_HAS_PIPE | FLAG_HAS_OUTPUT_LOGFILE)) 113 pmcstat_shutdown_logging(); 114} --- 186 unchanged lines hidden (view full) --- 301 302 /* write token to child to state that we are ready */ 303 if (write(pmcstat_pipefd[WRITEPIPEFD], "+", 1) != 1) 304 err(EX_OSERR, "ERROR: write failed"); 305 306 (void) close(pmcstat_pipefd[WRITEPIPEFD]); 307} 308 | 107 if (a->pa_logparser) { 108 pmclog_close(a->pa_logparser); 109 a->pa_logparser = NULL; 110 } 111 112 if (a->pa_flags & (FLAG_HAS_PIPE | FLAG_HAS_OUTPUT_LOGFILE)) 113 pmcstat_shutdown_logging(); 114} --- 186 unchanged lines hidden (view full) --- 301 302 /* write token to child to state that we are ready */ 303 if (write(pmcstat_pipefd[WRITEPIPEFD], "+", 1) != 1) 304 err(EX_OSERR, "ERROR: write failed"); 305 306 (void) close(pmcstat_pipefd[WRITEPIPEFD]); 307} 308 |
309 | |
310void 311pmcstat_show_usage(void) 312{ 313 errx(EX_USAGE, 314 "[options] [commandline]\n" 315 "\t Measure process and/or system performance using hardware\n" 316 "\t performance monitoring counters.\n" 317 "\t Options include:\n" --- 561 unchanged lines hidden (view full) --- 879 switch (kev.filter) { 880 case EVFILT_PROC: /* target has exited */ 881 if (args.pa_flags & (FLAG_HAS_OUTPUT_LOGFILE | 882 FLAG_HAS_PIPE)) 883 runstate = pmcstat_close_log(&args); 884 break; 885 886 case EVFILT_READ: /* log file data is present */ | 309void 310pmcstat_show_usage(void) 311{ 312 errx(EX_USAGE, 313 "[options] [commandline]\n" 314 "\t Measure process and/or system performance using hardware\n" 315 "\t performance monitoring counters.\n" 316 "\t Options include:\n" --- 561 unchanged lines hidden (view full) --- 878 switch (kev.filter) { 879 case EVFILT_PROC: /* target has exited */ 880 if (args.pa_flags & (FLAG_HAS_OUTPUT_LOGFILE | 881 FLAG_HAS_PIPE)) 882 runstate = pmcstat_close_log(&args); 883 break; 884 885 case EVFILT_READ: /* log file data is present */ |
887 runstate = pmcstat_print_log(&args); | 886 runstate = pmcstat_process_log(&args); |
888 break; 889 890 case EVFILT_SIGNAL: 891 if (kev.ident == SIGCHLD) { 892 /* 893 * The child process sends us a 894 * SIGCHLD if its exec() failed. We 895 * wait for it to exit and then exit --- 62 unchanged lines hidden --- | 887 break; 888 889 case EVFILT_SIGNAL: 890 if (kev.ident == SIGCHLD) { 891 /* 892 * The child process sends us a 893 * SIGCHLD if its exec() failed. We 894 * wait for it to exit and then exit --- 62 unchanged lines hidden --- |