bin/99800: [PATCH] Add support for profiling multiple executions

Peter Jeremy peterjeremy at optushome.com.au
Wed Jul 5 09:30:24 UTC 2006


>Number:         99800
>Category:       bin
>Synopsis:       [PATCH] Add support for profiling multiple executions
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jul 05 09:30:21 GMT 2006
>Closed-Date:
>Last-Modified:
>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 at 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:
>Unformatted:


More information about the freebsd-bugs mailing list