diff options
| author | John Birrell <jb@FreeBSD.org> | 1998-09-05 07:56:36 +0000 |
|---|---|---|
| committer | John Birrell <jb@FreeBSD.org> | 1998-09-05 07:56:36 +0000 |
| commit | 683728f17df00631d446d9dd5f49a622989203f2 (patch) | |
| tree | e443365eb54481062357b3ffc28e2475cb98fb63 /lib/libc | |
| parent | a4abb1d06254ed55ca6e6b86e3da31504b92ac63 (diff) | |
Notes
Diffstat (limited to 'lib/libc')
| -rw-r--r-- | lib/libc/gmon/gmon.c | 15 | ||||
| -rw-r--r-- | lib/libc/gmon/moncontrol.3 | 6 |
2 files changed, 14 insertions, 7 deletions
diff --git a/lib/libc/gmon/gmon.c b/lib/libc/gmon/gmon.c index a0f0036009c9..f477822f08cf 100644 --- a/lib/libc/gmon/gmon.c +++ b/lib/libc/gmon/gmon.c @@ -35,12 +35,15 @@ static char sccsid[] = "@(#)gmon.c 8.1 (Berkeley) 6/4/93"; #endif -#ifndef __NETBSD_SYSCALLS +#ifndef __alpha__ + #include <sys/param.h> #include <sys/time.h> #include <sys/gmon.h> #include <sys/sysctl.h> +#include <err.h> +#include <errno.h> #include <stdio.h> #include <fcntl.h> #include <unistd.h> @@ -51,6 +54,8 @@ extern char *minbrk asm (".minbrk"); extern char *minbrk asm ("minbrk"); #endif +extern char *__progname; + struct gmonparam _gmonparam = { GMON_PROF_OFF }; static int s_scale; @@ -139,6 +144,7 @@ _mcleanup() struct gmonparam *p = &_gmonparam; struct gmonhdr gmonhdr, *hdr; struct clockinfo clockinfo; + char outname[128]; int mib[2]; size_t size; #ifdef DEBUG @@ -165,15 +171,16 @@ _mcleanup() } moncontrol(0); - fd = open("gmon.out", O_CREAT|O_TRUNC|O_WRONLY, 0666); + snprintf(outname,sizeof(outname),"%s.gmon",__progname); + fd = open(outname, O_CREAT|O_TRUNC|O_WRONLY, 0666); if (fd < 0) { - perror("mcount: gmon.out"); + warnx("_mcleanup: %s - %s",outname,strerror(errno)); return; } #ifdef DEBUG log = open("gmon.log", O_CREAT|O_TRUNC|O_WRONLY, 0664); if (log < 0) { - perror("mcount: gmon.log"); + perror("_mcleanup: gmon.log"); return; } len = sprintf(buf, "[mcleanup1] kcount 0x%x ssiz %d\n", diff --git a/lib/libc/gmon/moncontrol.3 b/lib/libc/gmon/moncontrol.3 index 92993cd3bbfe..a35389f58d8e 100644 --- a/lib/libc/gmon/moncontrol.3 +++ b/lib/libc/gmon/moncontrol.3 @@ -55,8 +55,8 @@ call-graph execution profiler. In typical operation, profiling begins at program startup and ends when the program calls exit. When the program exits, the profiling data are written to the file -.Em gmon.out , -then +.Em progname.gmon , +where progname is the name of the program, then .Xr gprof 1 can be used to examine the results. .Pp @@ -96,7 +96,7 @@ Profiling begins on return from .Fn monstartup . .Sh FILES .Bl -tag -width Pa -compact -.It Pa gmon.out execution data file +.It Pa progname.gmon execution data file .El .Sh SEE ALSO .Xr cc 1 , |
