- /*
- * Check that we are profiling.
- */
- if (profiling)
- goto out;
- /*
- * Find the return address for mcount,
- * and the return address for mcount's caller.
- */
-#ifdef lint
- selfpc = (char *)0;
- frompcindex = 0;
-#else
- ; /* avoid label botch */
-#ifdef __GNUC__
-#if defined(vax)
- Fix Me!!
-#endif
-#if defined(tahoe)
- Fix Me!!
-#endif
-#if defined(hp300) || defined(luna68k)
- /*
- * selfpc = pc pushed by mcount jsr,
- * frompcindex = pc pushed by jsr into self.
- * In GCC the caller's stack frame has already been built so we
- * have to chase a6 to find caller's raddr. This assumes that all
- * routines we are profiling were built with GCC and that all
- * profiled routines use link/unlk.
- */
- asm("movl a6@(4),%0" : "=r" (selfpc));
- asm("movl a6@(0)@(4),%0" : "=r" (frompcindex));
-#endif
-#else
-#if defined(vax)
- asm(" movl (sp), r11"); /* selfpc = ... (jsb frame) */
- asm(" movl 16(fp), r10"); /* frompcindex = (calls frame) */
-#endif
-#if defined(tahoe)
- asm(" movl -8(fp),r12"); /* selfpc = callf frame */
- asm(" movl (fp),r11");
- asm(" movl -8(r11),r11"); /* frompcindex = 1 callf frame back */
-#endif
-#if defined(hp300) || defined(luna68k)
- Fix Me!!
-#endif
-#endif /* not __GNUC__ */
-#endif /* not lint */
- /*
- * Insure that we cannot be recursively invoked.
- * this requires that splhigh() and splx() below
- * do NOT call mcount!
- */
-#if defined(hp300) || defined(luna68k)
- asm("movw sr,%0" : "=g" (s));
- asm("movw #0x2700,sr");
-#else
- s = splhigh();
-#endif
- /*
- * Check that frompcindex is a reasonable pc value.
- * For example: signal catchers get called from the stack,
- * not from text space. too bad.
- */
- frompcindex = (u_short *)((long)frompcindex - (long)s_lowpc);
- if ((u_long)frompcindex > s_textsize)
- goto done;
- frompcindex =
- &froms[((long)frompcindex) / (HASHFRACTION * sizeof (*froms))];
- toindex = *frompcindex;
- if (toindex == 0) {
- /*
- * First time traversing this arc
- */
- toindex = ++tos[0].link;
- if (toindex >= tolimit)
- goto overflow;
- *frompcindex = toindex;
- top = &tos[toindex];
- top->selfpc = selfpc;
- top->count = 1;
- top->link = 0;
- goto done;