aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/pmcstat
diff options
context:
space:
mode:
authorSimon J. Gerraty <sjg@FreeBSD.org>2015-05-27 01:19:58 +0000
committerSimon J. Gerraty <sjg@FreeBSD.org>2015-05-27 01:19:58 +0000
commit98e0ffaefb0f241cda3a72395d3be04192ae0d47 (patch)
tree55c065b6730aaac2afb6c29933ee6ec5fa4c4249 /usr.sbin/pmcstat
parentb17ff922d4072ae132ece458f5b5d74a236880ac (diff)
parente81032ad243db32b8fd615b2d55ee94b9f6a5b6a (diff)
downloadsrc-98e0ffaefb0f241cda3a72395d3be04192ae0d47.tar.gz
src-98e0ffaefb0f241cda3a72395d3be04192ae0d47.zip
Merge sync of head
Notes
Notes: svn path=/projects/bmake/; revision=283595
Diffstat (limited to 'usr.sbin/pmcstat')
-rw-r--r--usr.sbin/pmcstat/Makefile3
-rw-r--r--usr.sbin/pmcstat/pmcstat.815
-rw-r--r--usr.sbin/pmcstat/pmcstat.c61
-rw-r--r--usr.sbin/pmcstat/pmcstat_log.c7
4 files changed, 50 insertions, 36 deletions
diff --git a/usr.sbin/pmcstat/Makefile b/usr.sbin/pmcstat/Makefile
index 78cde444948e..dc5a30a40003 100644
--- a/usr.sbin/pmcstat/Makefile
+++ b/usr.sbin/pmcstat/Makefile
@@ -5,8 +5,7 @@
PROG= pmcstat
MAN= pmcstat.8
-DPADD= ${LIBELF} ${LIBKVM} ${LIBPMC} ${LIBM} ${LIBNCURSESW}
-LDADD= -lelf -lkvm -lpmc -lm -lncursesw
+LIBADD= elf kvm pmc m ncursesw
SRCS= pmcstat.c pmcstat.h pmcstat_log.c \
pmcpl_callgraph.c pmcpl_gprof.c pmcpl_annotate.c \
diff --git a/usr.sbin/pmcstat/pmcstat.8 b/usr.sbin/pmcstat/pmcstat.8
index d34cb6bd2087..647824101cbc 100644
--- a/usr.sbin/pmcstat/pmcstat.8
+++ b/usr.sbin/pmcstat/pmcstat.8
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd Oct 27, 2014
+.Dd May 8, 2015
.Dt PMCSTAT 8
.Os
.Sh NAME
@@ -236,7 +236,7 @@ This option requires the
.Fl R
option to read in samples that were previously collected and
saved with the
-.Fl o
+.Fl O
option.
.It Fl c Ar cpu-spec
Set the cpus for subsequent system mode PMCs specified on the
@@ -279,8 +279,9 @@ Set the pathname of the kernel directory to argument
This directory specifies where
.Nm
should look for the kernel and its modules.
-The default is
-.Pa /boot/kernel .
+The default is to use the path of the running kernel obtained from the
+.Va kern.bootfile
+sysctl.
.It Fl l Ar secs
Set system-wide performance measurement duration for
.Ar secs
@@ -301,6 +302,12 @@ is a
this information is sent to the output file specified by the
.Fl o
option.
+This option requires the
+.Fl R
+option to read in samples that were previously collected and
+saved with the
+.Fl O
+option.
.It Fl n Ar rate
Set the default sampling rate for subsequent sampling mode
PMCs specified on the command line.
diff --git a/usr.sbin/pmcstat/pmcstat.c b/usr.sbin/pmcstat/pmcstat.c
index a045706dda13..c7f36bc6f26a 100644
--- a/usr.sbin/pmcstat/pmcstat.c
+++ b/usr.sbin/pmcstat/pmcstat.c
@@ -557,7 +557,7 @@ main(int argc, char **argv)
int c, check_driver_stats, current_sampling_count;
int do_callchain, do_descendants, do_logproccsw, do_logprocexit;
int do_print, do_read;
- size_t dummy;
+ size_t len;
int graphdepth;
int pipefd[2], rfd;
int use_cumulative_counts;
@@ -586,7 +586,6 @@ main(int argc, char **argv)
args.pa_verbosity = 1;
args.pa_logfd = -1;
args.pa_fsroot = "";
- args.pa_kernel = strdup("/boot/kernel");
args.pa_samplesdir = ".";
args.pa_printfile = stderr;
args.pa_graphdepth = DEFAULT_CALLGRAPH_DEPTH;
@@ -610,12 +609,20 @@ main(int argc, char **argv)
ev = NULL;
CPU_ZERO(&cpumask);
+ /* Default to using the running system kernel. */
+ len = 0;
+ if (sysctlbyname("kern.bootfile", NULL, &len, NULL, 0) == -1)
+ err(EX_OSERR, "ERROR: Cannot determine path of running kernel");
+ args.pa_kernel = malloc(len + 1);
+ if (sysctlbyname("kern.bootfile", args.pa_kernel, &len, NULL, 0) == -1)
+ err(EX_OSERR, "ERROR: Cannot determine path of running kernel");
+
/*
* The initial CPU mask specifies all non-halted CPUS in the
* system.
*/
- dummy = sizeof(int);
- if (sysctlbyname("hw.ncpu", &ncpu, &dummy, NULL, 0) < 0)
+ len = sizeof(int);
+ if (sysctlbyname("hw.ncpu", &ncpu, &len, NULL, 0) < 0)
err(EX_OSERR, "ERROR: Cannot determine the number of CPUs");
for (hcpu = 0; hcpu < ncpu; hcpu++)
CPU_SET(hcpu, &cpumask);
@@ -940,7 +947,7 @@ main(int argc, char **argv)
errx(EX_USAGE, "ERROR: options -T and -l are mutually "
"exclusive.");
- /* -m option is allowed with -R only. */
+ /* -a and -m require -R */
if (args.pa_flags & FLAG_DO_ANNOTATE && args.pa_inputpath == NULL)
errx(EX_USAGE, "ERROR: option %s requires an input file",
args.pa_plugin == PMCSTAT_PL_ANNOTATE ? "-m" : "-a");
@@ -1061,33 +1068,31 @@ main(int argc, char **argv)
);
/*
- * Check if "-k kerneldir" was specified, and if whether
- * 'kerneldir' actually refers to a file. If so, use
- * `dirname path` to determine the kernel directory.
+ * Check if 'kerneldir' refers to a file rather than a
+ * directory. If so, use `dirname path` to determine the
+ * kernel directory.
*/
- if (args.pa_flags & FLAG_HAS_KERNELPATH) {
- (void) snprintf(buffer, sizeof(buffer), "%s%s", args.pa_fsroot,
- args.pa_kernel);
+ (void) snprintf(buffer, sizeof(buffer), "%s%s", args.pa_fsroot,
+ args.pa_kernel);
+ if (stat(buffer, &sb) < 0)
+ err(EX_OSERR, "ERROR: Cannot locate kernel \"%s\"",
+ buffer);
+ if (!S_ISREG(sb.st_mode) && !S_ISDIR(sb.st_mode))
+ errx(EX_USAGE, "ERROR: \"%s\": Unsupported file type.",
+ buffer);
+ if (!S_ISDIR(sb.st_mode)) {
+ tmp = args.pa_kernel;
+ args.pa_kernel = strdup(dirname(args.pa_kernel));
+ free(tmp);
+ (void) snprintf(buffer, sizeof(buffer), "%s%s",
+ args.pa_fsroot, args.pa_kernel);
if (stat(buffer, &sb) < 0)
- err(EX_OSERR, "ERROR: Cannot locate kernel \"%s\"",
+ err(EX_OSERR, "ERROR: Cannot stat \"%s\"",
buffer);
- if (!S_ISREG(sb.st_mode) && !S_ISDIR(sb.st_mode))
- errx(EX_USAGE, "ERROR: \"%s\": Unsupported file type.",
+ if (!S_ISDIR(sb.st_mode))
+ errx(EX_USAGE,
+ "ERROR: \"%s\" is not a directory.",
buffer);
- if (!S_ISDIR(sb.st_mode)) {
- tmp = args.pa_kernel;
- args.pa_kernel = strdup(dirname(args.pa_kernel));
- free(tmp);
- (void) snprintf(buffer, sizeof(buffer), "%s%s",
- args.pa_fsroot, args.pa_kernel);
- if (stat(buffer, &sb) < 0)
- err(EX_OSERR, "ERROR: Cannot stat \"%s\"",
- buffer);
- if (!S_ISDIR(sb.st_mode))
- errx(EX_USAGE,
- "ERROR: \"%s\" is not a directory.",
- buffer);
- }
}
/*
diff --git a/usr.sbin/pmcstat/pmcstat_log.c b/usr.sbin/pmcstat/pmcstat_log.c
index 40de320f17a1..fbc358d6129d 100644
--- a/usr.sbin/pmcstat/pmcstat_log.c
+++ b/usr.sbin/pmcstat/pmcstat_log.c
@@ -716,7 +716,8 @@ pmcstat_image_get_elf_params(struct pmcstat_image *image)
ph.p_offset);
break;
case PT_LOAD:
- if ((ph.p_offset & (-ph.p_align)) == 0)
+ if ((ph.p_flags & PF_X) != 0 &&
+ (ph.p_offset & (-ph.p_align)) == 0)
image->pi_vaddr = ph.p_vaddr & (-ph.p_align);
break;
}
@@ -1531,7 +1532,9 @@ pmcstat_analyze_log(void)
free(ppm);
}
- /* associate this process image */
+ /*
+ * Associate this process image.
+ */
image_path = pmcstat_string_intern(
ev.pl_u.pl_x.pl_pathname);
assert(image_path != NULL);