Path: utzoo!attcan!uunet!mcvax!cernvax!ethz!iis!prl From: prl@iis.UUCP (Peter Lamb) Newsgroups: comp.lang.c++ Subject: Re: profiling C++ programs Message-ID: <714@eiger.iis.UUCP> Date: 13 Dec 88 10:49:17 GMT References: <1790@kano.cs.vu.nl> Reply-To: prl@iis.UUCP (Peter Lamb) Organization: Integrated Systems Lab., ETH Zuerich Lines: 47 In article <1790@kano.cs.vu.nl> frans@cs.vu.nl (Frans Heeman) writes: >I tried to make a profile of a C++ program, using the -p (or -pg) flag: > CC -p *.c >During linking, the following error was produced: > _exit: /usr/lib/libc_p.a(exit.o): multiply defined > The problem is that exit() is defined in /lib/mcrt0.o and /lib/gcrt0.o . The reason for this is so that you don't have to have a different exit() function in /lib/libc.a . It is quite difficult to get profiling to work correctly, especially if you want to support a number of programming environments (we have AT&T 1.2.1 on Vax, Sun, Alliant and Sequent). I couldn't make the combination of profiling, executing destructors and doing stdio cleanup work correctly for an exit function called exit(). So, what I have done is to change the distributed exit.c code to do the following: #ifndef PROFILE_LIB ... Original AT&T code for C++ exit #endif void Exit(int i) { dtors(); exit(i); } The library must be compiled for profiling with PROFILE_LIB defined. If you want to use profiling, you have to exit with Exit(i) rather than exit(i). This is *ugly*, and I would really appreciate someone giving me a better solution. -- Peter Lamb uucp: uunet!mcvax!ethz!prl eunet: prl@ethz.uucp Tel: +411 256 5241 Integrated Systems Laboratory ETH-Zentrum, 8092 Zurich