diff options
author | Jim Wilson <wilson@gcc.gnu.org> | 1995-11-29 19:03:54 -0800 |
---|---|---|
committer | Jim Wilson <wilson@gcc.gnu.org> | 1995-11-29 19:03:54 -0800 |
commit | 6156580d2ebc5c4fb264173651d80bd45a645c27 (patch) | |
tree | 9e772bf93f8bac90e34404ea2bb4d96755760af9 /gcc | |
parent | 8b8def46d617422f5704092a2c92bbbbe2d3b629 (diff) | |
download | gcc-6156580d2ebc5c4fb264173651d80bd45a645c27.zip gcc-6156580d2ebc5c4fb264173651d80bd45a645c27.tar.gz gcc-6156580d2ebc5c4fb264173651d80bd45a645c27.tar.bz2 |
(_mcleanup): Add support for PROFDIR environment variable.
From-SVN: r10637
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/config/sparc/gmon-sol2.c | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/gcc/config/sparc/gmon-sol2.c b/gcc/config/sparc/gmon-sol2.c index ba1549b..9b41c64 100644 --- a/gcc/config/sparc/gmon-sol2.c +++ b/gcc/config/sparc/gmon-sol2.c @@ -39,11 +39,11 @@ static char sccsid[] = "@(#)gmon.c 5.3 (Berkeley) 5/22/91"; #endif /* not lint */ -#include <unistd.h> - -#ifdef DEBUG #include <stdio.h> -#endif +#include <stdlib.h> +#include <string.h> +#include <limits.h> +#include <unistd.h> #if 0 #include "sparc/gmon.h" @@ -172,6 +172,7 @@ monstartup(lowpc, highpc) moncontrol(1); } +void _mcleanup() { int fd; @@ -180,11 +181,35 @@ _mcleanup() char *frompc; int toindex; struct rawarc rawarc; + char *profdir; + char *proffile; + char *progname; + char buf[PATH_MAX]; + extern char **___Argv; moncontrol(0); - fd = creat( "gmon.out" , 0666 ); + + if ((profdir = getenv("PROFDIR")) != NULL) { + /* If PROFDIR contains a null value, no profiling output is produced */ + if (*profdir == '\0') { + return; + } + + progname=strrchr(___Argv[0], '/'); + if (progname == NULL) + progname=___Argv[0]; + else + progname++; + + sprintf(buf, "%s/%d.%s", profdir, getpid(), progname); + proffile = buf; + } else { + proffile = "gmon.out"; + } + + fd = creat( proffile, 0666 ); if ( fd < 0 ) { - perror( "mcount: gmon.out" ); + perror( proffile ); return; } # ifdef DEBUG |