profiling with cc

Andreas Tobler toa at pop.agri.ch
Tue Feb 7 12:00:48 PST 2006


Marius Strobl wrote:

> If you just cd to src/lib/libc and issue make it's expected that the
> system headers, i.e. the headers in /usr/include, are used as that's
> basically the same as issuing make on any other source in any other
> location. "Magic" regarding using the headers below src instead of
> the system headers only happens when running a buildworld as then
> (as far as I'm aware) a GCC with a special standard include path is
> built and used.

Heh. Anyway, buildworld just for testing is a bit lot of overhead.
I solved it with symlinking.

>> P.S, even a pointer to read all through would be good.
> 
> Well, I think if you want to know how the build process works there's
> no way around reading the Makefiles in src and /usr/share/mk/*.

Thanks.

Ok, back to the topic.

Attached what I have so far. I built a libc_p.a and I can compile some 
code with -pg and do some investigations with gprof now.

Done on an enterprise 2 2x296MHz 896MB.

FreeBSD enterprise.andreas.nets 7.0-CURRENT FreeBSD 7.0-CURRENT #0: Sun 
Feb  5 08:20:12 CET 2006 
andreast at enterprise.andreas.nets:/usr/obj/home/andreast/devel/src/sys/GENERIC 
  sparc64

What I do not know yet, is the fact, how reliably the figures are.


Would you mind giving me some feedback if the attached is useful/needs 
rework?

TIA,

Andreas
-------------- next part --------------
Index: sys/sparc64/include/profile.h
===================================================================
RCS file: /home/ncvs/src/sys/sparc64/include/profile.h,v
retrieving revision 1.8
diff -u -r1.8 profile.h
--- sys/sparc64/include/profile.h	7 Jan 2005 02:29:22 -0000	1.8
+++ sys/sparc64/include/profile.h	7 Feb 2006 19:37:47 -0000
@@ -32,13 +32,16 @@
 #ifndef _MACHINE_PROFILE_H_
 #define	_MACHINE_PROFILE_H_
 
-#define	FUNCTION_ALIGNMENT 32
-#define	_MCOUNT_DECL	void mcount
-#define	MCOUNT
+#define _MCOUNT_SYM "mcount"
+#define _MCOUNT_ENTRY "_mcount"
+
+#define FUNCTION_ALIGNMENT 32
 
 typedef u_long	fptrdiff_t;
 
 #ifdef _KERNEL
+#define _MCOUNT_DECL    void mcount
+#define MCOUNT
 
 #include <machine/cpufunc.h>
 
@@ -63,6 +66,26 @@
 
 #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_ENTRY);		 \
+  __asm(_MCOUNT_ENTRY ":");			 \
+  __asm("add %i7, 8, %o0");			 \
+  __asm("sethi %hi(" _MCOUNT_SYM "), %o2");	 \
+  __asm("jmpl %o2 + %lo(" _MCOUNT_SYM "), %g0"); \
+  __asm("add %o7, 8, %o1") ;
+
+#else /* !__GNUCLIKE_ASM  */
+#define MCOUNT					\
+  void						\
+  mcount()					\
+  {						\
+  }
+#endif /* __GNUCLIKE_ASM  */
 typedef u_long	uintfptr_t;
 
 #endif /* _KERNEL */


More information about the freebsd-sparc64 mailing list