Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 29 Apr 2012 22:19:58 +0000 (UTC)
From:      Eitan Adler <eadler@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r234819 - head/lib/libc/gmon
Message-ID:  <201204292219.q3TMJwkw035078@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: eadler
Date: Sun Apr 29 22:19:58 2012
New Revision: 234819
URL: http://svn.freebsd.org/changeset/base/234819

Log:
  Allow users of gprof to get per run output files (using the pid)
  
  PR:		bin/99800
  Submitted by:	Peter Jeremy <peterjeremy@optushome.com.au>
  Reviewed by:	jilles (code)
  Reviewed by:	dwhite (doc)
  Approved by:	cperciva
  MFC after:	1 week

Modified:
  head/lib/libc/gmon/gmon.c
  head/lib/libc/gmon/moncontrol.3

Modified: head/lib/libc/gmon/gmon.c
==============================================================================
--- head/lib/libc/gmon/gmon.c	Sun Apr 29 22:01:23 2012	(r234818)
+++ head/lib/libc/gmon/gmon.c	Sun Apr 29 22:19:58 2012	(r234819)
@@ -157,7 +157,12 @@ _mcleanup(void)
 	}
 
 	moncontrol(0);
-	snprintf(outname, sizeof(outname), "%s.gmon", _getprogname());
+	if (getenv("PROFIL_USE_PID"))
+		snprintf(outname, sizeof(outname), "%s.%d.gmon",
+		    _getprogname(), getpid());
+	else
+		snprintf(outname, sizeof(outname), "%s.gmon", _getprogname());
+
 	fd = _open(outname, O_CREAT|O_TRUNC|O_WRONLY, 0666);
 	if (fd < 0) {
 		_warn("_mcleanup: %s", outname);

Modified: head/lib/libc/gmon/moncontrol.3
==============================================================================
--- head/lib/libc/gmon/moncontrol.3	Sun Apr 29 22:01:23 2012	(r234818)
+++ head/lib/libc/gmon/moncontrol.3	Sun Apr 29 22:19:58 2012	(r234819)
@@ -98,6 +98,12 @@ however, all functions in that address r
 have their execution time measured.
 Profiling begins on return from
 .Fn monstartup .
+.Sh ENVIRONMENT
+The following environment variables affect the execution of
+.Nm :
+.Bl -tag -width ".Ev PROFIL_USE_PID"
+.It PROFIL_USE_PID
+If set, the pid of the process is inserted into the filename.
 .Sh FILES
 .Bl -tag -width progname.gmon -compact
 .It Pa progname.gmon



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201204292219.q3TMJwkw035078>