From peterjeremy@optushome.com.au  Wed Jul  5 09:29:03 2006
Return-Path: <peterjeremy@optushome.com.au>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 5FA4116A4DA
	for <FreeBSD-gnats-submit@freebsd.org>; Wed,  5 Jul 2006 09:29:03 +0000 (UTC)
	(envelope-from peterjeremy@optushome.com.au)
Received: from mail12.syd.optusnet.com.au (mail12.syd.optusnet.com.au [211.29.132.193])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 22D4843D53
	for <FreeBSD-gnats-submit@freebsd.org>; Wed,  5 Jul 2006 09:29:01 +0000 (GMT)
	(envelope-from peterjeremy@optushome.com.au)
Received: from turion.vk2pj.dyndns.org (c220-239-19-236.belrs4.nsw.optusnet.com.au [220.239.19.236])
	by mail12.syd.optusnet.com.au (8.12.11/8.12.11) with ESMTP id k659SxgY014398
	(version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO)
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 5 Jul 2006 19:29:00 +1000
Received: from turion.vk2pj.dyndns.org (localhost.vk2pj.dyndns.org [127.0.0.1])
	by turion.vk2pj.dyndns.org (8.13.6/8.13.6) with ESMTP id k659SxQM001308
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 5 Jul 2006 19:28:59 +1000 (EST)
	(envelope-from peter@turion.vk2pj.dyndns.org)
Received: (from peter@localhost)
	by turion.vk2pj.dyndns.org (8.13.6/8.13.6/Submit) id k659Sxrn001307;
	Wed, 5 Jul 2006 19:28:59 +1000 (EST)
	(envelope-from peter)
Message-Id: <200607050928.k659Sxrn001307@turion.vk2pj.dyndns.org>
Date: Wed, 5 Jul 2006 19:28:59 +1000 (EST)
From: Peter Jeremy <peterjeremy@optushome.com.au>
Reply-To: Peter Jeremy <peterjeremy@optushome.com.au>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] Add support for profiling multiple executions
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         99800
>Category:       bin
>Synopsis:       [libc] [patch] Add support for profiling multiple executions
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    eadler
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jul 05 09:30:21 GMT 2006
>Closed-Date:    Sun May 06 14:24:33 UTC 2012
>Last-Modified:  Sun May 06 14:24:33 UTC 2012
>Originator:     Peter Jeremy
>Release:        FreeBSD 6.1-STABLE amd64
>Organization:
n/a
>Environment:
System: FreeBSD turion.vk2pj.dyndns.org 6.1-STABLE FreeBSD 6.1-STABLE #19: Tue Jul 4 17:56:20 EST 2006 root@turion.vk2pj.dyndns.org:/usr/obj/usr/src/sys/turion amd64

>Description:
	gprof(1) has support for merging multiple gmon.out files but
	the name 'NAME.gmon' is hard-wired in the profiling code and
	any existing NAME.gmon file is over-written.

	The patch below allows a process to create 'NAME.PID.gmon' by
	creating an enviroment variable "PROFIL_USE_PID".

>How-To-Repeat:
	Code inspection shows that NAME.gmon is hard-coded and truncated.
>Fix:
Index: lib/libc/gmon/gmon.c
===================================================================
RCS file: /usr/ncvs/src/lib/libc/gmon/gmon.c,v
retrieving revision 1.20
diff -u -r1.20 gmon.c
--- lib/libc/gmon/gmon.c	16 Oct 2004 06:32:43 -0000	1.20
+++ lib/libc/gmon/gmon.c	21 May 2006 19:11:14 -0000
@@ -174,7 +174,11 @@
 	}
 
 	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);
>Release-Note:
>Audit-Trail:

From: Peter Jeremy <peterjeremy@optushome.com.au>
To: FreeBSD-gnats-submit@FreeBSD.org, freebsd-bugs@FreeBSD.org
Cc:  
Subject: Re: bin/99800: [PATCH] Add support for profiling multiple
	executions
Date: Sat, 16 May 2009 08:32:06 +1000

 --XWOWbaMNXpFDWE00
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 This patch is still relevant and I believe it's useful.  Any chance
 of getting it into 8.0?
 
 --=20
 Peter Jeremy
 
 --XWOWbaMNXpFDWE00
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.11 (FreeBSD)
 
 iEYEARECAAYFAkoN7WYACgkQ/opHv/APuIc40gCdEicbPkDUJ9OOIRCbB+hKmSM0
 J7IAnR7a6c1P1ALuFXFGT4x5rWHcOBoi
 =Bq/G
 -----END PGP SIGNATURE-----
 
 --XWOWbaMNXpFDWE00--
Responsible-Changed-From-To: freebsd-bugs->eadler 
Responsible-Changed-By: eadler 
Responsible-Changed-When: Sun Mar 25 03:31:38 UTC 2012 
Responsible-Changed-Why:  
I'll take it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=99800 
State-Changed-From-To: open->analyzed 
State-Changed-By: eadler 
State-Changed-When: Tue Apr 10 01:40:03 UTC 2012 
State-Changed-Why:  
awaiting approval 

http://www.freebsd.org/cgi/query-pr.cgi?pr=99800 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/99800: commit references a PR
Date: Sun, 29 Apr 2012 22:20:18 +0000 (UTC)

 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
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: analyzed->patched 
State-Changed-By: eadler 
State-Changed-When: Sun Apr 29 22:31:34 UTC 2012 
State-Changed-Why:  
committed in r234819 

http://www.freebsd.org/cgi/query-pr.cgi?pr=99800 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/99800: commit references a PR
Date: Sun,  6 May 2012 14:11:15 +0000 (UTC)

 Author: eadler
 Date: Sun May  6 14:10:56 2012
 New Revision: 235082
 URL: http://svn.freebsd.org/changeset/base/235082
 
 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/9/lib/libc/gmon/gmon.c
   stable/9/lib/libc/gmon/moncontrol.3
 Directory Properties:
   stable/9/lib/libc/   (props changed)
 
 Modified: stable/9/lib/libc/gmon/gmon.c
 ==============================================================================
 --- stable/9/lib/libc/gmon/gmon.c	Sun May  6 13:09:13 2012	(r235081)
 +++ stable/9/lib/libc/gmon/gmon.c	Sun May  6 14:10:56 2012	(r235082)
 @@ -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: stable/9/lib/libc/gmon/moncontrol.3
 ==============================================================================
 --- stable/9/lib/libc/gmon/moncontrol.3	Sun May  6 13:09:13 2012	(r235081)
 +++ stable/9/lib/libc/gmon/moncontrol.3	Sun May  6 14:10:56 2012	(r235082)
 @@ -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
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/99800: commit references a PR
Date: Sun,  6 May 2012 14:11:33 +0000 (UTC)

 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
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/99800: commit references a PR
Date: Sun,  6 May 2012 14:12:08 +0000 (UTC)

 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
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: eadler 
State-Changed-When: Sun May 6 14:24:32 UTC 2012 
State-Changed-Why:  
Committed. Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=99800 
>Unformatted:
