From owner-freebsd-questions Wed May 16 14:31:22 2001 Delivered-To: freebsd-questions@freebsd.org Received: from MPI-Softtech.Com (mpi.mpi-softtech.com [208.60.120.177]) by hub.freebsd.org (Postfix) with ESMTP id CB53B37B423 for ; Wed, 16 May 2001 14:31:15 -0700 (PDT) (envelope-from dleimbac@MPI-Softtech.Com) Received: from mpi.mpi-softtech.com (mpi.mpi-softtech.com [208.60.120.177]); by MPI-Softtech.Com (8.9.3/8.9.3/MPI-Softtech/evision: 1.3 $) with SMTP; id QAA04973; Wed, 16 May 2001 16:31:05 -0500 (CDT) Message-Id: <200105162131.QAA04973@MPI-Softtech.Com> Date: Wed, 16 May 2001 16:31:05 -0500 (CDT) From: Dave Leimbach Reply-To: Dave Leimbach Subject: Re: mproff/c++ To: freebsd-questions@FreeBSD.ORG, kmarx@bigshed.com Cc: kmarx@ankimo.bigshed.com MIME-Version: 1.0 Content-Type: TEXT/plain; charset=us-ascii Content-MD5: zGwqt4PMWXwzKjrlFAiXbg== X-Mailer: dtmail 1.3.0 CDE Version 1.3 SunOS 5.7 sun4u sparc Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG I have a guess.... C++ uses name mangling to achieve the ability known as overloading. This name mangling is applied to the symbols that represent function names in your object file. C doesn't have overloading capabilities and thusly doesn't mangle the names. Its possible that mproff only works with non-mangled symbols for function names. If this is the case you can declare all of your functions in C++ to be extern "C". That will effectively disable name mangling. I have never used mproff so I can't give you a definitive answer. Dave >Delivered-To: freebsd-questions@freebsd.org >Subject: mproff/c++ >To: freebsd-questions@FreeBSD.ORG (questions freeBSD) >Date: Wed, 16 May 2001 14:27:58 -0700 (PDT) >Cc: kmarx@ankimo.bigshed.com (Kenneth J Marx) >From: Ken Marx >MIME-Version: 1.0 >Content-Transfer-Encoding: 7bit >X-Loop: FreeBSD.ORG > >Hi, > >Is there some reason why mprof barfs on c++ binaries? > >See below for reproduction. > >(The man page does reference problems with using >valloc and memalign, but I put my test binary >in gdb with breakpoints for these and they >never got hit. Both these symbols are defined >in the binary even if I take out the c++ code.) > >thanks, >k. > >-- >Ken Marx, kmarx@bigshed.com >OK. This is a tough pill to swallow but we must recognize who our customers are >and motivate the troops for the solution space. > - http://cgi.bigshed.com/~kmarx/cgi-bin/speak.cgi > >------------------------------------------------------------------------------- >The source: > >[sploot] /tmp <356> cat jnk.c >#include "stdlib.h" > >class dog >{ >public: > dog(); > ~dog(); >}; > >dog::dog() >{ >} > >dog::~dog() >{ >} > >main() >{ > int i=3; > static char *s = "fyuc"; > char *m = (char *)malloc( 10 ); > dog *breath = new dog(); >} >------------------------------------------------------------------------- > >the compile, run, mprof phases: > >[sploot] /tmp <357> g++ -g jnk.c -lc_mp >[sploot] /tmp <358> a.out >[sploot] /tmp <359> mprof -verbose a.out >--c20+--v3.0+--m3+--+--+--+--+--+--+--+--+ MPROF +--+--+--+--+--+--+--s0+--f0+--d0+--l0+ > > >--------- Allocation Bins with possible Types ------------ > > size: allocs bytes (%) frees kept (%) types > > 1 1 1 (9) 0 1 (9) dog > 10 1 10 (90) 0 10 (90) > > 1024 0 0 0 0 > > 2 11 1 11 > > > >--------- Partial Dynamic Call Paths for Memory Leaks ------------ > >Total bytes not freed: 11 > >kept bytes (%) allocs bytes (%) path > > 10 (90) 1 10 (90) || > _start > main >Segmentation fault (core dumped) > >------------------------------------------------------------------------------- > >[sploot] /tmp <365> wc mprof.data > 2083 2176 4507 mprof.data > > >To Unsubscribe: send mail to majordomo@FreeBSD.org >with "unsubscribe freebsd-questions" in the body of the message To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message