devooght@ads.com (Lawrence De Vooght) (06/26/91)
I sent this letter out the other day: =================================== >> Subject: Gprof -gnu profiler - I need advise >> Message-ID: <ugenblf3ra@ads.com> >> Sender: usenet@ads.com (USENET News) >>Organization: Advanced Decision Systems, Mtn. View, CA (415) 960-7300 >>Distribution: usa >>Date: Fri, 21 Jun 91 10:15:23 PDT >>Lines: 34 >> I am trying to find out if it us possible to use the Gnu Profiler - >>Gprof - with g++ compiled code. >> I have quite a large image (20mg) that I want to profile and I am >>having problems getting the GPROF to work. I have done the following. >>On a Sparc station: >>the code consists of, Xwindow, Interviews and g++ >>compiled the source with the -pg option -- g++ compiler >>linked the o's with the -pg option >>make sure that the program executes in the prescribed manner - with >>exit(0) >>---- >>result is no gmon.out is generated, any suggestion or insights ? >> Thanks in advance, >> devooght@ads.com ==================== I received a number of answers to my problem some of them complex other simple. I choose the most simple -- and it worked with one exception. I defined the extern function as - extern "C" void monitor() --. The following is the fix ---- Thanks Miron Cuperman. From: miron@cs.sfu.ca (Miron Cuperman) Newsgroups: gnu.emacs.help,gnu.g++.help,gnu.gcc.help,gnu.emac Subject: Re: Gprof -gnu profiler - I need advise Message-ID: <1991Jun22.022027.1185@cs.sfu.ca> Date: 22 Jun 91 02:20:27 GMT References: <ugenblf3ra@ads.com> Distribution: usa Organization: Simon Fraser University Lines: 9 You have to execute the following code before exiting: extern void monitor(int); monitor(0); -- by Miron Cuperman <miron@cs.sfu.ca>
fox@allegra.ATt.COM (David Fox) (06/27/91)
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))