diff --git a/usr.sbin/pmcstat/pmcstat.c b/usr.sbin/pmcstat/pmcstat.c index c32b55f76ed..c41fa77f75d 100644 --- a/usr.sbin/pmcstat/pmcstat.c +++ b/usr.sbin/pmcstat/pmcstat.c @@ -88,10 +88,6 @@ pmcstat_cleanup(struct pmcstat_args *a) { struct pmcstat_ev *ev, *tmp; - /* de-configure the log file if present. */ - if (a->pa_flags & (FLAG_HAS_PIPE | FLAG_HAS_OUTPUT_LOGFILE)) - (void) pmc_configure_logfile(-1); - /* release allocated PMCs. */ STAILQ_FOREACH_SAFE(ev, &a->pa_head, ev_next, tmp) if (ev->ev_pmcid != PMC_ID_INVALID) { @@ -104,6 +100,10 @@ pmcstat_cleanup(struct pmcstat_args *a) free(ev); } + /* de-configure the log file if present. */ + if (a->pa_flags & (FLAG_HAS_PIPE | FLAG_HAS_OUTPUT_LOGFILE)) + (void) pmc_configure_logfile(-1); + if (a->pa_logparser) { pmclog_close(a->pa_logparser); a->pa_logparser = NULL; @@ -306,7 +306,6 @@ pmcstat_start_process(struct pmcstat_args *a) (void) close(pmcstat_pipefd[WRITEPIPEFD]); } - void pmcstat_show_usage(void) { @@ -884,7 +883,7 @@ main(int argc, char **argv) break; case EVFILT_READ: /* log file data is present */ - runstate = pmcstat_print_log(&args); + runstate = pmcstat_process_log(&args); break; case EVFILT_SIGNAL: diff --git a/usr.sbin/pmcstat/pmcstat.h b/usr.sbin/pmcstat/pmcstat.h index 393e3faab87..f0246f9aaf8 100644 --- a/usr.sbin/pmcstat/pmcstat.h +++ b/usr.sbin/pmcstat/pmcstat.h @@ -120,7 +120,7 @@ void pmcstat_show_usage(void); void pmcstat_shutdown_logging(void); void pmcstat_start_pmcs(struct pmcstat_args *_a); void pmcstat_start_process(struct pmcstat_args *_a); -void pmcstat_process_log(struct pmcstat_args *_a); +int pmcstat_process_log(struct pmcstat_args *_a); int pmcstat_print_log(struct pmcstat_args *_a); int pmcstat_convert_log(struct pmcstat_args *_a); diff --git a/usr.sbin/pmcstat/pmcstat_log.c b/usr.sbin/pmcstat/pmcstat_log.c index 111064d2036..500959db077 100644 --- a/usr.sbin/pmcstat/pmcstat_log.c +++ b/usr.sbin/pmcstat/pmcstat_log.c @@ -1159,7 +1159,7 @@ pmcstat_print_log(struct pmcstat_args *a) * Process a log file in offline analysis mode. */ -void +int pmcstat_process_log(struct pmcstat_args *a) { @@ -1168,12 +1168,10 @@ pmcstat_process_log(struct pmcstat_args *a) * log to the current output file. */ if (a->pa_flags & FLAG_DO_PRINT) - pmcstat_print_log(a); + return pmcstat_print_log(a); else /* convert the log to gprof compatible profiles */ - pmcstat_convert_log(a); - - return; + return pmcstat_convert_log(a); } void