Date: Sun, 6 May 2012 14:11:25 +0000 (UTC) From: Eitan Adler <eadler@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org Subject: svn commit: r235083 - stable/7/lib/libc/gmon Message-ID: <201205061411.q46EBP4J017251@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: eadler Date: Sun May 6 14:11:25 2012 New Revision: 235083 URL: http://svn.freebsd.org/changeset/base/235083 Log: MFC r234819: Allow users of gprof to get per run output files (using the pid) PR: bin/99800 Approved by: cperciva (implicit) Modified: stable/7/lib/libc/gmon/gmon.c stable/7/lib/libc/gmon/moncontrol.3 Directory Properties: stable/7/lib/libc/ (props changed) Modified: stable/7/lib/libc/gmon/gmon.c ============================================================================== --- stable/7/lib/libc/gmon/gmon.c Sun May 6 14:10:56 2012 (r235082) +++ stable/7/lib/libc/gmon/gmon.c Sun May 6 14:11:25 2012 (r235083) @@ -170,7 +170,12 @@ _mcleanup() } 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: stable/7/lib/libc/gmon/moncontrol.3 ============================================================================== --- stable/7/lib/libc/gmon/moncontrol.3 Sun May 6 14:10:56 2012 (r235082) +++ stable/7/lib/libc/gmon/moncontrol.3 Sun May 6 14:11:25 2012 (r235083) @@ -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?201205061411.q46EBP4J017251>