Change the profile data file name from gmon.out to progname.gmon

where progname comes from __progname in crt0 or crt1.
This commit is contained in:
John Birrell 1998-09-05 07:56:36 +00:00
parent a4abb1d062
commit 683728f17d
2 changed files with 14 additions and 7 deletions

View File

@ -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",

View File

@ -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 ,