[7370] in Athena Bugs

home help back first fref pref prev next nref lref last post

suggestion for gmon.c

daemon@ATHENA.MIT.EDU (Ken Raeburn)
Fri Mar 29 06:20:06 1991

Date: Fri, 29 Mar 91 06:19:55 EST
From: Ken Raeburn <Raeburn@MIT.Edu>
To: bugs@ATHENA.MIT.EDU

This change defines a global variable __gmon_filename into which a program
can write the desired pathname for the gmon.out file that will be
generated from running it.

This can useful when installing a version of a program with profiling
enabled, and trying to gather lots of profiling data from lots of people
running the program.  For example, I could hack /mit/zephyr/*bin/zwgc to
dump out profiling data into
/mit/zephyr/gmon/zwgc.<machtype>.<host>.<date>.

I sent out a description of it to athena-ws a couple of years or so
ago, and got some interest.

I've also deleted a couple of initializations of variables to zero;
they might as well go in the bss section.

*** /source/bsd-4.3/vax/lib/libc/vax/csu/gmon.c	Wed Nov 18 03:42:10 1987
--- gmon.c	Fri Mar 29 06:04:57 1991
***************
*** 9,16 ****
  #endif LIBC_SCCS and not lint
  
- #ifdef DEBUG
  #include <stdio.h>
- #endif DEBUG
- 
  #include "gmon.h"
  
--- 9,13 ----
***************
*** 20,28 ****
  static int		profiling = 3;
  static unsigned short	*froms;
! static struct tostruct	*tos = 0;
! static long		tolimit = 0;
! static char		*s_lowpc = 0;
! static char		*s_highpc = 0;
! static unsigned long	s_textsize = 0;
  
  static int	ssiz;
--- 17,25 ----
  static int		profiling = 3;
  static unsigned short	*froms;
! static struct tostruct	*tos;
! static long		tolimit;
! static char		*s_lowpc;
! static char		*s_highpc;
! static unsigned long	s_textsize;
  
  static int	ssiz;
***************
*** 34,37 ****
--- 31,37 ----
  #define	MSG "No space for monitor buffer(s)\n"
  
+ #include <sys/param.h>
+ char __gmon_filename[MAXPATHLEN];
+ 
  monstartup(lowpc, highpc)
      char	*lowpc;
***************
*** 86,89 ****
--- 86,90 ----
  _mcleanup()
  {
+     char		*filename;
      int			fd;
      int			fromindex;
***************
*** 93,97 ****
      struct rawarc	rawarc;
  
!     fd = creat( "gmon.out" , 0666 );
      if ( fd < 0 ) {
  	perror( "mcount: gmon.out" );
--- 94,99 ----
      struct rawarc	rawarc;
  
!     filename = __gmon_filename[0] ? __gmon_filename : "gmon.out";
!     fd = creat( filename , 0666 );
      if ( fd < 0 ) {
  	perror( "mcount: gmon.out" );

home help back first fref pref prev next nref lref last post