From 7e74cac42ed3750633f384a5fb4529a6c986dab8 Mon Sep 17 00:00:00 2001 From: Jean-Marc Zucconi Date: Sun, 23 May 1999 00:37:56 +0000 Subject: [PATCH] Construct the profile file name from the name of the executable. A program compiled with -pg and run will generate a file .gmon, not gmon.out. PR: bin/8426 --- usr.bin/gprof/gprof.1 | 20 +++++++++----------- usr.bin/gprof/gprof.c | 6 ++++-- usr.bin/gprof/gprof.h | 1 - 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/usr.bin/gprof/gprof.1 b/usr.bin/gprof/gprof.1 index dc6f369e081..02eea626ef4 100644 --- a/usr.bin/gprof/gprof.1 +++ b/usr.bin/gprof/gprof.1 @@ -40,15 +40,13 @@ .Sh SYNOPSIS .Nm gprof .Op options -.Op Ar a.out Op Ar gmon.out ... +.Op Ar a.out Op Ar a.out.gmon ... .Sh DESCRIPTION .Nm Gprof produces an execution profile of C, Pascal, or Fortran77 programs. The effect of called routines is incorporated in the profile of each caller. The profile data is taken from the call graph profile file -.Pf ( Pa gmon.out -default) which is created by programs -that are compiled with the +which is created by programs that are compiled with the .Fl pg option of .Xr cc 1 , @@ -63,8 +61,10 @@ that are compiled for profiling. reads the given object file (the default is .Pa a.out) and establishes the relation between it's symbol table -and the call graph profile from -.Pa gmon.out . +and the call graph profile. The default graph profile file name is the name +of the executable with the suffix +.Pa .gmon +appended. If more than one profile file is specified, the .Nm gprof @@ -231,10 +231,10 @@ This is useful with the option for discovering which routines were never called. .El .Sh FILES -.Bl -tag -width gmon.sum -compact +.Bl -tag -width a.out.gmon -compact .It Pa a.out The namelist and text space. -.It Pa gmon.out +.It Pa a.out.gmon Dynamic call graph and profile. .It Pa gmon.sum Summarized dynamic call graph and profile. @@ -295,6 +295,4 @@ the execution of the profiling routine, in which case all is lost. The profiled program must call .Xr exit 3 or return normally for the profiling information to be saved -in the -.Pa gmon.out -file. +in the graph profile file. diff --git a/usr.bin/gprof/gprof.c b/usr.bin/gprof/gprof.c index 0d4d63f7af2..a5c61403889 100644 --- a/usr.bin/gprof/gprof.c +++ b/usr.bin/gprof/gprof.c @@ -42,7 +42,7 @@ static const char copyright[] = static char sccsid[] = "@(#)gprof.c 8.1 (Berkeley) 6/6/93"; #endif static const char rcsid[] = - "$Id: gprof.c,v 1.7 1998/08/08 17:48:26 jdp Exp $"; + "$Id: gprof.c,v 1.8 1998/09/07 23:31:59 jdp Exp $"; #endif /* not lint */ #include @@ -155,7 +155,9 @@ main(argc, argv) gmonname = *argv; argv++; } else { - gmonname = GMONNAME; + gmonname = (char *) malloc(strlen(a_outname)+6); + strcpy(gmonname, a_outname); + strcat(gmonname, ".gmon"); } /* * get information from the executable file. diff --git a/usr.bin/gprof/gprof.h b/usr.bin/gprof/gprof.h index ce164d55a57..e42647300a9 100644 --- a/usr.bin/gprof/gprof.h +++ b/usr.bin/gprof/gprof.h @@ -84,7 +84,6 @@ char *a_outname; #define A_OUTNAME "a.out" char *gmonname; -#define GMONNAME "gmon.out" #define GMONSUM "gmon.sum" /* -- 2.45.2