From 3cade8d074f10ed4002c26e30494d70bb274b767 Mon Sep 17 00:00:00 2001 From: jkoshy Date: Thu, 30 Jun 2005 19:01:26 +0000 Subject: MFP4: - pmcstat(8) gprof output mode fixes: lib/libpmc/pmclog.{c,h}, sys/sys/pmclog.h: + Add a 'is_usermode' field to the PMCLOG_PCSAMPLE event + Add an 'entryaddr' field to the PMCLOG_PROCEXEC event, so that pmcstat(8) can determine where the runtime loader /libexec/ld-elf.so.1 is getting loaded. sys/kern/kern_exec.c: + Use a local struct to group the entry address of the image being exec()'ed and the process credential changed flag to the exec handling hook inside hwpmc(4). usr.sbin/pmcstat/*: + Support "-k kernelpath", "-D sampledir". + Implement the ELF bits of 'gmon.out' profile generation in a new file "pmcstat_log.c". Move all log related functions to this file. + Move local definitions and prototypes to "pmcstat.h" - Other bug fixes: + lib/libpmc/pmclog.c: correctly handle EOF in pmclog_read(). + sys/dev/hwpmc_mod.c: unconditionally log a PROCEXIT event to all attached PMCs when a process exits. + sys/sys/pmc.h: correct a function prototype. + Improve usage checks in pmcstat(8). Approved by: re (blanket hwpmc) --- lib/libpmc/pmclog.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/libpmc/pmclog.c') diff --git a/lib/libpmc/pmclog.c b/lib/libpmc/pmclog.c index 8772c58..a6b70b5 100644 --- a/lib/libpmc/pmclog.c +++ b/lib/libpmc/pmclog.c @@ -334,6 +334,7 @@ pmclog_get_event(void *cookie, char **data, ssize_t *len, PMCLOG_READ32(le,ev->pl_u.pl_s.pl_pid); PMCLOG_READADDR(le,ev->pl_u.pl_s.pl_pc); PMCLOG_READ32(le,ev->pl_u.pl_s.pl_pmcid); + PMCLOG_READ32(le,ev->pl_u.pl_s.pl_usermode); break; case PMCLOG_TYPE_PMCALLOCATE: PMCLOG_READ32(le,ev->pl_u.pl_a.pl_pmcid); @@ -361,6 +362,8 @@ pmclog_get_event(void *cookie, char **data, ssize_t *len, case PMCLOG_TYPE_PROCEXEC: PMCLOG_GET_PATHLEN(pathlen,evlen,pmclog_procexec); PMCLOG_READ32(le,ev->pl_u.pl_x.pl_pid); + PMCLOG_READADDR(le,ev->pl_u.pl_x.pl_entryaddr); + PMCLOG_READ32(le,ev->pl_u.pl_x.pl_pmcid); PMCLOG_READSTRING(le,ev->pl_u.pl_x.pl_pathname,pathlen); break; case PMCLOG_TYPE_PROCEXIT: @@ -436,8 +439,10 @@ pmclog_read(void *cookie, struct pmclog_ev *ev) PMCLOG_BUFFER_SIZE); if (nread <= 0) { - ev->pl_state = nread < 0 ? PMCLOG_ERROR : - PMCLOG_EOF; + if (nread == 0) + ev->pl_state = PMCLOG_EOF; + else if (errno != EAGAIN) /* not restartable */ + ev->pl_state = PMCLOG_ERROR; return -1; } -- cgit v1.1