Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 May 2001 16:31:05 -0500 (CDT)
From:      Dave Leimbach <dleimbac@MPI-Softtech.Com>
To:        freebsd-questions@FreeBSD.ORG, kmarx@bigshed.com
Cc:        kmarx@ankimo.bigshed.com
Subject:   Re: mproff/c++
Message-ID:  <200105162131.QAA04973@MPI-Softtech.Com>

next in thread | raw e-mail | index | archive | help
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 <kmarx@bigshed.com>
>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();
>}
>----------------------------------<snip>---------------------------------------
>
>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        
>
>    <TOTAL>         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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200105162131.QAA04973>