Xref: utzoo gnu.g++.help:891 comp.lang.c++:14400 Newsgroups: gnu.g++.help,comp.lang.c++ Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!allegra.ATt.COM!fox From: fox@allegra.ATt.COM (David Fox) Subject: Re: Gprof for g++; fixed - here's how. Message-ID: <9106262023.AA12838@life.ai.mit.edu> Sender: gnulists@ai.mit.edu Organization: Gatewayed from the GNU Project mailing list help-g++@prep.ai.mit.edu Date: Wed, 26 Jun 1991 20:22:27 GMT Lines: 79 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))