🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by David Fox Wed, 26 Jun 1991 20:22
Re: Gprof for g++; fixed - here's how.
#649
Author: David Fox
Date: Wed, 26 Jun 1991 20:22
78 lines
3477 bytes
This is a workable solution, but it has a number of drawbacks:

 1) The documentation says you should get a gmon.out file even
    if you don't call monitor before exiting.
 2) You shouldn't have to change your source code to do profiling.
 3) You need to load with a profiling version of libg++ to get
    profiling data for the library routines.

Here is my solution.  First, apply this patch to gcc.c and recompile
to produce the executable g++:

*** gcc.c~	Tue Apr 30 23:46:57 1991
--- gcc.c	Mon Jun 17 09:03:02 1991
***************
*** 311,315 ****
   %{A} %{d} %{e*} %{N} %{n} %{r} %{s} %{S} %{T*} %{t} %{u*} %{X} %{x} %{z}\
   %{y*} %{!nostdlib:%S} \
!  %{L*} %o %{!nostdlib:-lg++ gnulib%s %{g:-lg} %L}\n }}}}";
  #else
  /* Here is the spec for running the linker, after compiling all files.  */
--- 311,315 ----
   %{A} %{d} %{e*} %{N} %{n} %{r} %{s} %{S} %{T*} %{t} %{u*} %{X} %{x} %{z}\
   %{y*} %{!nostdlib:%S} \
!  %{L*} %o %{!nostdlib:-lg++%{p:_p}%{pg:_p} gnulib%s %{g:-lg} %L}\n }}}}";
  #else
  /* Here is the spec for running the linker, after compiling all files.  */
***************
*** 317,321 ****
   %{A} %{d} %{e*} %{N} %{n} %{r} %{s} %{S} %{T*} %{t} %{u*} %{X} %{x} %{z}\
   %{y*} %{!nostdlib:%S} \
!  %{L*} %o %{!nostdlib:-lg++ gnulib%s %{g:-lg} %L}\n }}}}";
  #endif
  
--- 317,321 ----
   %{A} %{d} %{e*} %{N} %{n} %{r} %{s} %{S} %{T*} %{t} %{u*} %{X} %{x} %{z}\
   %{y*} %{!nostdlib:%S} \
!  %{L*} %o %{!nostdlib:-lg++%{p:_p}%{pg:_p} gnulib%s %{g:-lg} %L}\n }}}}";
  #endif
  

Next apply this patch to gnulib3.c in libg++:

*** gnulib3.c~	Sat Nov 25 10:16:43 1989
--- gnulib3.c	Mon Jun  3 21:45:28 1991
***************
*** 35,43 ****
  */
  
- #if 0
  #if defined(sun)
  #define ON_EXIT(PROCP, ARG) \
    do { extern void PROCP (); on_exit (PROCP, ARG); } while (0)
- #endif
  #endif
  
--- 35,41 ----

(That is, delete the #if 0 ... #endif pair.)
Recompile libg++ with the -pg flag and install the result with the
name libg++_p.a in the same directory as libg++.a.  Now the compiler
should work as documented.  While you're at it, apply this patch and
recompile ccplus1 to get operator delete to work correctly:

*** cplus-decl.c~	Tue Apr 30 23:46:53 1991
--- cplus-decl.c	Mon Jun  3 10:55:54 1991
***************
*** 7954,7958 ****
  	exprstmt = build_method_call (build1 (NOP_EXPR, TYPE_POINTER_TO (current_class_type), error_mark_node),
  				      get_identifier (OPERATOR_DELETE_FORMAT),
! 				      build_tree_list (NULL_TREE, integer_zero_node),
  				      NULL_TREE, LOOKUP_NORMAL);
        else if (TYPE_USES_VIRTUAL_BASECLASSES (current_class_type))
--- 7954,7958 ----
  	exprstmt = build_method_call (build1 (NOP_EXPR, TYPE_POINTER_TO (current_class_type), error_mark_node),
  				      get_identifier (OPERATOR_DELETE_FORMAT),
! 				      build_tree_list (NULL_TREE, current_class_decl),
  				      NULL_TREE, LOOKUP_NORMAL);
        else if (TYPE_USES_VIRTUAL_BASECLASSES (current_class_type))
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads