profiling with cc

Marius Strobl marius at alchemy.franken.de
Sun Feb 5 08:57:04 PST 2006


On Sun, Feb 05, 2006 at 03:44:21PM +0100, Andreas Tobler wrote:
> Marius Strobl wrote:
> > On Sun, Feb 05, 2006 at 12:52:45PM +0100, Andreas Tobler wrote:
> >> Marius Strobl wrote:
> >>
> >>> I think all it takes is the MD _mcount() -> mcount() wrapper but I'm
> >>> not sure what it's actually supposed to do.
> >> Ok, thank you for the pointer. I try to read through the code and see if 
> >> I can get something out of it.
> >>
> >> Build question, if I play around in this section, does it mean to 
> >> rebuild the whole kernel/world everytime, or is it enough to just 
> >> compile and install the modified parts ?
> >>
> > 
> > AFAICT the wrapper has to go into the userland version of the MCOUNT
> > macro in <machine/profile.h> and you'll have to re-compile and re-
> > install libc, specifically libc_p.a, in order to test it.
> 
> Good.
> 
> To my understanding, the wrapper should look similar like in
>   sys/amd64/include/profile.h?
> 

Basically yes.

> 
> #else /* !_KERNEL */
> #define _MCOUNT_DECL \
> static void _mcount(uintfptr_t frompc, uintfptr_t selfpc) __used; \
> static void _mcount
> 
> #ifdef __GNUCLIKE_ASM
> 
> #define MCOUNT \
>         __asm(".global " _mcount);\
>         __asm(_mcount ":");\
>         __asm("add %o7, 8, %o1");\
>         __asm("1: call 2f; nop; 2:");\
>         __asm("add %o7," __mcount "-1b, %o2");\
>         __asm("ld [%o2], %o2");\
>         __asm("jmpl %o2, %g0");\
>         __asm("add %i7, 8, %o0");
> #else /* !__GNUCLIKE_ASM */
> #define MCOUNT                                       \
> void                                                 \
> mcount()                                             \
> {                                                    \
> }
> #endif /* __GNUCLIKE_ASM */
> 
> Or am I looking to far?
> 
> The above asm code comes from NetBSD...
> 

As far as I understand MCOUNT refers to the symbol generated by the
compiler and _MCOUNT_DECL to the name of the real function in libc.
As the compiler apparently generates calls to _mcount() on sparc64
the MCOUNT macro should define _mcount() for userland and _MCOUNT_DECL
mcount() or maybe better __mcount(). I'm not sure wheter the NetBSD
asm applies to FreeBSD.
If you let _MCOUNT_DECL define _mcount() as in your snippet above
you'll bypass the wrapper on sparc64 altogether.

Marius

-- 
This mail was scanned by AntiVir Milter.
This product is licensed for non-commercial use.
See www.antivir.de for details.


More information about the freebsd-sparc64 mailing list