[patch] hwpmc [12/13]

Aggelos Economopoulos aoiko at cc.ece.ntua.gr
Sat Nov 24 13:17:46 PST 2007


Minor adjustments for dragonfly.

diff -upr -x CVS usr.sbin/pmccontrol.freebsd/pmccontrol.c usr.sbin/pmccontrol/pmccontrol.c
--- usr.sbin/pmccontrol.freebsd/pmccontrol.c
+++ usr.sbin/pmccontrol/pmccontrol.c
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.sbin/pmccontrol/pmccontrol.c,v 1.6 2006-02-27 14:25:32 jkoshy Exp $");
+/*__FBSDID("$FreeBSD: src/usr.sbin/pmccontrol/pmccontrol.c,v 1.6 2006-02-27 14:25:32 jkoshy Exp $");*/
 
 #include <sys/types.h>
 #include <sys/queue.h>
diff -upr -x CVS usr.sbin/pmcstat.freebsd/pmcstat.c usr.sbin/pmcstat/pmcstat.c
--- usr.sbin/pmcstat.freebsd/pmcstat.c
+++ usr.sbin/pmcstat/pmcstat.c
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.sbin/pmcstat/pmcstat.c,v 1.17 2007-04-27 12:09:31 jkoshy Exp $");
+/*__FBSDID("$FreeBSD: src/usr.sbin/pmcstat/pmcstat.c,v 1.17 2007-04-27 12:09:31 jkoshy Exp $");*/
 
 #include <sys/types.h>
 #include <sys/event.h>
@@ -139,7 +139,7 @@ pmcstat_cleanup(struct pmcstat_args *a)
 	struct pmcstat_ev *ev, *tmp;
 
 	/* release allocated PMCs. */
-	STAILQ_FOREACH_SAFE(ev, &a->pa_events, ev_next, tmp)
+	STAILQ_FOREACH_MUTABLE(ev, &a->pa_events, ev_next, tmp)
 	    if (ev->ev_pmcid != PMC_ID_INVALID) {
 		if (pmc_release(ev->ev_pmcid) < 0)
 			err(EX_OSERR, "ERROR: cannot release pmc "
@@ -278,7 +278,7 @@ pmcstat_find_targets(struct pmcstat_args
 		    errbuf)) == NULL)
 			err(EX_OSERR, "ERROR: Cannot open kernel \"%s\"",
 			    errbuf);
-		if ((pmcstat_plist = kvm_getprocs(pmcstat_kvm, KERN_PROC_PROC,
+		if ((pmcstat_plist = kvm_getprocs(pmcstat_kvm, KERN_PROC_ALL,
 		    0, &nproc)) == NULL)
 			err(EX_OSERR, "ERROR: Cannot get process list: %s",
 			    kvm_geterr(pmcstat_kvm));
@@ -291,10 +291,10 @@ pmcstat_find_targets(struct pmcstat_args
 	}
 
 	for (n = 0, kp = pmcstat_plist; n < nproc; n++, kp++) {
-		if ((rv = regexec(&reg, kp->ki_comm, 1, &regmatch, 0)) == 0) {
+		if ((rv = regexec(&reg, kp->kp_comm, 1, &regmatch, 0)) == 0) {
 			if ((pt = malloc(sizeof(*pt))) == NULL)
 				goto outofmemory;
-			pt->pt_pid = kp->ki_pid;
+			pt->pt_pid = kp->kp_pid;
 			SLIST_INSERT_HEAD(&a->pa_targets, pt, pt_next);
 		} else if (rv != REG_NOMATCH) {
 			regerror(rv, &reg, errbuf, sizeof(errbuf));
diff -upr -x CVS usr.sbin/pmcstat.freebsd/pmcstat_log.c usr.sbin/pmcstat/pmcstat_log.c
--- usr.sbin/pmcstat.freebsd/pmcstat_log.c
+++ usr.sbin/pmcstat/pmcstat_log.c
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.sbin/pmcstat/pmcstat_log.c,v 1.10 2006-04-05 15:12:25 jkoshy Exp $");
+/*__FBSDID("$FreeBSD: src/usr.sbin/pmcstat/pmcstat_log.c,v 1.10 2006-04-05 15:12:25 jkoshy Exp $");*/
 
 #include <sys/param.h>
 #include <sys/endian.h>
@@ -411,7 +411,7 @@ pmcstat_string_shutdown(void)
 	struct pmcstat_string *ps, *pstmp;
 
 	for (i = 0; i < PMCSTAT_NHASH; i++)
-		LIST_FOREACH_SAFE(ps, &pmcstat_string_hash[i], ps_next,
+		LIST_FOREACH_MUTABLE(ps, &pmcstat_string_hash[i], ps_next,
 		    pstmp) {
 			LIST_REMOVE(ps, ps_next);
 			free(ps->ps_string);
@@ -444,7 +444,6 @@ pmcstat_gmon_create_file(struct pmcstat_
 	    sizeof(struct gmonhdr);
 	gm.version = GMONVERSION;
 	gm.profrate = 0;		/* use ticks */
-	gm.histcounter_type = 0;	/* compatibility with moncontrol() */
 	gm.spare[0] = gm.spare[1] = 0;
 
 	/* Write out the gmon header */
@@ -689,9 +688,9 @@ pmcstat_image_get_elf_params(struct pmcs
 	} while (0)
 
 	switch (h->e_machine) {
+#if	defined(__amd64__)
 	case EM_386:
 	case EM_486:
-#if	defined(__amd64__)
 		/* a 32 bit executable */
 		h32 = (const Elf32_Ehdr *) h;
 		sh32 = (const Elf32_Shdr *)((uintptr_t) mapbase + h32->e_shoff);
@@ -1013,7 +1012,7 @@ pmcstat_image_unmap(struct pmcstat_proce
 	 *   middle of a pcmap; in this case shorten the entry.
 	 */
 
-	TAILQ_FOREACH_SAFE(pcm, &pp->pp_map, ppm_next, pcmtmp) {
+	TAILQ_FOREACH_MUTABLE(pcm, &pp->pp_map, ppm_next, pcmtmp) {
 		assert(pcm->ppm_lowpc < pcm->ppm_highpc);
 		if (pcm->ppm_highpc <= start)
 			continue;
@@ -1223,12 +1222,12 @@ pmcstat_process_lookup(pid_t pid, int al
 
 	hash = (uint32_t) pid & PMCSTAT_HASH_MASK;	/* simplicity wins */
 
-	LIST_FOREACH_SAFE(pp, &pmcstat_process_hash[hash], pp_next, pptmp)
+	LIST_FOREACH_MUTABLE(pp, &pmcstat_process_hash[hash], pp_next, pptmp)
 	    if (pp->pp_pid == pid) {
 		    /* Found a descriptor, check and process zombies */
 		    if (allocate && pp->pp_isactive == 0) {
 			    /* remove maps */
-			    TAILQ_FOREACH_SAFE(ppm, &pp->pp_map, ppm_next,
+			    TAILQ_FOREACH_MUTABLE(ppm, &pp->pp_map, ppm_next,
 				ppmtmp) {
 				    TAILQ_REMOVE(&pp->pp_map, ppm, ppm_next);
 				    free(ppm);
@@ -1434,7 +1433,7 @@ pmcstat_convert_log(struct pmcstat_args 
 			    PMCSTAT_ALLOCATE);
 
 			/* delete the current process map */
-			TAILQ_FOREACH_SAFE(ppm, &pp->pp_map, ppm_next, ppmtmp) {
+			TAILQ_FOREACH_MUTABLE(ppm, &pp->pp_map, ppm_next, ppmtmp) {
 				TAILQ_REMOVE(&pp->pp_map, ppm, ppm_next);
 				free(ppm);
 			}
@@ -1799,7 +1798,7 @@ pmcstat_shutdown_logging(struct pmcstat_
 		(void) fprintf(mf, "MAP:\n");
 
 	for (i = 0; i < PMCSTAT_NHASH; i++) {
-		LIST_FOREACH_SAFE(pi, &pmcstat_image_hash[i], pi_next, pitmp) {
+		LIST_FOREACH_MUTABLE(pi, &pmcstat_image_hash[i], pi_next, pitmp) {
 
 			if (mf)
 				(void) fprintf(mf, " \"%s\" => \"%s\"",
@@ -1807,7 +1806,7 @@ pmcstat_shutdown_logging(struct pmcstat_
 				    pmcstat_string_unintern(pi->pi_samplename));
 
 			/* flush gmon.out data to disk */
-			LIST_FOREACH_SAFE(pgf, &pi->pi_gmlist, pgf_next,
+			LIST_FOREACH_MUTABLE(pgf, &pi->pi_gmlist, pgf_next,
 			    pgftmp) {
 				pmcstat_gmon_unmap_file(pgf);
 			    	LIST_REMOVE(pgf, pgf_next);
@@ -1829,7 +1828,7 @@ pmcstat_shutdown_logging(struct pmcstat_
 			LIST_REMOVE(pi, pi_next);
 			free(pi);
 		}
-		LIST_FOREACH_SAFE(pp, &pmcstat_process_hash[i], pp_next,
+		LIST_FOREACH_MUTABLE(pp, &pmcstat_process_hash[i], pp_next,
 		    pptmp) {
 			LIST_REMOVE(pp, pp_next);
 			free(pp);





More information about the Submit mailing list