From owner-svn-src-stable-8@FreeBSD.ORG Sun May 6 14:11:51 2012 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C899B1065670; Sun, 6 May 2012 14:11:51 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B2B818FC0C; Sun, 6 May 2012 14:11:51 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q46EBpVd017301; Sun, 6 May 2012 14:11:51 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q46EBpCD017298; Sun, 6 May 2012 14:11:51 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201205061411.q46EBpCD017298@svn.freebsd.org> From: Eitan Adler Date: Sun, 6 May 2012 14:11:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235084 - stable/8/lib/libc/gmon X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 May 2012 14:11:51 -0000 Author: eadler Date: Sun May 6 14:11:51 2012 New Revision: 235084 URL: http://svn.freebsd.org/changeset/base/235084 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/8/lib/libc/gmon/gmon.c stable/8/lib/libc/gmon/moncontrol.3 Directory Properties: stable/8/lib/libc/ (props changed) Modified: stable/8/lib/libc/gmon/gmon.c ============================================================================== --- stable/8/lib/libc/gmon/gmon.c Sun May 6 14:11:25 2012 (r235083) +++ stable/8/lib/libc/gmon/gmon.c Sun May 6 14:11:51 2012 (r235084) @@ -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/8/lib/libc/gmon/moncontrol.3 ============================================================================== --- stable/8/lib/libc/gmon/moncontrol.3 Sun May 6 14:11:25 2012 (r235083) +++ stable/8/lib/libc/gmon/moncontrol.3 Sun May 6 14:11:51 2012 (r235084) @@ -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